Class: RogIQ::Commands::Sync

Inherits:
Base
  • Object
show all
Defined in:
lib/rogiq/commands/sync.rb

Instance Method Summary collapse

Instance Method Details

#integrations(identifier) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rogiq/commands/sync.rb', line 41

def integrations(identifier)
  RogIQ.load_rails!
  client = RogIQ::Helpers.resolve_client(identifier)
  unless client
    fmt.error_msg("Client not found")
    exit 1
  end

  ids = client.integrations.pluck(:id)
  if ids.empty?
    fmt.warn_msg("No integrations linked to this client.")
    return
  end

  ids.each { |iid| ::Integrations::SyncJob.perform_later(iid) }
  fmt.success("Enqueued #{ids.size} Integrations::SyncJob(s).")
end

#postmanObject



7
8
9
10
11
# File 'lib/rogiq/commands/sync.rb', line 7

def postman
  RogIQ.load_rails!
  Rails.application.load_tasks
  Rake::Task["postman:sync"].invoke
end

#stripeObject



14
15
16
17
18
# File 'lib/rogiq/commands/sync.rb', line 14

def stripe
  RogIQ.load_rails!
  Rails.application.load_tasks
  Rake::Task["stripe:ensure_subscription_prices"].invoke
end

#wordpress(identifier) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rogiq/commands/sync.rb', line 21

def wordpress(identifier)
  RogIQ.load_rails!
  client = RogIQ::Helpers.resolve_client(identifier)
  unless client
    fmt.error_msg("Client not found")
    exit 1
  end

  ::Integrations::SyncWordpressTaxonomiesJob.perform_later(
    account_id: client.,
    client_id: client.id
  )
  ::Integrations::SyncWordpressAuthorsJob.perform_later(
    account_id: client.,
    client_id: client.id
  )
  fmt.success("WordPress sync jobs enqueued for client #{client.id}.")
end