Class: RTrail::Client
- Inherits:
-
Object
- Object
- RTrail::Client
- Defined in:
- lib/rtrail/client.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#get(path) ⇒ Object
Send a GET request to the API and return a Hashie::Mash (for individual object requests) or an Array of Hashie::Mash (for requests returning a list of objects).
-
#initialize(base_url, user, password) ⇒ Client
constructor
A new instance of Client.
-
#post(path, data) ⇒ Object
Send a POST request to the API and return a Hashie::Mash.
Constructor Details
#initialize(base_url, user, password) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 |
# File 'lib/rtrail/client.rb', line 11 def initialize(base_url, user, password) @base_url = base_url @user = user @password = password end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
16 17 18 |
# File 'lib/rtrail/client.rb', line 16 def base_url @base_url end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
16 17 18 |
# File 'lib/rtrail/client.rb', line 16 def password @password end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
16 17 18 |
# File 'lib/rtrail/client.rb', line 16 def user @user end |
Instance Method Details
#get(path) ⇒ Object
Send a GET request to the API and return a Hashie::Mash (for individual object requests) or an Array of Hashie::Mash (for requests returning a list of objects).
25 26 27 |
# File 'lib/rtrail/client.rb', line 25 def get(path) _request(:get, path) end |
#post(path, data) ⇒ Object
Send a POST request to the API and return a Hashie::Mash.
37 38 39 |
# File 'lib/rtrail/client.rb', line 37 def post(path, data) _request(:post, path, data) end |