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
-
#delete(*args) ⇒ Object
args: either a full URL or subdomain, path.
-
#get(*args) ⇒ Object
args: either a full URL or subdomain, path, plus an optional params hash.
-
#initialize(access_token) ⇒ ApiClient
constructor
A new instance of ApiClient.
- #patch(*args) ⇒ Object
-
#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.
Methods included from UrlHelper
Constructor Details
#initialize(access_token) ⇒ ApiClient
Returns a new instance of ApiClient.
15 16 17 |
# File 'lib/cobot_client/api_client.rb', line 15 def initialize(access_token) @access_token = access_token end |
Class Attribute Details
.retry_time ⇒ Object
Returns the value of attribute retry_time.
11 12 13 |
# File 'lib/cobot_client/api_client.rb', line 11 def retry_time @retry_time end |
.user_agent ⇒ Object
Returns the value of attribute user_agent.
11 12 13 |
# File 'lib/cobot_client/api_client.rb', line 11 def user_agent @user_agent end |
Instance Method Details
#delete(*args) ⇒ Object
args: either a full URL or subdomain, path
47 48 49 50 51 52 |
# File 'lib/cobot_client/api_client.rb', line 47 def delete(*args) url, subdomain, path, = parse_args(*args) rewrap_errors do RestClient.delete(build_url(url || subdomain, path), headers) end end |
#get(*args) ⇒ Object
args: either a full URL or subdomain, path, plus an optional params hash
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cobot_client/api_client.rb', line 34 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 |
#patch(*args) ⇒ Object
29 30 31 |
# File 'lib/cobot_client/api_client.rb', line 29 def patch(*args) request :patch, *args end |
#post(*args) ⇒ Object
args: either a full URL or subdomain, path, plus a body as hash
20 21 22 |
# File 'lib/cobot_client/api_client.rb', line 20 def post(*args) request :post, *args end |
#put(*args) ⇒ Object
args: either a full URL or subdomain, path, plus a body as hash
25 26 27 |
# File 'lib/cobot_client/api_client.rb', line 25 def put(*args) request :put, *args end |