Sha256: cf7a27bd265efd354664e1fdc06552f80955a3be89d53159991536788c8784d7
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module HubSpot module HTTPApiCalls module Contact class CreateOrUpdate include ::HubSpot::HTTPApiCalls::Base URL = "https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/%<email>s" def initialize(properties) @properties = ::HubSpot.stringify_keys(properties) end private attr_reader :properties def make_the_call HubSpot::HTTP.post(url: url, headers: headers, post_body: post_body) end def url format(URL, email: email) end def email properties.fetch("email") end def headers default_headers.merge(HubSpot::HTTP::AUTHORIZATION => auth_header_value) end def auth_header_value "Bearer #{HubSpot::OAuth.access_token}" end def post_body { "properties" => properties_array } end def properties_array properties.map { |k, v| { "property" => k.to_s, "value" => v } } end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hub_spot-0.3.1 | lib/hub_spot/http_api_calls/contact/create_or_update.rb |
hub_spot-0.3.0 | lib/hub_spot/http_api_calls/contact/create_or_update.rb |