Class: Board::Client::API

Inherits:
Object
  • Object
show all
Defined in:
lib/board/client/api.rb

Direct Known Subclasses

Candidates, Organizations, UserOrganizations, Users

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ API

Returns a new instance of API.



4
5
6
# File 'lib/board/client/api.rb', line 4

def initialize(client)
  @client = client
end

Instance Method Details

#get(path, attributes = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/board/client/api.rb', line 18

def get(path, attributes = {})
  json = @client.get(path, attributes)

  if json.is_a?(Array)
    json.map { |item| Hashie::Mash.new(item) }
  else
    Hashie::Mash.new(json)
  end
end

#post(path, attributes = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/board/client/api.rb', line 8

def post(path, attributes = {})
  json = @client.post(path, attributes)

  if json.is_a?(Hash)
    Hashie::Mash.new(json)
  else
    json
  end
end