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 +4 -4
- data/lib/baidu-sms/report_service.rb +11 -5
- data/lib/baidu-sms/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9993c6e1521964c0e3013e5b4673ddfd7fdf5b9d
|
4
|
+
data.tar.gz: dd537702a9539cf87908cea18f7e1de2cc723a38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
46
|
+
rescue *RETRYABLE_EXCEPTIONS => e
|
44
47
|
raise e unless retry_timeout && current_retry < max_retries
|
45
|
-
|
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)
|
data/lib/baidu-sms/version.rb
CHANGED
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
|
+
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: {}
|