soapy_cake 1.19.0 → 1.20.0

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
  SHA1:
3
- metadata.gz: 1b885bb4fe2f48d057406017f66cb421de417619
4
- data.tar.gz: c1d0e66a52f0b4acff03760ddcf9f94ef0da7f37
3
+ metadata.gz: b83f34c1746ec07e1eb0eb47ddbb50c9fea4796c
4
+ data.tar.gz: f0dd1db1eaa1ba6550669564ea3a0c6984021a8c
5
5
  SHA512:
6
- metadata.gz: 39f8963dd4d26fc38edec8478ce6b5e17af70d3c62a724fc4eb6814625f0fb5ed386e0e3f30793b64dafc18db6cf42bc4cdf6a7b8767f894f2345ea42cbbf65e
7
- data.tar.gz: 8f2f6de99f031f2b5869ec82cbf02426996ea1047b1f17e6aa309579dba615a894bb3d0e2504e3d8e517cd9fae72559e9ab35b95ccb6f80d9c2ba580a4de9910
6
+ metadata.gz: ce98500805287cef4ed338947ca7f556e707c6143941ba02a9a9b2ce71d1ddd340347d742a69cccb277d4ce2bcf03c6e1c80d7572fe36b82185376710cc6e555
7
+ data.tar.gz: 082ec9d5cd54283ca0857bad5cf246bd43faf03bf27ac4314e8ebf3267b79ae593333668d1b06a9b2cccb2bc6bc6e60c4ed1f729dd512ef2c92585a7a4847365
@@ -2,6 +2,7 @@ require 'logger'
2
2
  require 'nokogiri'
3
3
  require 'saxerator'
4
4
  require 'httparty'
5
+ require 'retryable'
5
6
  require 'active_support/core_ext/hash/reverse_merge'
6
7
  require 'active_support/core_ext/hash/transform_values'
7
8
  require 'active_support/time'
@@ -25,8 +25,10 @@ module SoapyCake
25
25
  request.api_key = api_key
26
26
  request.time_converter = time_converter
27
27
 
28
- response = Response.new(response_body(request), request.short_response?, time_converter)
29
- xml_response? ? response.to_xml : response.to_enum
28
+ Retryable.retryable(tries: 5, on: RateLimitError, sleep: -> (n) { 3**n }) do
29
+ response = Response.new(response_body(request), request.short_response?, time_converter)
30
+ xml_response? ? response.to_xml : response.to_enum
31
+ end
30
32
  end
31
33
 
32
34
  private
@@ -1,4 +1,5 @@
1
1
  module SoapyCake
2
2
  class Error < RuntimeError; end
3
3
  class RequestFailed < Error; end
4
+ class RateLimitError < RequestFailed; end
4
5
  end
@@ -67,6 +67,7 @@ module SoapyCake
67
67
 
68
68
  def error_check_success!
69
69
  return if sax.for_tag(:success).first == 'true'.freeze
70
+ fail RateLimitError if error_message == 'Restricted'.freeze
70
71
  fail RequestFailed, error_message
71
72
  end
72
73
 
@@ -82,7 +83,7 @@ module SoapyCake
82
83
  end
83
84
 
84
85
  def error_message
85
- sax.for_tag(:message).first || sax.for_tag(:Text).first || 'Unknown error'
86
+ @error_message ||= sax.for_tag(:message).first || sax.for_tag(:Text).first || 'Unknown error'
86
87
  end
87
88
  end
88
89
  end
@@ -1,3 +1,3 @@
1
1
  module SoapyCake
2
- VERSION = '1.19.0'.freeze
2
+ VERSION = '1.20.0'.freeze
3
3
  end
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency 'saxerator'
23
23
  spec.add_dependency 'nokogiri'
24
24
  spec.add_dependency 'httparty'
25
+ spec.add_dependency 'retryable'
25
26
 
26
27
  spec.add_development_dependency 'bundler'
27
28
  spec.add_development_dependency 'rake'
@@ -42,7 +42,7 @@ http_interactions:
42
42
  encoding: UTF-8
43
43
  string: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
44
44
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><AffiliatesResponse
45
- xmlns="http://cakemarketing.com/api/5/"><AffiliatesResult><success>false</success><message>Restricted</message><row_count>0</row_count></AffiliatesResult></AffiliatesResponse></soap:Body></soap:Envelope>
46
- http_version:
45
+ xmlns="http://cakemarketing.com/api/5/"><AffiliatesResult><success>false</success><message>Something Broken</message><row_count>0</row_count></AffiliatesResult></AffiliatesResponse></soap:Body></soap:Envelope>
46
+ http_version:
47
47
  recorded_at: Mon, 15 Jun 2015 12:00:00 GMT
48
48
  recorded_with: VCR 2.9.3
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soapy_cake
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.19.0
4
+ version: 1.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ad2games GmbH
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: retryable
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: bundler
71
85
  requirement: !ruby/object:Gem::Requirement