Sha256: 81987bd7426cc01133ea720dbb8c8e1be7aa3cc0612c1ee89eb0b9f025b5058e
Contents?: true
Size: 1.05 KB
Versions: 16
Compression:
Stored size: 1.05 KB
Contents
module Services module Hubspot module Contacts class Search def initialize(email:) @email = email end def call search_api = ::Hubspot::Crm::Contacts::SearchApi.new results = search_api.do_search(search_request, auth_names: 'oauth2').results results = add_fullnames(results) results end private def search_request filter = ::Hubspot::Crm::Contacts::Filter.new( property_name: 'email', operator: 'EQ', value: @email ) filter_group = ::Hubspot::Crm::Contacts::FilterGroup.new(filters: [filter]) ::Hubspot::Crm::Contacts::PublicObjectSearchRequest.new(filter_groups: [filter_group]) end def add_fullnames(contacts) contacts.each do |contact| fullname = [contact.properties['firstname'], contact.properties['lastname']].reject(&:empty?).join(' ') contact.properties['fullname'] = fullname end end end end end end
Version data entries
16 entries across 6 versions & 1 rubygems