class Emarsys::Api::Services

Public Instance Methods

email_queue(customer_id, params) click to toggle source
# File lib/emarsys/api/services.rb, line 14
def email_queue(customer_id, params)
  response = client.post "customers/#{customer_id}/email_queue/", JSON.generate(params)
  validate_response! response

  response.body
end
flippers(customer_id) click to toggle source
# File lib/emarsys/api/services.rb, line 21
def flippers(customer_id)
  response = client.get("customers/#{customer_id}/flippers")
  validate_response!(response)

  response.body['flippers'].each_with_object({}) do |flipper, flippers|
    flippers[flipper['id']] = flipper['is_on']
  end
end
launchlist_get(customer_id, campaign_id, limit = 10_000, offset = 0) click to toggle source
# File lib/emarsys/api/services.rb, line 5
def launchlist_get(customer_id, campaign_id, limit = 10_000, offset = 0) # rubocop:disable Metrics/ParameterLists
  params = { limit: limit, offset: offset }
  response = client.get "customers/#{customer_id}/campaigns/#{campaign_id}/launch_list/contact_ids/", params

  validate_response! response

  response.body['contact_ids']
end

Private Instance Methods

module_path() click to toggle source
# File lib/emarsys/api/services.rb, line 32
def module_path
  '/api/services'
end
parse_for_error(response) click to toggle source
Calls superclass method Emarsys::Api::Base#parse_for_error
# File lib/emarsys/api/services.rb, line 36
def parse_for_error(response)
  errors = response.body['errors']
  if response.body.is_a?(Hash) && errors.is_a?(Array) && errors.first.is_a?(Hash)
    [errors.first['message'], response.status, errors.first['code']]
  else
    super
  end
end