Class: OneSky::Client

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

Overview

Base implemention of an API client based on the one sky api version 2.

http://developer.oneskyapp.com/api/list/v/2

Constant Summary collapse

API_ROOT_URL =

Api version 2

"https://api.oneskyapp.com/2/".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, api_secret) ⇒ Client

Provide the name of the project you created on the OneSky website. Also, the API key and secret shown there.

Raises:

  • (ArgumentError)


16
17
18
19
# File 'lib/one_sky/client.rb', line 16

def initialize(api_key, api_secret)
  raise ArgumentError, "api_key, api_secret cannot be nil." unless [api_key, api_secret].all?
  @api_key, @api_secret = api_key, api_secret
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



13
14
15
# File 'lib/one_sky/client.rb', line 13

def api_key
  @api_key
end

#api_secretObject

Returns the value of attribute api_secret.



13
14
15
# File 'lib/one_sky/client.rb', line 13

def api_secret
  @api_secret
end

Instance Method Details

#get(path, params = {}, options = nil) ⇒ Object



24
25
26
# File 'lib/one_sky/client.rb', line 24

def get(path, params = {}, options = nil)
  fetch_response :get, path, params, options
end

#post(path, params = {}, options = nil) ⇒ Object



28
29
30
# File 'lib/one_sky/client.rb', line 28

def post(path, params = {}, options = nil)
  fetch_response :post, path, params, options
end

#project(name) ⇒ Object

Returns an API proxy for the Project Management API



33
34
35
# File 'lib/one_sky/client.rb', line 33

def project(name)
  Project.new(name, self)
end

#utilityObject

Returns an API proxy for the Utility API



38
39
40
# File 'lib/one_sky/client.rb', line 38

def utility
  Utility.new(self)
end