Sha256: fbdaa1dafd854717f0f196a416062c2478a07cba4888570a17ab6cd2e3990db3

Contents?: true

Size: 989 Bytes

Versions: 20

Compression:

Stored size: 989 Bytes

Contents

module Services
  module Hubspot
    module Contacts
      class CreateBatch
        def initialize(emails, access_token)
          @emails = emails
          @access_token = access_token
        end

        def call
          contacts_object = ::Hubspot::Crm::Contacts::BatchInputSimplePublicObjectInput.new(
            inputs: contacts
          )
          batch_api.create(body: contacts_object, auth_names: 'oauth2')
        end

        private

        def contacts
          @emails.map do |email|
            ::Hubspot::Crm::Contacts::SimplePublicObjectInput.new(
              properties: { email: email }
            )
          end
        end

        def batch_api
          config = ::Hubspot::Crm::Contacts::Configuration.new do |config|
            config.access_token = @access_token
          end
          api_client = ::Hubspot::Crm::Contacts::ApiClient.new(config)
          ::Hubspot::Crm::Contacts::BatchApi.new(api_client)
        end
      end
    end
  end
end

Version data entries

20 entries across 10 versions & 1 rubygems

Version Path
hubspot-api-client-7.1.0 sample-apps/rate-limits-redis-sample-app/app/lib/services/hubspot/contacts/create_batch.rb
hubspot-api-client-7.1.0 sample-apps/leaky-bucket-app/app/lib/services/hubspot/contacts/create_batch.rb
hubspot-api-client-7.0.0 sample-apps/rate-limits-redis-sample-app/app/lib/services/hubspot/contacts/create_batch.rb
hubspot-api-client-7.0.0 sample-apps/leaky-bucket-app/app/lib/services/hubspot/contacts/create_batch.rb
hubspot-api-client-6.0.0 sample-apps/leaky-bucket-app/app/lib/services/hubspot/contacts/create_batch.rb
hubspot-api-client-6.0.0 sample-apps/rate-limits-redis-sample-app/app/lib/services/hubspot/contacts/create_batch.rb
hubspot-api-client-5.0.0 sample-apps/rate-limits-redis-sample-app/app/lib/services/hubspot/contacts/create_batch.rb
hubspot-api-client-5.0.0 sample-apps/leaky-bucket-app/app/lib/services/hubspot/contacts/create_batch.rb
hubspot-api-client-4.0.0 sample-apps/leaky-bucket-app/app/lib/services/hubspot/contacts/create_batch.rb
hubspot-api-client-4.0.0 sample-apps/rate-limits-redis-sample-app/app/lib/services/hubspot/contacts/create_batch.rb
hubspot-api-client-3.3.0 sample-apps/rate-limits-redis-sample-app/app/lib/services/hubspot/contacts/create_batch.rb
hubspot-api-client-3.3.0 sample-apps/leaky-bucket-app/app/lib/services/hubspot/contacts/create_batch.rb
hubspot-api-client-3.2.0 sample-apps/leaky-bucket-app/app/lib/services/hubspot/contacts/create_batch.rb
hubspot-api-client-3.2.0 sample-apps/rate-limits-redis-sample-app/app/lib/services/hubspot/contacts/create_batch.rb
hubspot-api-client-3.1.1 sample-apps/rate-limits-redis-sample-app/app/lib/services/hubspot/contacts/create_batch.rb
hubspot-api-client-3.1.1 sample-apps/leaky-bucket-app/app/lib/services/hubspot/contacts/create_batch.rb
hubspot-api-client-3.1.0.pre.beta sample-apps/rate-limits-redis-sample-app/app/lib/services/hubspot/contacts/create_batch.rb
hubspot-api-client-3.1.0.pre.beta sample-apps/leaky-bucket-app/app/lib/services/hubspot/contacts/create_batch.rb
hubspot-api-client-3.0.0.pre.beta sample-apps/rate-limits-redis-sample-app/app/lib/services/hubspot/contacts/create_batch.rb
hubspot-api-client-3.0.0.pre.beta sample-apps/leaky-bucket-app/app/lib/services/hubspot/contacts/create_batch.rb