class RDStation::Contacts

More info: developers.rdstation.com/pt-BR/reference/contacts

Public Class Methods

new(authorization:) click to toggle source
# File lib/rdstation/contacts.rb, line 8
def initialize(authorization:)
  @authorization = authorization
end

Public Instance Methods

by_email(email) click to toggle source
# File lib/rdstation/contacts.rb, line 23
def by_email(email)
  retryable_request(@authorization) do |authorization|
    response = self.class.get(base_url("email:#{email}"), headers: authorization.headers)
    ApiResponse.build(response)
  end
end
by_uuid(uuid) click to toggle source

param uuid:

The unique uuid associated to each RD Station Contact.
# File lib/rdstation/contacts.rb, line 16
def by_uuid(uuid)
  retryable_request(@authorization) do |authorization|
    response = self.class.get(base_url(uuid), headers: authorization.headers)
    ApiResponse.build(response)
  end
end
update(uuid, contact_hash) click to toggle source

The Contact hash may contain the following parameters: :email :name :job_title :linkedin :facebook :twitter :personal_phone :mobile_phone :website :tags

# File lib/rdstation/contacts.rb, line 41
def update(uuid, contact_hash)
  retryable_request(@authorization) do |authorization|
    response = self.class.patch(base_url(uuid), :body => contact_hash.to_json, :headers => authorization.headers)
    ApiResponse.build(response)
  end
end
upsert(identifier, identifier_value, contact_hash) click to toggle source

param identifier:

Field that will be used to identify the contact.

param identifier_value:

Value to the identifier given.

param contact_hash:

Contact data
# File lib/rdstation/contacts.rb, line 56
def upsert(identifier, identifier_value, contact_hash)
  retryable_request(@authorization) do |authorization|
    path = "#{identifier}:#{identifier_value}"
    response = self.class.patch(base_url(path), body: contact_hash.to_json, headers: authorization.headers)
    ApiResponse.build(response)
  end
end

Private Instance Methods

base_url(path = '') click to toggle source
# File lib/rdstation/contacts.rb, line 66
def base_url(path = '')
  "https://api.rd.services/platform/contacts/#{path}"
end