Sha256: 5538aa90b41010f16996e0b7eefca9cc7d7f4b1291a5ff7ad956cfdf5e0b8da1
Contents?: true
Size: 1.05 KB
Versions: 6
Compression:
Stored size: 1.05 KB
Contents
module Services module Hubspot module Associations class GetById def initialize(company_id) @company_id = company_id end def call return unless associated_contacts_id_object.present? contacts_list = ::Hubspot::Crm::Contacts::BatchApi.new.read( body: associated_contacts_id_object, auth_names: 'oauth2' ).results end private def associated_contacts_id_object id_objects = ::Hubspot::Crm::Associations::BatchApi.new.read( 'companies', 'contacts', body: company_id_object, auth_names: 'oauth2' ).results id_objects = id_objects.present? ? id_objects[0].to : [] ::Hubspot::Crm::Contacts::BatchReadInputSimplePublicObjectId.new(inputs: id_objects) end def company_id_object @company_id_object ||= ::Hubspot::Crm::Associations::BatchInputPublicObjectId.new( inputs: [@company_id] ) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems