Class: CobotClient::ApiClient

Inherits:
Object
  • Object
show all
Includes:
UrlHelper
Defined in:
lib/cobot_client/api_client.rb

Class Attribute Summary collapse

Instance Method Summary collapse

Methods included from UrlHelper

#cobot_url, site, site=

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_timeObject

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_agentObject

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