class HubSpot::HTTPApiCalls::Contact::CreateOrUpdate

Constants

URL

Attributes

properties[R]

Public Class Methods

new(properties) click to toggle source
# File lib/hub_spot/http_api_calls/contact/create_or_update.rb, line 10
def initialize(properties)
  @properties = ::HubSpot.stringify_keys(properties)
end

Private Instance Methods

auth_header_value() click to toggle source
# File lib/hub_spot/http_api_calls/contact/create_or_update.rb, line 34
def auth_header_value
  "Bearer #{HubSpot::OAuth.access_token}"
end
email() click to toggle source
# File lib/hub_spot/http_api_calls/contact/create_or_update.rb, line 26
def email
  properties.fetch("email")
end
headers() click to toggle source
# File lib/hub_spot/http_api_calls/contact/create_or_update.rb, line 30
def headers
  default_headers.merge(HubSpot::HTTP::AUTHORIZATION => auth_header_value)
end
make_the_call() click to toggle source
# File lib/hub_spot/http_api_calls/contact/create_or_update.rb, line 18
def make_the_call
  HubSpot::HTTP.post(url: url, headers: headers, post_body: post_body)
end
post_body() click to toggle source
# File lib/hub_spot/http_api_calls/contact/create_or_update.rb, line 38
def post_body
  { "properties" => properties_array }
end
properties_array() click to toggle source
# File lib/hub_spot/http_api_calls/contact/create_or_update.rb, line 42
def properties_array
  properties.map { |k, v| { "property" => k.to_s, "value" => v } }
end
url() click to toggle source
# File lib/hub_spot/http_api_calls/contact/create_or_update.rb, line 22
def url
  format(URL, email: email)
end