Class: SFMC::Contacts::ContactKey

Inherits:
SFMCBase
  • Object
show all
Defined in:
lib/sfmc/contacts/contact_key.rb

Constant Summary

Constants inherited from SFMCBase

SFMCBase::NAME_TO_METHOD

Class Method Summary collapse

Methods inherited from SFMCBase

authenticate_and_retry, request

Methods included from Helpers

#get_subscriber_key, #init, #set_base_uri

Methods included from Errors

#error_class, #error_message

Class Method Details

.find(emails, max = 1) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/sfmc/contacts/contact_key.rb', line 6

def self.find(emails, max = 1)
  emails = [emails] unless emails.is_a? Array

  params = {
    channelAddressList: emails,
    maximumCount: max,
  }
  response = create(nil, params)

  response.channelAddressResponseEntities.map do |channel|
    key = channel[:contactKeyDetails].first[:contactKey]
    raise SFMC::Errors::NotFoundError if key.nil?

    key
  end
end