Class: CDD::Client
- Inherits:
-
Object
- Object
- CDD::Client
- Defined in:
- lib/cdd/client.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #execute(uri, params = {}) ⇒ Object
-
#initialize(token, options = {}) ⇒ Client
constructor
A new instance of Client.
- #vaults ⇒ Object
- #vaults_url ⇒ Object
Constructor Details
#initialize(token, options = {}) ⇒ Client
Returns a new instance of Client.
9 10 11 12 |
# File 'lib/cdd/client.rb', line 9 def initialize(token, ={}) self.token = token self.url = [:url] || "https://app.collaborativedrug.com" end |
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
6 7 8 |
# File 'lib/cdd/client.rb', line 6 def token @token end |
#url ⇒ Object
Returns the value of attribute url.
7 8 9 |
# File 'lib/cdd/client.rb', line 7 def url @url end |
Instance Method Details
#execute(uri, params = {}) ⇒ Object
24 25 26 27 |
# File 'lib/cdd/client.rb', line 24 def execute(uri, params={}) response = RestClient.get "#{self.url}#{uri}", { :params => params, "X-CDD-Token" => token } JSON.parse(response.to_s) end |
#vaults ⇒ Object
14 15 16 17 18 |
# File 'lib/cdd/client.rb', line 14 def vaults @vaults ||= execute(vaults_url).collect do |hash| CDD::Vault.new(self,hash) end end |
#vaults_url ⇒ Object
20 21 22 |
# File 'lib/cdd/client.rb', line 20 def vaults_url "/api/v1/vaults" end |