promoter 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/promoter/contact.rb +2 -2
- data/lib/promoter/errors.rb +3 -3
- data/lib/promoter/request.rb +8 -7
- data/lib/promoter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43969ad482fc7bc346366f0b32d80581829550e18a53af2ced62488429dbcf9d
|
4
|
+
data.tar.gz: 5369949d18a1cbc07378e563211931a9752a6ab89dd098f630542c5e4d0f7306
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46f679a4587e1441f5e8d46d0a7ba1873086b2b23346406bbdf6329b1f2b63ef92070961801d031cccca514b10d12fea1b13004a2d52daa18406a2425b976e0d
|
7
|
+
data.tar.gz: cd5409b18f5b2d3167448427698983e4b152454a859e25f8bbd63c622d6e5cdf0925275c9e1ced76e1f20d95ed819744eca62d6c3010663f9e29b52b6546dd91
|
data/lib/promoter/contact.rb
CHANGED
@@ -89,13 +89,13 @@ module Promoter
|
|
89
89
|
contact_attributes = if Promoter.api_version == 2
|
90
90
|
api_url = "https://app.promoter.io/api/v2"
|
91
91
|
contact_params = {
|
92
|
-
attributes: params[:attributes],
|
92
|
+
attributes: params[:attributes] || {},
|
93
93
|
email: params[:email],
|
94
94
|
first_name: params[:first_name],
|
95
95
|
last_name: params[:last_name]
|
96
96
|
}
|
97
97
|
survey_params = {
|
98
|
-
attributes: params[:survey_attributes],
|
98
|
+
attributes: params[:survey_attributes] || {},
|
99
99
|
campaign_id: params[:campaign_id],
|
100
100
|
contact: contact_params,
|
101
101
|
}
|
data/lib/promoter/errors.rb
CHANGED
@@ -24,10 +24,10 @@ module Promoter
|
|
24
24
|
# 429 Too Many Requests – You’re requesting too much! Slown down!
|
25
25
|
# 500 Internal Server Error – We had a problem with our server. Try again later.
|
26
26
|
# 503 Service Unavailable – We’re temporarially offline for maintanance. Please try again later.
|
27
|
-
def check_for_error(status_code)
|
27
|
+
def check_for_error(status_code, response_body)
|
28
28
|
case status_code.to_i
|
29
29
|
when 400
|
30
|
-
raise BadRequest.new(
|
30
|
+
raise BadRequest.new(response_body)
|
31
31
|
when 401
|
32
32
|
raise Unauthorized.new("Your API key is incorrect or invalid")
|
33
33
|
when 403
|
@@ -49,4 +49,4 @@ module Promoter
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
52
|
-
end
|
52
|
+
end
|
data/lib/promoter/request.rb
CHANGED
@@ -28,12 +28,13 @@ module Promoter
|
|
28
28
|
|
29
29
|
def self.parse_response(response, response_format=:json)
|
30
30
|
display_debug(response.body)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
response_body = begin
|
32
|
+
JSON.parse(response.body.to_s)
|
33
|
+
rescue
|
34
|
+
response.body.to_s
|
35
|
+
end
|
36
|
+
check_for_error(response.response.code, response_body)
|
37
|
+
response_body
|
37
38
|
end
|
38
39
|
|
39
40
|
def self.display_debug(response)
|
@@ -54,4 +55,4 @@ module Promoter
|
|
54
55
|
|
55
56
|
end
|
56
57
|
|
57
|
-
end
|
58
|
+
end
|
data/lib/promoter/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: promoter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris O'Sullivan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|