baidu-sms 0.0.4 → 0.0.5

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: da1a6b1d4c9c33e89428e12c5416449607ddf211
4
- data.tar.gz: 7892dfcf0a9a73d01998aec21b49002a6568b9e2
3
+ metadata.gz: 9993c6e1521964c0e3013e5b4673ddfd7fdf5b9d
4
+ data.tar.gz: dd537702a9539cf87908cea18f7e1de2cc723a38
5
5
  SHA512:
6
- metadata.gz: 1b4c80345dfe7226bd5adc77cda1529d6310041bf4b9f4da3b4c950bbf7095d83413ef4d1fac2120bdee65dbaeb0ed4297097f0280ef06999e9d0fbebff376d7
7
- data.tar.gz: 3d3f7ba23db2e08ba0a4785fb2e0299b8089afa7037e052174ee66c368768e88e2a32c3d7cbc5e366a202b0ac03271f98dd2d4aa3f2a0cd535292c5d99ec679c
6
+ metadata.gz: 4dd5c3ddf9a376276d3b800885c4cc11a07c550fc2d1987ab01237f2495caa6ef98bf4acf74df843f9816c44af349369c67ae6338c13d3327faf2b36ff8fa858
7
+ data.tar.gz: f772a83557ddbff18040ce3d586122f8365d56e9a63795a7c057e511518940361ca2611e691568f34a934306c18aba114a8bf33064c4d983a850914ca81fe7e2
@@ -1,3 +1,5 @@
1
+ require 'curl'
2
+
1
3
  module BaiduSMS
2
4
  class ReportService
3
5
  include BaiduSMS::Core
@@ -5,6 +7,7 @@ module BaiduSMS
5
7
  REPORT_SERVICE = "ReportService"
6
8
  MESSAGE_PARAM_ORDER = [ :performanceData, :startDate, :endDate, :levelOfDetails, :reportType, :device ]
7
9
  DEFAULT_OPTIONS = { max_retries: 10, retry_timeout: false, current_retry: 0 }
10
+ RETRYABLE_EXCEPTIONS = [HTTPI::Error, Curl::Err::CurlError]
8
11
 
9
12
  attr_reader :max_retries, :retry_timeout, :current_retry
10
13
 
@@ -40,17 +43,20 @@ module BaiduSMS
40
43
  response = @client.call(*args)
41
44
  header = response.header[:res_header]
42
45
  raise BaiduSMSInvalidRequestError.new("#{header[:failures][:code]} - #{header[:failures][:message]}") unless header[:status].to_i == 0
43
- rescue HTTPI::TimeoutError => e
46
+ rescue *RETRYABLE_EXCEPTIONS => e
44
47
  raise e unless retry_timeout && current_retry < max_retries
45
- current_retry += 1
46
- sleep [10 * (2 ** current_retry), 600].min
47
- p "Retry number: #{current_retry}"
48
- response = self.call(args)
48
+ response = retry_call(*args)
49
49
  end
50
50
 
51
51
  response
52
52
  end
53
53
 
54
+ def retry_call(*args)
55
+ current_retry += 1
56
+ p "Retry number: #{current_retry}"
57
+ self.call(*args)
58
+ end
59
+
54
60
  def set_options(options)
55
61
  DEFAULT_OPTIONS.each do |key, value|
56
62
  instance_variable_set("@#{key}", options[key] || value)
@@ -1,3 +1,3 @@
1
1
  module BaiduSMS
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baidu-sms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Borkowski
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - '>='
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: curb
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: debugger
30
44
  requirement: !ruby/object:Gem::Requirement
@@ -54,7 +68,7 @@ files:
54
68
  - lib/baidu-sms/level_of_details.rb
55
69
  - lib/baidu-sms/device.rb
56
70
  - lib/baidu-sms/version.rb
57
- homepage: ''
71
+ homepage: https://github.com/forward3d/baidu-sms
58
72
  licenses:
59
73
  - MIT
60
74
  metadata: {}