Class: Promoter::Metric

Inherits:
Object
  • Object
show all
Defined in:
lib/promoter/metric.rb

Constant Summary collapse

API_URL =
"https://app.promoter.io/api/metrics"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ Metric

Returns a new instance of Metric.



9
10
11
12
13
# File 'lib/promoter/metric.rb', line 9

def initialize(attrs)
  @campaign_name = attrs["campaign_name"]
  @nps = attrs["nps"].to_f
  @organization_nps = attrs["organization_nps"].to_f
end

Instance Attribute Details

#campaign_nameObject

Returns the value of attribute campaign_name.



5
6
7
# File 'lib/promoter/metric.rb', line 5

def campaign_name
  @campaign_name
end

#npsObject

Returns the value of attribute nps.



5
6
7
# File 'lib/promoter/metric.rb', line 5

def nps
  @nps
end

#organization_npsObject

Returns the value of attribute organization_nps.



5
6
7
# File 'lib/promoter/metric.rb', line 5

def organization_nps
  @organization_nps
end

Class Method Details

.all(options = {}) ⇒ Object



15
16
17
18
19
# File 'lib/promoter/metric.rb', line 15

def self.all(options={})
  query_string = URI.encode_www_form(options)
  response = Request.get("#{API_URL}/?#{query_string}")
  response['results'].map {|attrs| new(attrs)}
end