Sha256: 4cd949453f56d13b9991ea53709d846014caef0f4912c3f15f9a0f410110979a

Contents?: true

Size: 828 Bytes

Versions: 6

Compression:

Stored size: 828 Bytes

Contents

module Helium
  class Organization < Resource
    attr_reader :name, :timezone

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

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

    def resource_path
      "/organization"
    end

    # TODO refactor into relationships
    def users
      Collection.new(klass: User, client: @client, belongs_to: self)
    end

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

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

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
helium-ruby-0.26.0 lib/helium/organization.rb
helium-ruby-0.25.0 lib/helium/organization.rb
helium-ruby-0.24.0 lib/helium/organization.rb
helium-ruby-0.23.0 lib/helium/organization.rb
helium-ruby-0.22.0 lib/helium/organization.rb
helium-ruby-0.21.0 lib/helium/organization.rb