Class: Hapyrus::ApiClient

Inherits:
Object
  • Object
show all
Defined in:
lib/hapyrus/api_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(credentials = nil) ⇒ ApiClient

Returns a new instance of ApiClient.



10
11
12
# File 'lib/hapyrus/api_client.rb', line 10

def initialize(credentials=nil)
  @credentials = credentials || Hapyrus::Credentials.new
end

Instance Attribute Details

#credentialsObject

Returns the value of attribute credentials.



8
9
10
# File 'lib/hapyrus/api_client.rb', line 8

def credentials
  @credentials
end

#responseObject (readonly)

Returns the value of attribute response.



7
8
9
# File 'lib/hapyrus/api_client.rb', line 7

def response
  @response
end

Instance Method Details

#get(path) ⇒ Object



18
19
20
21
22
# File 'lib/hapyrus/api_client.rb', line 18

def get(path)
  uri = "http://#{HAPYRUS_API_HOST}#{path}"
  resource = RestClient::Resource.new(uri, resource_opts)
  @response = resource.get(:accept => :json)
end

#post(path, params = nil) ⇒ Object



13
14
15
16
17
# File 'lib/hapyrus/api_client.rb', line 13

def post(path, params=nil)
  uri = "http://#{HAPYRUS_API_HOST}#{path}"
  resource = RestClient::Resource.new(uri, resource_opts)
  @response = resource.post(params)
end