promoter 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/promoter/feedback.rb +25 -5
- data/lib/promoter/request.rb +11 -5
- data/lib/promoter/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea27996c893857e6dd98b5e11c280e6f78fcaa1732c098af5047f5c46162f16d
|
4
|
+
data.tar.gz: ad6d39654a606515e534637c54977e9e8541fd755bafcca0e587f51738b8d9e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3844da7ec9900ea84248e0b467d760b6f5e1578803ac4ca4d9de5077c72556e0900225c5821c41601b46754331022c3a044fa79dc0b0d825a32ec63bcaf76d9
|
7
|
+
data.tar.gz: b15f80e2d7a5421f8cf0cf3e9fa0410a8244674084e97265cb719ce755f3ab72715d7375fc0cfb7ca91e2e63a2d0b5619824af0baa013e7ddc8cdbc922557b6e
|
data/lib/promoter/feedback.rb
CHANGED
@@ -2,19 +2,24 @@ module Promoter
|
|
2
2
|
|
3
3
|
class Feedback
|
4
4
|
|
5
|
-
attr_reader :id, :contact, :score, :score_type, :posted_date, :comment,
|
5
|
+
attr_reader :id, :contact, :score, :score_type, :posted_date, :comment,
|
6
|
+
:follow_up_url, :url, :comment_updated_date, :status
|
6
7
|
|
7
8
|
API_URL = "https://app.promoter.io/api/feedback"
|
8
9
|
|
9
10
|
def initialize(attrs)
|
10
11
|
@id = attrs["id"]
|
11
|
-
@contact = Contact.new(attrs["contact"])
|
12
|
+
@contact = Contact.new(attrs["contact"]) if attrs["contact"]
|
12
13
|
@score = attrs["score"]
|
13
14
|
@score_type = attrs["score_type"]
|
14
|
-
@posted_date = Time.parse(attrs["posted_date"])
|
15
|
+
@posted_date = Time.parse(attrs["posted_date"]) if attrs["posted_date"]
|
16
|
+
if attrs["comment_updated_date"]
|
17
|
+
@comment_updated_date = Time.parse(attrs["comment_updated_date"])
|
18
|
+
end
|
15
19
|
@comment = attrs["comment"]
|
16
20
|
@follow_up_url = attrs["followup_href"]
|
17
21
|
@follow_up_href = attrs["href"]
|
22
|
+
@status = attrs["status"]
|
18
23
|
end
|
19
24
|
|
20
25
|
# Parameter Required Description
|
@@ -31,7 +36,13 @@ module Promoter
|
|
31
36
|
# NOTE: This url parameter does not require quotes around the value.
|
32
37
|
# e.g. (<api-url>?survey__campaign__status=ACTIVE)
|
33
38
|
def self.all(attrs={})
|
34
|
-
|
39
|
+
api_url = if Promoter.api_version == 1
|
40
|
+
API_URL
|
41
|
+
else
|
42
|
+
"https://app.promoter.io/api/v2/feedback"
|
43
|
+
end
|
44
|
+
|
45
|
+
response = Request.get("#{api_url}/?#{query_string(attrs)}")
|
35
46
|
response['results'].map {|attrs| new(attrs)}
|
36
47
|
end
|
37
48
|
|
@@ -40,6 +51,15 @@ module Promoter
|
|
40
51
|
new(response)
|
41
52
|
end
|
42
53
|
|
54
|
+
def close
|
55
|
+
if Promoter.api_version == 1
|
56
|
+
raise "This method is only available in API v2 onwards"
|
57
|
+
end
|
58
|
+
|
59
|
+
api_url = "https://app.promoter.io/api/v2/feedback"
|
60
|
+
Request.put("#{api_url}/#{id}/", { status: "CLOSED" })
|
61
|
+
end
|
62
|
+
|
43
63
|
private
|
44
64
|
|
45
65
|
def self.query_string(attrs)
|
@@ -47,4 +67,4 @@ module Promoter
|
|
47
67
|
end
|
48
68
|
|
49
69
|
end
|
50
|
-
end
|
70
|
+
end
|
data/lib/promoter/request.rb
CHANGED
@@ -8,20 +8,26 @@ module Promoter
|
|
8
8
|
include HTTParty
|
9
9
|
extend Errors
|
10
10
|
|
11
|
+
def self.delete(url)
|
12
|
+
response = HTTParty.delete(url, headers: auth_header)
|
13
|
+
parse_response(response)
|
14
|
+
end
|
15
|
+
|
11
16
|
def self.get(url)
|
12
17
|
response = HTTParty.get(url, headers: auth_header)
|
13
18
|
parse_response(response)
|
14
19
|
end
|
15
20
|
|
16
|
-
def self.
|
21
|
+
def self.put(url, params)
|
17
22
|
response_format = params.delete(:response_format) || :json
|
18
|
-
response = HTTParty.
|
23
|
+
response = HTTParty.put(url, body: params.to_json, headers: auth_header)
|
19
24
|
parse_response(response, response_format)
|
20
25
|
end
|
21
26
|
|
22
|
-
def self.
|
23
|
-
|
24
|
-
|
27
|
+
def self.post(url, params)
|
28
|
+
response_format = params.delete(:response_format) || :json
|
29
|
+
response = HTTParty.post(url, body: params.to_json, headers: auth_header)
|
30
|
+
parse_response(response, response_format)
|
25
31
|
end
|
26
32
|
|
27
33
|
private
|
data/lib/promoter/version.rb
CHANGED