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, initialize_from_path, #metadata, resource_name, #resource_name, singleton, #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

#nameObject (readonly)

Returns the value of attribute name



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

def name
  @name
end

#timezoneObject (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_jsonObject



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

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

#elementsObject



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

def elements
  Collection.new(klass: Element, client: @client, belongs_to: self)
end

#labelsObject



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

def labels
  Collection.new(klass: Label, client: @client, belongs_to: self)
end

#resource_pathObject



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

def resource_path
  "/organization"
end

#sensorsObject



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

def sensors
  Collection.new(klass: Sensor, client: @client, belongs_to: self)
end

#usersObject

TODO refactor into relationships



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

def users
  Collection.new(klass: User, client: @client, belongs_to: self)
end