Class: Promoter::Feedback
- Inherits:
-
Object
- Object
- Promoter::Feedback
- Defined in:
- lib/promoter/feedback.rb
Constant Summary collapse
- API_URL =
"https://app.promoter.io/api/feedback"
Instance Attribute Summary collapse
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#comment_updated_date ⇒ Object
readonly
Returns the value of attribute comment_updated_date.
-
#contact ⇒ Object
readonly
Returns the value of attribute contact.
-
#follow_up_url ⇒ Object
readonly
Returns the value of attribute follow_up_url.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#posted_date ⇒ Object
readonly
Returns the value of attribute posted_date.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
-
#score_created ⇒ Object
readonly
Returns the value of attribute score_created.
-
#score_modified ⇒ Object
readonly
Returns the value of attribute score_modified.
-
#score_type ⇒ Object
readonly
Returns the value of attribute score_type.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
-
.all(attrs = {}) ⇒ Object
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.
- .find(id) ⇒ Object
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(attrs) ⇒ Feedback
constructor
A new instance of Feedback.
Constructor Details
#initialize(attrs) ⇒ Feedback
Returns a new instance of Feedback.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# 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 |
Instance Attribute Details
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
5 6 7 |
# File 'lib/promoter/feedback.rb', line 5 def comment @comment end |
#comment_updated_date ⇒ Object (readonly)
Returns the value of attribute comment_updated_date.
5 6 7 |
# File 'lib/promoter/feedback.rb', line 5 def comment_updated_date @comment_updated_date end |
#contact ⇒ Object (readonly)
Returns the value of attribute contact.
5 6 7 |
# File 'lib/promoter/feedback.rb', line 5 def contact @contact end |
#follow_up_url ⇒ Object (readonly)
Returns the value of attribute follow_up_url.
5 6 7 |
# File 'lib/promoter/feedback.rb', line 5 def follow_up_url @follow_up_url end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/promoter/feedback.rb', line 5 def id @id end |
#posted_date ⇒ Object (readonly)
Returns the value of attribute posted_date.
5 6 7 |
# File 'lib/promoter/feedback.rb', line 5 def posted_date @posted_date end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
5 6 7 |
# File 'lib/promoter/feedback.rb', line 5 def score @score end |
#score_created ⇒ Object (readonly)
Returns the value of attribute score_created.
5 6 7 |
# File 'lib/promoter/feedback.rb', line 5 def score_created @score_created end |
#score_modified ⇒ Object (readonly)
Returns the value of attribute score_modified.
5 6 7 |
# File 'lib/promoter/feedback.rb', line 5 def score_modified @score_modified end |
#score_type ⇒ Object (readonly)
Returns the value of attribute score_type.
5 6 7 |
# File 'lib/promoter/feedback.rb', line 5 def score_type @score_type end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/promoter/feedback.rb', line 5 def status @status end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/promoter/feedback.rb', line 5 def url @url end |
Class Method Details
.all(attrs = {}) ⇒ Object
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)
47 48 49 50 51 52 53 54 55 56 |
# 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 |
Instance Method Details
#close ⇒ Object
63 64 65 66 67 68 69 70 |
# 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 |