Class: Hubspot::Owner

Inherits:
Object
  • Object
show all
Defined in:
lib/hubspot/owner.rb

Overview

HubSpot Owners API

http://developers.hubspot.com/docs/methods/owners/get_owners

TODO: Create an Owner TODO: Update an Owner TODO: Delete an Owner

Constant Summary collapse

GET_OWNER_PATH =

GET

'/owners/v2/owners/:owner_id'
GET_OWNERS_PATH =

GET

'/owners/v2/owners'
CREATE_OWNER_PATH =

POST

'/owners/v2/owners'
UPDATE_OWNER_PATH =

PUT

'/owners/v2/owners/:owner_id'
DELETE_OWNER_PATH =

DELETE

'/owners/v2/owners/:owner_id'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(property_hash) ⇒ Owner

Returns a new instance of Owner.



20
21
22
23
24
# File 'lib/hubspot/owner.rb', line 20

def initialize(property_hash)
  @properties = property_hash
  @owner_id   = @properties['ownerId']
  @email      = @properties['email']
end

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



18
19
20
# File 'lib/hubspot/owner.rb', line 18

def email
  @email
end

#owner_idObject (readonly)

Returns the value of attribute owner_id.



18
19
20
# File 'lib/hubspot/owner.rb', line 18

def owner_id
  @owner_id
end

#propertiesObject (readonly)

Returns the value of attribute properties.



18
19
20
# File 'lib/hubspot/owner.rb', line 18

def properties
  @properties
end

Class Method Details

.all(include_inactive = false) ⇒ Object



31
32
33
34
35
36
# File 'lib/hubspot/owner.rb', line 31

def all(include_inactive=false)
  path     = GET_OWNERS_PATH
  params   = { includeInactive: include_inactive }
  response = Hubspot::Connection.get_json(path, params)
  response.map { |r| new(r) }
end

.find(id, include_inactive = false) ⇒ Object



38
39
40
41
42
# File 'lib/hubspot/owner.rb', line 38

def find(id, include_inactive=false)
  response = Hubspot::Connection.get_json(GET_OWNER_PATH, owner_id: id,
    include_inactive: include_inactive)
  new(response)
end

.find_by_email(email, include_inactive = false) ⇒ Object



44
45
46
47
48
49
# File 'lib/hubspot/owner.rb', line 44

def find_by_email(email, include_inactive=false)
  path     = GET_OWNERS_PATH
  params   = { email: email, includeInactive: include_inactive }
  response = Hubspot::Connection.get_json(path, params)
  response.blank? ? nil : new(response.first)
end

.find_by_emails(emails, include_inactive = false) ⇒ Object



51
52
53
# File 'lib/hubspot/owner.rb', line 51

def find_by_emails(emails, include_inactive=false)
  emails.map { |email| find_by_email(email, include_inactive) }.reject(&:blank?)
end

Instance Method Details

#[](property) ⇒ Object



26
27
28
# File 'lib/hubspot/owner.rb', line 26

def [](property)
  @properties[property]
end