Class: Vertpig::Client
- Inherits:
-
Object
- Object
- Vertpig::Client
- Defined in:
- lib/vertpig/client.rb
Constant Summary collapse
- HOST =
'https://www.vertpig.com/api/v1.1'
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#secret ⇒ Object
readonly
Returns the value of attribute secret.
Instance Method Summary collapse
- #get(path, params = {}, headers = {}) ⇒ Object
-
#initialize(attrs = {}) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(attrs = {}) ⇒ Client
Returns a new instance of Client.
11 12 13 14 |
# File 'lib/vertpig/client.rb', line 11 def initialize(attrs = {}) @key = attrs[:key] @secret = attrs[:secret] end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
9 10 11 |
# File 'lib/vertpig/client.rb', line 9 def key @key end |
#secret ⇒ Object (readonly)
Returns the value of attribute secret.
9 10 11 |
# File 'lib/vertpig/client.rb', line 9 def secret @secret end |
Instance Method Details
#get(path, params = {}, headers = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vertpig/client.rb', line 16 def get(path, params = {}, headers = {}) nonce = Time.now.to_i response = connection.get do |req| url = "#{HOST}/#{path}" req.params.merge!(params) req.url(url) if key req.params[:apikey] = key req.params[:nonce] = nonce req.headers[:apisign] = signature( connection.build_exclusive_url(req.path, req.params), nonce) end end JSON.parse(response.body)['result'] end |