Class: WhenHub::Client

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

Constant Summary collapse

RESOURCE =
RestClient::Resource.new('https://api.whenhub.com')

Instance Method Summary collapse

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

#meObject



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

#schedulesObject



22
23
24
# File 'lib/whenhub/client.rb', line 22

def schedules
  SchedulesCollection.new(self)
end