Class: Helium::Organization

Inherits:
Resource show all
Defined in:
lib/helium/organization.rb

Instance Attribute Summary collapse

Attributes inherited from Resource

#id, #params, #type

Instance Method Summary collapse

Methods inherited from Resource

#==, all, all_path, create, #created_at, #destroy, #eql?, find, #hash, #to_json, #update, #updated_at

Methods included from Utils

#datetime_to_iso, #kebab_case

Constructor Details

#initialize(opts = {}) ⇒ Organization

Returns a new instance of Organization.



5
6
7
8
9
10
# File 'lib/helium/organization.rb', line 5

def initialize(opts = {})
  super(opts)

  @name     = @params.dig('attributes', 'name')
  @timezone = @params.dig('attributes', 'timezone')
end

Instance Attribute Details

#name ⇒ Object (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/helium/organization.rb', line 3

def name
  @name
end

#timezone ⇒ Object (readonly)

Returns the value of attribute timezone.



3
4
5
# File 'lib/helium/organization.rb', line 3

def timezone
  @timezone
end

Instance Method Details

#as_json ⇒ Object



33
34
35
36
37
38
# File 'lib/helium/organization.rb', line 33

def as_json
  super.merge({
    name: name,
    timezone: timezone
  })
end

#elements ⇒ Object



25
26
27
# File 'lib/helium/organization.rb', line 25

def elements
  @client.organization_elements
end

#labels ⇒ Object



21
22
23
# File 'lib/helium/organization.rb', line 21

def labels
  @client.organization_labels
end

#resource_path ⇒ Object



12
13
14
# File 'lib/helium/organization.rb', line 12

def resource_path
  "/organization"
end

#sensors ⇒ Object



29
30
31
# File 'lib/helium/organization.rb', line 29

def sensors
  @client.organization_sensors
end

#users ⇒ Object

TODO refactor into relationships



17
18
19
# File 'lib/helium/organization.rb', line 17

def users
  @client.organization_users
end