promoter 0.9.3 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43969ad482fc7bc346366f0b32d80581829550e18a53af2ced62488429dbcf9d
4
- data.tar.gz: 5369949d18a1cbc07378e563211931a9752a6ab89dd098f630542c5e4d0f7306
3
+ metadata.gz: ea27996c893857e6dd98b5e11c280e6f78fcaa1732c098af5047f5c46162f16d
4
+ data.tar.gz: ad6d39654a606515e534637c54977e9e8541fd755bafcca0e587f51738b8d9e9
5
5
  SHA512:
6
- metadata.gz: 46f679a4587e1441f5e8d46d0a7ba1873086b2b23346406bbdf6329b1f2b63ef92070961801d031cccca514b10d12fea1b13004a2d52daa18406a2425b976e0d
7
- data.tar.gz: cd5409b18f5b2d3167448427698983e4b152454a859e25f8bbd63c622d6e5cdf0925275c9e1ced76e1f20d95ed819744eca62d6c3010663f9e29b52b6546dd91
6
+ metadata.gz: d3844da7ec9900ea84248e0b467d760b6f5e1578803ac4ca4d9de5077c72556e0900225c5821c41601b46754331022c3a044fa79dc0b0d825a32ec63bcaf76d9
7
+ data.tar.gz: b15f80e2d7a5421f8cf0cf3e9fa0410a8244674084e97265cb719ce755f3ab72715d7375fc0cfb7ca91e2e63a2d0b5619824af0baa013e7ddc8cdbc922557b6e
@@ -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, :follow_up_url, :url
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
- response = Request.get("#{API_URL}/?#{query_string(attrs)}")
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
@@ -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.post(url, params)
21
+ def self.put(url, params)
17
22
  response_format = params.delete(:response_format) || :json
18
- response = HTTParty.post(url, body: params.to_json, headers: auth_header)
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.delete(url)
23
- response = HTTParty.delete(url, headers: auth_header)
24
- parse_response(response)
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
@@ -1,3 +1,3 @@
1
1
  module Promoter
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: promoter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris O'Sullivan