Class: HubspotClient::Model::Company
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- HubspotClient::Model::Company
- Defined in:
- lib/hubspot_client/model/company.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.create(properties) ⇒ Object
14 15 16 17 18 |
# File 'lib/hubspot_client/model/company.rb', line 14 def self.create(properties) response = Client::Company.new.create(properties) new(response['properties']) end |
.find(hubspot_id: nil) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/hubspot_client/model/company.rb', line 6 def self.find(hubspot_id: nil) response = Client::Company.new.find_by_id(hubspot_id) return nil if response['properties'].nil? new(response['properties']) end |
Instance Method Details
#assign_attributes(attributes) ⇒ Object
38 39 40 41 42 |
# File 'lib/hubspot_client/model/company.rb', line 38 def assign_attributes(attributes) attributes.each do |attribute, value| self[attribute] = value end end |
#reload ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/hubspot_client/model/company.rb', line 29 def reload response = Client::Company.new.find_by_id(hs_object_id) response['properties'].each do |key, value| self[key] = value if value != self[key] end self end |
#update(new_properties = {}) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/hubspot_client/model/company.rb', line 20 def update(new_properties = {}) assign_attributes(new_properties) response = Client::Company.new.update(hs_object_id, to_h.slice(*writable_properties)) return true if response.code == 200 false end |