class Promoter::Feedback
Constants
- API_URL
Attributes
comment[R]
comment_updated_date[R]
contact[R]
follow_up_url[R]
id[R]
posted_date[R]
score[R]
score_created[R]
score_modified[R]
score_type[R]
status[R]
url[R]
Public Class Methods
all(attrs={})
click to toggle source
Parameter Required Description score false Filtering by score can be achieved with
a range 0-10
score_type
false Filtering by score type can be achieved
with a list of values promoter, detractor, passive
survey__campaign false Filtering by campaign can be achieved
by the given id of your campaign id
survey__campaign__status false Filtering by campaign status can be
achieved by providing one of the campaign status values: ACTIVE, COMPLETE.
NOTE: This url parameter does not require quotes around the value. e.g. (<api-url>?survey__campaign__status=ACTIVE)
# File lib/promoter/feedback.rb, line 47 def self.all(attrs={}) api_url = if Promoter.api_version == 1 API_URL else "https://app.promoter.io/api/v2/feedback" end response = Request.get("#{api_url}/?#{query_string(attrs)}") response['results'].map {|attrs| new(attrs)} end
find(id)
click to toggle source
# File lib/promoter/feedback.rb, line 58 def self.find(id) response = Request.get("#{API_URL}/#{id}") new(response) end
new(attrs)
click to toggle source
# File lib/promoter/feedback.rb, line 11 def initialize(attrs) @id = attrs["id"] @contact = Contact.new(attrs["contact"]) if attrs["contact"] @score = attrs["score"] @score_type = attrs["score_type"] @posted_date = Time.parse(attrs["posted_date"]) if attrs["posted_date"] if attrs["comment_updated_date"] @comment_updated_date = Time.parse(attrs["comment_updated_date"]) end @comment = attrs["comment"] @follow_up_url = attrs["followup_href"] @follow_up_href = attrs["href"] @status = attrs["status"] if attrs["score_created"] @score_created = Time.parse(attrs["score_created"]) end if attrs["score_modified"] @score_modified = Time.parse(attrs["score_modified"]) end end
Private Class Methods
query_string(attrs)
click to toggle source
# File lib/promoter/feedback.rb, line 74 def self.query_string(attrs) URI.encode_www_form(attrs) end
Public Instance Methods
close()
click to toggle source
# File lib/promoter/feedback.rb, line 63 def close if Promoter.api_version == 1 raise "This method is only available in API v2 onwards" end api_url = "https://app.promoter.io/api/v2/feedback" Request.put("#{api_url}/#{id}/", { status: "CLOSED" }) end