Class: SemaphoreClient::Api::Org

Inherits:
Object
  • Object
show all
Defined in:
lib/semaphore_client/api/org.rb

Instance Method Summary collapse

Constructor Details

#initialize(http_client) ⇒ Org

Returns a new instance of Org.



4
5
6
# File 'lib/semaphore_client/api/org.rb', line 4

def initialize(http_client)
  @http_client = http_client
end

Instance Method Details

#get(id) ⇒ Object



13
14
15
16
# File 'lib/semaphore_client/api/org.rb', line 13

def get(id)
  get!(id)
rescue SemaphoreClient::Exceptions::RequestFailed
end

#get!(id) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/semaphore_client/api/org.rb', line 30

def get!(id)
  response = @http_client.get([:orgs, id])

  assert_response_status(response, 200)

  content = JSON.parse(response.body)

  SemaphoreClient::Model::Org.load(content)
end

#listObject



8
9
10
11
# File 'lib/semaphore_client/api/org.rb', line 8

def list
  list!
rescue SemaphoreClient::Exceptions::RequestFailed
end

#list!Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/semaphore_client/api/org.rb', line 18

def list!
  response = @http_client.get([:orgs])

  assert_response_status(response, 200)

  content = JSON.parse(response.body)

  content.map do |entity|
    SemaphoreClient::Model::Org.load(entity)
  end
end