Class: PrefabC::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Client

Returns a new instance of Client.



3
4
5
6
# File 'lib/prefabc/client.rb', line 3

def initialize(path)
  url = "#{PrefabC.scheme_and_authority}#{path}"
  @resource = RestClient::Resource.new(url, '', PrefabC.api_key)
end

Instance Method Details

#getObject



8
9
10
11
# File 'lib/prefabc/client.rb', line 8

def get
  response = @resource.get
  JSON.parse(response.body, symbolize_names: true)
end

#patch(params = {}) ⇒ Object



13
14
15
16
# File 'lib/prefabc/client.rb', line 13

def patch(params = {})
  response = @resource.patch(params)
  JSON.parse(response.body, symbolize_names: true)
end

#post(params = {}) ⇒ Object



18
19
20
21
# File 'lib/prefabc/client.rb', line 18

def post(params = {})
  response = @resource.post(params)
  JSON.parse(response.body, symbolize_names: true)
end