Class: Quanto::Client

Inherits:
Object
  • Object
show all
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

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, options = {})
  @consumer =
    OAuth2::Client.new(consumer_key, consumer_secret, site: QUANTO_URL )

  @token = options[: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.

Returns:

  • (Boolean)


18
19
20
# File 'lib/quanto/client.rb', line 18

def authorized?
  !@token.nil?
end

#connected?Boolean

Returns:

  • (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