Class: CobotClient::ApiClient
- Inherits:
-
Object
- Object
- CobotClient::ApiClient
- Includes:
- UrlHelper
- Defined in:
- lib/cobot_client/api_client.rb
Class Attribute Summary collapse
-
.retry_time ⇒ Object
Returns the value of attribute retry_time.
-
.user_agent ⇒ Object
Returns the value of attribute user_agent.
Instance Method Summary collapse
- #create_booking(subdomain, resource_id, attributes) ⇒ Object
-
#delete(*args) ⇒ Object
args: either a full URL or subdomain, path.
- #delete_booking(subdomain, id) ⇒ Object
-
#get(*args) ⇒ Object
args: either a full URL or subdomain, path, plus an optional params hash.
- #get_resources(subdomain) ⇒ Object
-
#initialize(access_token) ⇒ ApiClient
constructor
A new instance of ApiClient.
-
#post(*args) ⇒ Object
args: either a full URL or subdomain, path, plus a body as hash.
-
#put(*args) ⇒ Object
args: either a full URL or subdomain, path, plus a body as hash.
- #update_booking(subdomain, id, attributes) ⇒ Object
Methods included from UrlHelper
Constructor Details
#initialize(access_token) ⇒ ApiClient
Returns a new instance of ApiClient.
13 14 15 |
# File 'lib/cobot_client/api_client.rb', line 13 def initialize(access_token) @access_token = access_token end |
Class Attribute Details
.retry_time ⇒ Object
Returns the value of attribute retry_time.
9 10 11 |
# File 'lib/cobot_client/api_client.rb', line 9 def retry_time @retry_time end |
.user_agent ⇒ Object
Returns the value of attribute user_agent.
9 10 11 |
# File 'lib/cobot_client/api_client.rb', line 9 def user_agent @user_agent end |
Instance Method Details
#create_booking(subdomain, resource_id, attributes) ⇒ Object
21 22 23 |
# File 'lib/cobot_client/api_client.rb', line 21 def create_booking(subdomain, resource_id, attributes) post subdomain, "/resources/#{resource_id}/bookings", attributes end |
#delete(*args) ⇒ Object
args: either a full URL or subdomain, path
55 56 57 58 59 60 |
# File 'lib/cobot_client/api_client.rb', line 55 def delete(*args) url, subdomain, path, _ = parse_args(*args) rewrap_errors do RestClient.delete(build_url(url || subdomain, path), headers) end end |
#delete_booking(subdomain, id) ⇒ Object
29 30 31 |
# File 'lib/cobot_client/api_client.rb', line 29 def delete_booking(subdomain, id) delete subdomain, "/bookings/#{id}" end |
#get(*args) ⇒ Object
args: either a full URL or subdomain, path, plus an optional params hash
44 45 46 47 48 49 50 51 52 |
# File 'lib/cobot_client/api_client.rb', line 44 def get(*args) url, subdomain, path, params = parse_args(*args) JSON.parse( rewrap_errors do RestClient.get( build_url(url || subdomain, path, params), headers).body end, symbolize_names: true) end |
#get_resources(subdomain) ⇒ Object
17 18 19 |
# File 'lib/cobot_client/api_client.rb', line 17 def get_resources(subdomain) get subdomain, '/resources' end |
#post(*args) ⇒ Object
args: either a full URL or subdomain, path, plus a body as hash
34 35 36 |
# File 'lib/cobot_client/api_client.rb', line 34 def post(*args) request :post, *args end |
#put(*args) ⇒ Object
args: either a full URL or subdomain, path, plus a body as hash
39 40 41 |
# File 'lib/cobot_client/api_client.rb', line 39 def put(*args) request :put, *args end |
#update_booking(subdomain, id, attributes) ⇒ Object
25 26 27 |
# File 'lib/cobot_client/api_client.rb', line 25 def update_booking(subdomain, id, attributes) put subdomain, "/bookings/#{id}", attributes end |