Class: Hubspot::Owner
- Inherits:
-
Object
- Object
- Hubspot::Owner
- Defined in:
- lib/hubspot/owner.rb
Overview
HubSpot Owners API
https://developers.hubspot.com/docs/reference/api/crm/owners/v3
Constant Summary collapse
- GET_OWNER_PATH =
GET
'/crm/v3/owners/:owner_id'
- GET_OWNERS_PATH =
GET
'/crm/v3/owners'
- CREATE_OWNER_PATH =
POST
"/crm/v3/owners"
- UPDATE_OWNER_PATH =
PUT
'/crm/v3/owners/:owner_id'
- DELETE_OWNER_PATH =
DELETE
'/crm/v3/owners/:owner_id'
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#owner_id ⇒ Object
readonly
Returns the value of attribute owner_id.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Class Method Summary collapse
- .all(include_archived: false, limit: 100, after: nil) ⇒ Object
- .find(id, id_property: nil) ⇒ Object
- .find_by_email(email, include_archived: false, limit: 100, after: nil) ⇒ Object
- .find_by_emails(emails = [], include_archived: false) ⇒ Object
Instance Method Summary collapse
- #[](property) ⇒ Object
-
#initialize(property_hash) ⇒ Owner
constructor
A new instance of Owner.
Constructor Details
#initialize(property_hash) ⇒ Owner
17 18 19 20 21 |
# File 'lib/hubspot/owner.rb', line 17 def initialize(property_hash) @properties = property_hash @owner_id = @properties['id'] @email = @properties['email'] end |
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
15 16 17 |
# File 'lib/hubspot/owner.rb', line 15 def email @email end |
#owner_id ⇒ Object (readonly)
Returns the value of attribute owner_id.
15 16 17 |
# File 'lib/hubspot/owner.rb', line 15 def owner_id @owner_id end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
15 16 17 |
# File 'lib/hubspot/owner.rb', line 15 def properties @properties end |
Class Method Details
.all(include_archived: false, limit: 100, after: nil) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/hubspot/owner.rb', line 28 def all(include_archived: false, limit: 100, after: nil) path = GET_OWNERS_PATH params = { archived: include_archived, limit: limit, after: after }.compact response = Hubspot::Connection.get_json(path, params) { results: response['results'].map { |r| new(r) }, pagination: { next: response['paging']&.dig('next', 'after'), total: response['total'] } } end |
.find(id, id_property: nil) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/hubspot/owner.rb', line 46 def find(id, id_property: nil) path = GET_OWNER_PATH params = { owner_id: id } params[:idProperty] = id_property if id_property response = Hubspot::Connection.get_json(path, params) new(response) end |
.find_by_email(email, include_archived: false, limit: 100, after: nil) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/hubspot/owner.rb', line 54 def find_by_email(email, include_archived: false, limit: 100, after: nil) path = GET_OWNERS_PATH params = { email: email, archived: include_archived, limit: limit, after: after }.compact response = Hubspot::Connection.get_json(path, params) response['results'].blank? ? nil : new(response['results'].first) end |
.find_by_emails(emails = [], include_archived: false) ⇒ Object
66 67 68 |
# File 'lib/hubspot/owner.rb', line 66 def find_by_emails(emails = [], include_archived: false) emails.map { |email| find_by_email(email, include_archived: include_archived) }.reject(&:nil?) end |
Instance Method Details
#[](property) ⇒ Object
23 24 25 |
# File 'lib/hubspot/owner.rb', line 23 def [](property) @properties[property] end |