Sha256: 3aba2b2cfe79e501688c86f3a1cd6b2ec64a13856ce874437a8c8538ed5335ca

Contents?: true

Size: 1015 Bytes

Versions: 4

Compression:

Stored size: 1015 Bytes

Contents

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
emarsys-api-0.6.1 lib/emarsys/api/services.rb
emarsys-api-0.6.0 lib/emarsys/api/services.rb
emarsys-api-0.5.0 lib/emarsys/api/services.rb
emarsys-api-0.4.0 lib/emarsys/api/services.rb