Class: WhenHub::Client
- Inherits:
-
Object
- Object
- WhenHub::Client
- Defined in:
- lib/whenhub/client.rb
Constant Summary collapse
- RESOURCE =
RestClient::Resource.new('https://api.whenhub.com')
Instance Method Summary collapse
- #delete(path) ⇒ Object
- #get(path, params = {}) ⇒ Object
-
#initialize(access_token:) ⇒ Client
constructor
A new instance of Client.
- #me ⇒ Object
- #post(path, params = {}) ⇒ Object
- #schedules ⇒ Object
Constructor Details
#initialize(access_token:) ⇒ Client
Returns a new instance of Client.
14 15 16 |
# File 'lib/whenhub/client.rb', line 14 def initialize(access_token:) @access_token = access_token end |
Instance Method Details
#delete(path) ⇒ Object
34 35 36 |
# File 'lib/whenhub/client.rb', line 34 def delete(path) JSON.parse(nested_resource(path).delete) end |
#get(path, params = {}) ⇒ Object
26 27 28 |
# File 'lib/whenhub/client.rb', line 26 def get(path, params={}) JSON.parse(nested_resource(path).get(params: params)) end |
#me ⇒ Object
18 19 20 |
# File 'lib/whenhub/client.rb', line 18 def me User.build(self, get('/api/users/me')) end |
#post(path, params = {}) ⇒ Object
30 31 32 |
# File 'lib/whenhub/client.rb', line 30 def post(path, params={}) JSON.parse(nested_resource(path).post(params)) end |
#schedules ⇒ Object
22 23 24 |
# File 'lib/whenhub/client.rb', line 22 def schedules SchedulesCollection.new(self) end |