Class: Quanto::Client
- Inherits:
-
Object
- Object
- Quanto::Client
- Defined in:
- lib/quanto/client.rb,
lib/quanto/metrics.rb
Constant Summary collapse
- API_VERSION =
"1"- QUANTO_URL =
"http://quanto.herokuapp.com"
Instance Method Summary collapse
-
#authorized? ⇒ Boolean
Returns true if the user is authorized to make requests to quanto This means that the application has acquired a valid access token and access token secret.
- #connected? ⇒ Boolean
-
#initialize(consumer_key, consumer_secret, options = {}) ⇒ Client
constructor
A new instance of Client.
- #record_metric(value, type, opts = {}) ⇒ Object
Constructor Details
#initialize(consumer_key, consumer_secret, options = {}) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 |
# File 'lib/quanto/client.rb', line 9 def initialize(consumer_key, consumer_secret, = {}) @consumer = OAuth2::Client.new(consumer_key, consumer_secret, site: QUANTO_URL ) @token = [:access_token] end |
Instance Method Details
#authorized? ⇒ Boolean
Returns true if the user is authorized to make requests to quanto This means that the application has acquired a valid access token and access token secret.
18 19 20 |
# File 'lib/quanto/client.rb', line 18 def !@token.nil? end |
#connected? ⇒ Boolean
22 23 24 |
# File 'lib/quanto/client.rb', line 22 def connected? !@access_token.nil? end |
#record_metric(value, type, opts = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/quanto/metrics.rb', line 5 def record_metric(value, type, opts={}) metric = { metric_type: type, value: value, date: opts[:date] || Date.today.to_s } post('/metrics', metric: metric) end |