Class: Hapyrus::ApiClient
- Inherits:
-
Object
- Object
- Hapyrus::ApiClient
- Defined in:
- lib/hapyrus/api_client.rb
Instance Attribute Summary collapse
-
#credentials ⇒ Object
Returns the value of attribute credentials.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #get(path) ⇒ Object
-
#initialize(credentials = nil) ⇒ ApiClient
constructor
A new instance of ApiClient.
- #post(path, params = nil) ⇒ Object
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
#credentials ⇒ Object
Returns the value of attribute credentials.
8 9 10 |
# File 'lib/hapyrus/api_client.rb', line 8 def credentials @credentials end |
#response ⇒ Object (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 |