Class: Promoter::Feedback

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

Constant Summary collapse

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#commentObject (readonly)

Returns the value of attribute comment.



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

def comment
  @comment
end

#comment_updated_dateObject (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

#contactObject (readonly)

Returns the value of attribute contact.



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

def contact
  @contact
end

#follow_up_urlObject (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

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#posted_dateObject (readonly)

Returns the value of attribute posted_date.



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

def posted_date
  @posted_date
end

#scoreObject (readonly)

Returns the value of attribute score.



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

def score
  @score
end

#score_createdObject (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_modifiedObject (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_typeObject (readonly)

Returns the value of attribute score_type.



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

def score_type
  @score_type
end

#statusObject (readonly)

Returns the value of attribute status.



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

def status
  @status
end

#urlObject (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

.find(id) ⇒ Object



58
59
60
61
# File 'lib/promoter/feedback.rb', line 58

def self.find(id)
  response = Request.get("#{API_URL}/#{id}")
  new(response)
end

Instance Method Details

#closeObject



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