Class: HubspotClient::Client::CommunicationPreference

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/hubspot_client/client/communication_preference.rb

Constant Summary collapse

BASE_PATH =
'/communication-preferences/v3'

Instance Method Summary collapse

Instance Method Details

#definitionsObject



14
15
16
17
18
19
20
21
# File 'lib/hubspot_client/client/communication_preference.rb', line 14

def definitions
  response = self.class.get("#{BASE_PATH}/definitions",
                            headers: headers)

  return response if response.code == 200

  raise FetchDefinitionsNotSuccessful, response
end

#headersObject



33
34
35
36
# File 'lib/hubspot_client/client/communication_preference.rb', line 33

def headers
  { Authorization: "Bearer #{HubspotClient.configuration.access_token}",
    'Content-Type': 'application/json' }
end

#subscribe(properties) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/hubspot_client/client/communication_preference.rb', line 23

def subscribe(properties)
  response = self.class.post("#{BASE_PATH}/subscribe",
                             body: properties.to_json,
                             headers: headers)

  return response if response.code == 200

  raise SubscriptionNotSuccessful, response
end