Class: HubspotClient::Client::Company
- Inherits:
-
Object
- Object
- HubspotClient::Client::Company
- Includes:
- HTTParty
- Defined in:
- lib/hubspot_client/client/company.rb
Constant Summary collapse
- BASE_PATH =
'/crm/v3/objects/companies'
- FIND_PROPERTIES =
%w[name phone address city zip].freeze
Instance Method Summary collapse
- #create(properties) ⇒ Object
- #find_by_id(hubspot_id) ⇒ Object
- #update(hubspot_id, properties) ⇒ Object
Instance Method Details
#create(properties) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/hubspot_client/client/company.rb', line 24 def create(properties) response = self.class.post(BASE_PATH, body: { properties: properties }.to_json, headers: headers) return response if response.code == 201 raise CompanyNotCreated, response end |
#find_by_id(hubspot_id) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/hubspot_client/client/company.rb', line 16 def find_by_id(hubspot_id) response = self.class.get("#{BASE_PATH}/#{hubspot_id}?properties=#{FIND_PROPERTIES.join(',')}", headers: headers) return response if response.code == 200 raise CompanyNotFound, response end |
#update(hubspot_id, properties) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/hubspot_client/client/company.rb', line 34 def update(hubspot_id, properties) response = self.class.patch("#{BASE_PATH}/#{hubspot_id}", body: { properties: properties }.to_json, headers: headers) return response if response.code == 200 raise CompanyNotUpdated, response end |