siebel_donations 1.0.8 → 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/siebel_donations.rb +5 -1
- data/lib/siebel_donations/base.rb +11 -4
- data/lib/siebel_donations/version.rb +1 -1
- data/siebel_donations.gemspec +1 -1
- data/spec/base_spec.rb +25 -0
- metadata +12 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 359eaa167fe4d9d00549b7b6163074095c490f2a1a569781674b01a03f4db810
|
4
|
+
data.tar.gz: 452358f3403231414acf90f111a7e3199daa38f90f4d8bae399821150bb08ad0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c98babd3bbd4f98a40d450638bbc60cc03a8d340a594580fc07f30617deb7951619a28fcb7bffc76913d2fa73398583c9391a40d7107ea756596a6161f9e37f
|
7
|
+
data.tar.gz: a74a1cea33371b7496becf816a02e3f2ed4ed85313f66fb85af2b49dcac11d12f43d6b270ce0a8914b160e3b2e6e7b027f2caf5ea13a89486283ae428a5d3db0
|
data/lib/siebel_donations.rb
CHANGED
@@ -7,7 +7,7 @@ end
|
|
7
7
|
|
8
8
|
module SiebelDonations
|
9
9
|
class << self
|
10
|
-
attr_accessor :base_url, :oauth_token, :default_timeout
|
10
|
+
attr_accessor :base_url, :oauth_token, :default_timeout, :default_retry_count
|
11
11
|
|
12
12
|
def configure
|
13
13
|
yield self
|
@@ -20,6 +20,10 @@ module SiebelDonations
|
|
20
20
|
def default_timeout
|
21
21
|
@default_timeout || 6000
|
22
22
|
end
|
23
|
+
|
24
|
+
def default_retry_count
|
25
|
+
@default_retry_count || 2
|
26
|
+
end
|
23
27
|
end
|
24
28
|
end
|
25
29
|
|
@@ -14,11 +14,18 @@ module SiebelDonations
|
|
14
14
|
def self.get(path, params)
|
15
15
|
raise 'You need to configure SiebelDonations with your oauth_token.' unless SiebelDonations.oauth_token
|
16
16
|
|
17
|
-
params[:
|
17
|
+
request_timeout = params[:timeout] || SiebelDonations.default_timeout
|
18
|
+
params[:response_timeout] ||= request_timeout
|
19
|
+
retry_count = params.delete(:retry_count) || SiebelDonations.default_retry_count
|
18
20
|
|
19
21
|
url = SiebelDonations.base_url + path
|
20
|
-
|
21
|
-
|
22
|
+
headers = { params: params, authorization: "Bearer #{SiebelDonations.oauth_token}" }
|
23
|
+
|
24
|
+
retryable_errors = [RestClient::InternalServerError, Timeout::Error, Errno::ECONNRESET]
|
25
|
+
|
26
|
+
Retryable.retryable on: retryable_errors, times: retry_count, sleep: 20 do
|
27
|
+
request_params = { method: :get, url: url, headers: headers, timeout: request_timeout }
|
28
|
+
RestClient::Request.execute(request_params) do |response, request, result, &block|
|
22
29
|
case response.code
|
23
30
|
when 200
|
24
31
|
Oj.load(response.unpack("C*").pack("U*").force_encoding("UTF-8").encode!)
|
@@ -31,7 +38,7 @@ module SiebelDonations
|
|
31
38
|
puts request.inspect
|
32
39
|
raise result.inspect
|
33
40
|
end
|
34
|
-
|
41
|
+
end
|
35
42
|
end
|
36
43
|
end
|
37
44
|
|
data/siebel_donations.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
20
|
gem.add_dependency('rest-client', '~> 2.0.2')
|
21
|
-
gem.add_dependency('oj', '
|
21
|
+
gem.add_dependency('oj', '>= 2.18')
|
22
22
|
gem.add_dependency('activesupport', '>= 3.0.0')
|
23
23
|
gem.add_dependency('retryable-rb', '~> 1.1.0')
|
24
24
|
|
data/spec/base_spec.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SiebelDonations::Base do
|
4
|
+
context '.get' do
|
5
|
+
context 'with timeout param set' do
|
6
|
+
it 'passes param to RestClient' do
|
7
|
+
expect(RestClient::Request).to receive(:execute)
|
8
|
+
.with(hash_including(url: SiebelDonations.base_url, timeout: 123))
|
9
|
+
.and_return(nil)
|
10
|
+
|
11
|
+
described_class.get('', timeout: 123)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'without timeout param set' do
|
16
|
+
it 'passes default to RestClient' do
|
17
|
+
expect(RestClient::Request).to receive(:execute)
|
18
|
+
.with(hash_including(timeout: 6000))
|
19
|
+
.and_return(nil)
|
20
|
+
|
21
|
+
described_class.get('', {})
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: siebel_donations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Starcher
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: oj
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.18
|
33
|
+
version: '2.18'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.18
|
40
|
+
version: '2.18'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: activesupport
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,12 +92,13 @@ files:
|
|
92
92
|
- lib/siebel_donations/profile.rb
|
93
93
|
- lib/siebel_donations/version.rb
|
94
94
|
- siebel_donations.gemspec
|
95
|
+
- spec/base_spec.rb
|
95
96
|
- spec/donation_spec.rb
|
96
97
|
- spec/spec_helper.rb
|
97
98
|
homepage: ''
|
98
99
|
licenses: []
|
99
100
|
metadata: {}
|
100
|
-
post_install_message:
|
101
|
+
post_install_message:
|
101
102
|
rdoc_options: []
|
102
103
|
require_paths:
|
103
104
|
- lib
|
@@ -112,11 +113,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
113
|
- !ruby/object:Gem::Version
|
113
114
|
version: '0'
|
114
115
|
requirements: []
|
115
|
-
|
116
|
-
|
117
|
-
signing_key:
|
116
|
+
rubygems_version: 3.1.2
|
117
|
+
signing_key:
|
118
118
|
specification_version: 4
|
119
119
|
summary: Get donation information from Siebel Donor
|
120
120
|
test_files:
|
121
|
+
- spec/base_spec.rb
|
121
122
|
- spec/donation_spec.rb
|
122
123
|
- spec/spec_helper.rb
|