Class: PatientZero::Organization

Inherits:
Object
  • Object
show all
Includes:
Client
Defined in:
lib/patient_zero/organization.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Client

#connection, #get, included, #parse, #post, #put

Constructor Details

#initialize(attributes) ⇒ Organization

Returns a new instance of Organization.



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

def initialize attributes
  @id = attributes.fetch 'id'
  @name = attributes.fetch 'name'
  @avatar = attributes.fetch 'avatar'
end

Instance Attribute Details

#avatarObject

Returns the value of attribute avatar.



4
5
6
# File 'lib/patient_zero/organization.rb', line 4

def avatar
  @avatar
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/patient_zero/organization.rb', line 4

def id
  @id
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/patient_zero/organization.rb', line 4

def name
  @name
end

Class Method Details

.allObject



12
13
14
15
16
17
# File 'lib/patient_zero/organization.rb', line 12

def self.all
  response = get '/mobile/api/v1/organizations', client_token: Authorization.token
  response['organizations'].map do |organization_attributes|
    new organization_attributes
  end
end

Instance Method Details

#sourcesObject



19
20
21
# File 'lib/patient_zero/organization.rb', line 19

def sources
  Source.all token
end

#tokenObject



23
24
25
26
# File 'lib/patient_zero/organization.rb', line 23

def token
  response = get "/mobile/api/v1/organizations/#{id}/switch", client_token: Authorization.token
  response['user_token']
end