module Emarsys module Api class Services < Base 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 def email_queue(customer_id, params) response = client.post "customers/#{customer_id}/email_queue/", JSON.generate(params) validate_response! response response.body end private def module_path '/api/services' end 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 end end end