Sha256: c317f9a8447ef856242d0f0d680e4045763ce575f3c6e8ec96a4efdb5562ca09

Contents?: true

Size: 627 Bytes

Versions: 8

Compression:

Stored size: 627 Bytes

Contents

# frozen_string_literal: true

module Intercom
  class DeprecatedLeadsCollectionProxy < ClientCollectionProxy
    def fetch(next_page)
      response_hash = if next_page
                        @client.get(next_page, {})
                      else
                        @client.get(@url, @params)
                      end
      transform(response_hash)
    end

    def transform(response_hash)
      response_hash['type'] = 'lead.list'
      leads_list = response_hash.delete('contacts')
      leads_list.each { |lead| lead['type'] = 'lead' }
      response_hash['leads'] = leads_list
      response_hash
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
intercom-4.2.1 lib/intercom/deprecated_leads_collection_proxy.rb
intercom-4.2.0 lib/intercom/deprecated_leads_collection_proxy.rb
intercom-4.1.3 lib/intercom/deprecated_leads_collection_proxy.rb
intercom-4.1.2 lib/intercom/deprecated_leads_collection_proxy.rb
intercom-4.1.1 lib/intercom/deprecated_leads_collection_proxy.rb
intercom-4.1.0 lib/intercom/deprecated_leads_collection_proxy.rb
intercom-4.0.1 lib/intercom/deprecated_leads_collection_proxy.rb
intercom-4.0.0 lib/intercom/deprecated_leads_collection_proxy.rb