Class: G5FoundationClient::Client

Inherits:
Object
  • Object
show all
Extended by:
FindableByUid
Defined in:
lib/g5_foundation_client/models/client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from FindableByUid

find_by_uid

Constructor Details

#initialize(attrs) ⇒ Client

Returns a new instance of Client.



5
6
7
# File 'lib/g5_foundation_client/models/client.rb', line 5

def initialize(attrs)
  self.client_hash = ActiveSupport::HashWithIndifferentAccess.new attrs.fetch(:client, attrs)
end

Instance Attribute Details

#client_hashObject

Returns the value of attribute client_hash.



3
4
5
# File 'lib/g5_foundation_client/models/client.rb', line 3

def client_hash
  @client_hash
end

Class Method Details

.all_client_uids(clients_uri) ⇒ Object



10
11
12
13
14
15
# File 'lib/g5_foundation_client/models/client.rb', line 10

def all_client_uids(clients_uri)
  G5FoundationClient::Fetcher.fetch_url(clients_uri) do |json|
    hash = ActiveSupport::HashWithIndifferentAccess.new(JSON.parse(json))
    hash[:clients].collect { |client| client[:uid] }
  end
end

Instance Method Details

#locationsObject



23
24
25
# File 'lib/g5_foundation_client/models/client.rb', line 23

def locations
  @locations ||= self.client_hash[:locations].collect { |lh| G5FoundationClient::Location.new(lh.merge(client: self)) }
end