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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b7e2c0354a1131bd25443d9e99ad8d87ddfee677b058def12bf8c7c105b296b
4
- data.tar.gz: dce5471e6325bad206a0db864f84172f7d20392b8af25b6fe3ee8c0780ced310
3
+ metadata.gz: 43969ad482fc7bc346366f0b32d80581829550e18a53af2ced62488429dbcf9d
4
+ data.tar.gz: 5369949d18a1cbc07378e563211931a9752a6ab89dd098f630542c5e4d0f7306
5
5
  SHA512:
6
- metadata.gz: 7dac49fe1a74a633fb39d91083cbd6d9ad08e171e05ae3c3133a6057de76a6b7e04a42c57ae6c8818a83b048e7f81f8ad62f48137a00647a30e834ac8fca71f8
7
- data.tar.gz: 6a5b6716ca5b558f4ef524a4c69cba077c6563ecd60843d39fc3454858825e70a733fd3f6e5fc42ad4ef3ab37ad957bd3f33dff775782bc4681774a4269b1184
6
+ metadata.gz: 46f679a4587e1441f5e8d46d0a7ba1873086b2b23346406bbdf6329b1f2b63ef92070961801d031cccca514b10d12fea1b13004a2d52daa18406a2425b976e0d
7
+ data.tar.gz: cd5409b18f5b2d3167448427698983e4b152454a859e25f8bbd63c622d6e5cdf0925275c9e1ced76e1f20d95ed819744eca62d6c3010663f9e29b52b6546dd91
@@ -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
  }
@@ -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("Something is wrong with your request")
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
@@ -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
- check_for_error(response.response.code)
32
- if response_format == :json
33
- JSON.parse(response.body.to_s)
34
- else
35
- response.body.to_s
36
- end
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
@@ -1,3 +1,3 @@
1
1
  module Promoter
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.3"
3
3
  end
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.2
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-03 00:00:00.000000000 Z
11
+ date: 2019-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler