iron_bank 4.4.3 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/CODEOWNERS +1 -1
- data/.github/workflows/ci.yml +50 -0
- data/.rubocop.yml +10 -9
- data/.ruby-version +1 -1
- data/Gemfile +14 -0
- data/Gemfile.lock +87 -92
- data/README.md +8 -10
- data/iron_bank.gemspec +4 -18
- data/lib/iron_bank.rb +3 -1
- data/lib/iron_bank/action.rb +5 -3
- data/lib/iron_bank/actions/query.rb +2 -0
- data/lib/iron_bank/associations.rb +3 -5
- data/lib/iron_bank/authentication.rb +1 -1
- data/lib/iron_bank/authentications/cookie.rb +2 -2
- data/lib/iron_bank/configuration.rb +1 -1
- data/lib/iron_bank/describe/excluded_fields.rb +3 -5
- data/lib/iron_bank/faraday_middleware/response/raise_error.rb +0 -2
- data/lib/iron_bank/local.rb +16 -5
- data/lib/iron_bank/local_records.rb +1 -1
- data/lib/iron_bank/logger.rb +1 -1
- data/lib/iron_bank/schema.rb +4 -6
- data/lib/iron_bank/version.rb +1 -1
- metadata +14 -196
- data/.travis.yml +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 14e87c406e0f4ae3a6f3c1de8b84039a5d48ccf0ee8a1d208839fc9181160d36
|
4
|
+
data.tar.gz: 6b6d4418d571a17bb38a5fd551eaf6f7de5763a5a918e6c933d8e6bca8b20a8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1afbd350670d0709e6bcf6b84a33ba1a37525e9254de39dd6efb2af4f2793d467f61e0f175006e246b41f6130784abb67a89112a132d8132b98cfb003c9c4afb
|
7
|
+
data.tar.gz: a196e9dcc5c18d3130df47715efa357b400500b9e0a7bbdca4a279642ae99f45f29c169be258b77c1c50f384525bb66fcdee966d0beb036ea6611fffd2c8bbb5
|
data/.github/CODEOWNERS
CHANGED
@@ -1 +1 @@
|
|
1
|
-
* @zendesk/
|
1
|
+
* @zendesk/billing
|
@@ -0,0 +1,50 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
pull_request:
|
8
|
+
branches:
|
9
|
+
- main
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
test:
|
13
|
+
name: Ruby
|
14
|
+
|
15
|
+
strategy:
|
16
|
+
matrix:
|
17
|
+
ruby:
|
18
|
+
- 2.5
|
19
|
+
- 2.6
|
20
|
+
- 2.7
|
21
|
+
- 3.0
|
22
|
+
|
23
|
+
runs-on: ubuntu-latest
|
24
|
+
|
25
|
+
steps:
|
26
|
+
- uses: zendesk/checkout@v2
|
27
|
+
|
28
|
+
- uses: zendesk/setup-ruby@v1
|
29
|
+
with:
|
30
|
+
ruby-version: ${{ matrix.ruby }}
|
31
|
+
|
32
|
+
- uses: zendesk/cache@v2
|
33
|
+
with:
|
34
|
+
path: vendor/bundle
|
35
|
+
key: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }}
|
36
|
+
restore-keys: |
|
37
|
+
${{ runner.os }}-gems-
|
38
|
+
|
39
|
+
- name: Install Dependencies
|
40
|
+
run: |
|
41
|
+
bundle config deployment true
|
42
|
+
bundle config path vendor/bundle
|
43
|
+
bundle install --jobs 4
|
44
|
+
|
45
|
+
- name: Run Tests
|
46
|
+
run: bundle exec rake
|
47
|
+
env:
|
48
|
+
ZUORA_CLIENT_ID: something
|
49
|
+
ZUORA_CLIENT_SECRET: secret
|
50
|
+
ZUORA_DOMAIN: rest.apisandbox.zuora.com
|
data/.rubocop.yml
CHANGED
@@ -3,15 +3,20 @@ require: rubocop-performance
|
|
3
3
|
AllCops:
|
4
4
|
DisplayCopNames: true
|
5
5
|
DisplayStyleGuide: true
|
6
|
-
|
6
|
+
NewCops: enable
|
7
|
+
SuggestExtensions: false
|
7
8
|
|
8
9
|
Layout/DotPosition:
|
9
10
|
EnforcedStyle: trailing
|
10
11
|
|
11
|
-
Layout/
|
12
|
+
Layout/HashAlignment:
|
12
13
|
EnforcedHashRocketStyle: table
|
13
14
|
EnforcedColonStyle: table
|
14
15
|
|
16
|
+
Lint/EmptyBlock:
|
17
|
+
Exclude:
|
18
|
+
- spec/**/*.rb
|
19
|
+
|
15
20
|
Lint/UselessAssignment:
|
16
21
|
Exclude:
|
17
22
|
- bin/console
|
@@ -39,10 +44,6 @@ Metrics/MethodLength:
|
|
39
44
|
- lib/iron_bank/error.rb
|
40
45
|
- lib/iron_bank/client.rb
|
41
46
|
|
42
|
-
Metrics/LineLength:
|
43
|
-
Exclude:
|
44
|
-
- lib/iron_bank.rb
|
45
|
-
|
46
47
|
Style/ClassAndModuleChildren:
|
47
48
|
EnforcedStyle: nested
|
48
49
|
|
@@ -50,6 +51,9 @@ Style/MixinUsage:
|
|
50
51
|
Exclude:
|
51
52
|
- lib/iron_bank/resource.rb
|
52
53
|
|
54
|
+
Style/StringLiterals:
|
55
|
+
EnforcedStyle: double_quotes
|
56
|
+
|
53
57
|
Style/OptionalArguments:
|
54
58
|
Exclude:
|
55
59
|
- lib/iron_bank/local.rb
|
@@ -63,6 +67,3 @@ Style/RegexpLiteral:
|
|
63
67
|
Style/RescueStandardError:
|
64
68
|
Exclude:
|
65
69
|
- lib/iron_bank/csv.rb
|
66
|
-
|
67
|
-
Style/StringLiterals:
|
68
|
-
EnforcedStyle: double_quotes
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.5.8
|
data/Gemfile
CHANGED
@@ -4,3 +4,17 @@ source "https://rubygems.org"
|
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in zuora.gemspec
|
6
6
|
gemspec
|
7
|
+
|
8
|
+
gem "bump", "~> 0.5"
|
9
|
+
gem "bundler", "~> 2.0"
|
10
|
+
gem "dotenv", "~> 2.2"
|
11
|
+
gem "factory_bot", "~> 6.0"
|
12
|
+
gem "pry-byebug", "~> 3.4"
|
13
|
+
gem "rake", "~> 13.0"
|
14
|
+
gem "reek", "~> 6.0"
|
15
|
+
gem "rspec", "~> 3.0"
|
16
|
+
gem "rubocop", "~> 1.0"
|
17
|
+
gem "rubocop-performance", "~> 1.0"
|
18
|
+
gem "shoulda-matchers", "~> 4.0"
|
19
|
+
gem "simplecov", "~> 0.15"
|
20
|
+
gem "timecop", "~> 0.9"
|
data/Gemfile.lock
CHANGED
@@ -1,114 +1,109 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
iron_bank (
|
5
|
-
faraday (~>
|
6
|
-
faraday_middleware (~>
|
4
|
+
iron_bank (5.2.0)
|
5
|
+
faraday (~> 1)
|
6
|
+
faraday_middleware (~> 1)
|
7
7
|
nokogiri (~> 1)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activesupport (
|
12
|
+
activesupport (6.1.1)
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
-
i18n (>=
|
15
|
-
minitest (
|
16
|
-
tzinfo (~>
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
descendants_tracker (0.0.4)
|
31
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
32
|
-
diff-lcs (1.3)
|
33
|
-
docile (1.3.2)
|
34
|
-
dotenv (2.7.5)
|
35
|
-
equalizer (0.0.11)
|
36
|
-
factory_bot (5.0.2)
|
37
|
-
activesupport (>= 4.2.0)
|
38
|
-
faraday (0.17.3)
|
14
|
+
i18n (>= 1.6, < 2)
|
15
|
+
minitest (>= 5.1)
|
16
|
+
tzinfo (~> 2.0)
|
17
|
+
zeitwerk (~> 2.3)
|
18
|
+
ast (2.4.1)
|
19
|
+
bump (0.10.0)
|
20
|
+
byebug (11.1.3)
|
21
|
+
coderay (1.1.3)
|
22
|
+
concurrent-ruby (1.1.7)
|
23
|
+
diff-lcs (1.4.4)
|
24
|
+
docile (1.3.4)
|
25
|
+
dotenv (2.7.6)
|
26
|
+
factory_bot (6.1.0)
|
27
|
+
activesupport (>= 5.0.0)
|
28
|
+
faraday (1.3.0)
|
29
|
+
faraday-net_http (~> 1.0)
|
39
30
|
multipart-post (>= 1.2, < 3)
|
40
|
-
|
41
|
-
|
42
|
-
|
31
|
+
ruby2_keywords
|
32
|
+
faraday-net_http (1.0.1)
|
33
|
+
faraday_middleware (1.0.0)
|
34
|
+
faraday (~> 1.0)
|
35
|
+
i18n (1.8.7)
|
43
36
|
concurrent-ruby (~> 1.0)
|
44
|
-
ice_nine (0.11.2)
|
45
|
-
jaro_winkler (1.5.3)
|
46
|
-
json (2.2.0)
|
47
37
|
kwalify (0.7.2)
|
48
|
-
method_source (0.
|
49
|
-
mini_portile2 (2.
|
50
|
-
minitest (5.
|
38
|
+
method_source (1.0.0)
|
39
|
+
mini_portile2 (2.5.0)
|
40
|
+
minitest (5.14.3)
|
51
41
|
multipart-post (2.1.1)
|
52
|
-
nokogiri (1.
|
53
|
-
mini_portile2 (~> 2.
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
42
|
+
nokogiri (1.11.1)
|
43
|
+
mini_portile2 (~> 2.5.0)
|
44
|
+
racc (~> 1.4)
|
45
|
+
parallel (1.20.1)
|
46
|
+
parser (3.0.0.0)
|
47
|
+
ast (~> 2.4.1)
|
48
|
+
pry (0.13.1)
|
49
|
+
coderay (~> 1.1)
|
50
|
+
method_source (~> 1.0)
|
51
|
+
pry-byebug (3.9.0)
|
61
52
|
byebug (~> 11.0)
|
62
|
-
pry (~> 0.
|
63
|
-
psych (3.
|
53
|
+
pry (~> 0.13.0)
|
54
|
+
psych (3.3.0)
|
55
|
+
racc (1.5.2)
|
64
56
|
rainbow (3.0.0)
|
65
|
-
rake (
|
66
|
-
reek (
|
67
|
-
codeclimate-engine-rb (~> 0.4.0)
|
57
|
+
rake (13.0.3)
|
58
|
+
reek (6.0.3)
|
68
59
|
kwalify (~> 0.7.0)
|
69
|
-
parser (
|
70
|
-
psych (~> 3.1
|
60
|
+
parser (~> 3.0.0)
|
61
|
+
psych (~> 3.1)
|
71
62
|
rainbow (>= 2.0, < 4.0)
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
rspec-
|
76
|
-
|
77
|
-
rspec-
|
78
|
-
rspec-
|
63
|
+
regexp_parser (2.0.3)
|
64
|
+
rexml (3.2.4)
|
65
|
+
rspec (3.10.0)
|
66
|
+
rspec-core (~> 3.10.0)
|
67
|
+
rspec-expectations (~> 3.10.0)
|
68
|
+
rspec-mocks (~> 3.10.0)
|
69
|
+
rspec-core (3.10.1)
|
70
|
+
rspec-support (~> 3.10.0)
|
71
|
+
rspec-expectations (3.10.1)
|
79
72
|
diff-lcs (>= 1.2.0, < 2.0)
|
80
|
-
rspec-support (~> 3.
|
81
|
-
rspec-mocks (3.
|
73
|
+
rspec-support (~> 3.10.0)
|
74
|
+
rspec-mocks (3.10.1)
|
82
75
|
diff-lcs (>= 1.2.0, < 2.0)
|
83
|
-
rspec-support (~> 3.
|
84
|
-
rspec-support (3.
|
85
|
-
rubocop (
|
86
|
-
jaro_winkler (~> 1.5.1)
|
76
|
+
rspec-support (~> 3.10.0)
|
77
|
+
rspec-support (3.10.1)
|
78
|
+
rubocop (1.8.1)
|
87
79
|
parallel (~> 1.10)
|
88
|
-
parser (>=
|
80
|
+
parser (>= 3.0.0.0)
|
89
81
|
rainbow (>= 2.2.2, < 4.0)
|
82
|
+
regexp_parser (>= 1.8, < 3.0)
|
83
|
+
rexml
|
84
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
90
85
|
ruby-progressbar (~> 1.7)
|
91
|
-
unicode-display_width (>= 1.4.0, <
|
92
|
-
rubocop-
|
93
|
-
|
94
|
-
|
95
|
-
|
86
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
87
|
+
rubocop-ast (1.4.0)
|
88
|
+
parser (>= 2.7.1.5)
|
89
|
+
rubocop-performance (1.9.2)
|
90
|
+
rubocop (>= 0.90.0, < 2.0)
|
91
|
+
rubocop-ast (>= 0.4.0)
|
92
|
+
ruby-progressbar (1.11.0)
|
93
|
+
ruby2_keywords (0.0.4)
|
94
|
+
shoulda-matchers (4.5.0)
|
96
95
|
activesupport (>= 4.2.0)
|
97
|
-
simplecov (0.
|
96
|
+
simplecov (0.21.2)
|
98
97
|
docile (~> 1.1)
|
99
|
-
|
100
|
-
|
101
|
-
simplecov-html (0.
|
102
|
-
|
103
|
-
timecop (0.9.
|
104
|
-
tzinfo (
|
105
|
-
|
106
|
-
unicode-display_width (
|
107
|
-
|
108
|
-
axiom-types (~> 0.1)
|
109
|
-
coercible (~> 1.0)
|
110
|
-
descendants_tracker (~> 0.0, >= 0.0.3)
|
111
|
-
equalizer (~> 0.0, >= 0.0.9)
|
98
|
+
simplecov-html (~> 0.11)
|
99
|
+
simplecov_json_formatter (~> 0.1)
|
100
|
+
simplecov-html (0.12.3)
|
101
|
+
simplecov_json_formatter (0.1.2)
|
102
|
+
timecop (0.9.2)
|
103
|
+
tzinfo (2.0.4)
|
104
|
+
concurrent-ruby (~> 1.0)
|
105
|
+
unicode-display_width (2.0.0)
|
106
|
+
zeitwerk (2.4.2)
|
112
107
|
|
113
108
|
PLATFORMS
|
114
109
|
ruby
|
@@ -117,17 +112,17 @@ DEPENDENCIES
|
|
117
112
|
bump (~> 0.5)
|
118
113
|
bundler (~> 2.0)
|
119
114
|
dotenv (~> 2.2)
|
120
|
-
factory_bot (~>
|
115
|
+
factory_bot (~> 6.0)
|
121
116
|
iron_bank!
|
122
117
|
pry-byebug (~> 3.4)
|
123
|
-
rake (~>
|
124
|
-
reek (~>
|
118
|
+
rake (~> 13.0)
|
119
|
+
reek (~> 6.0)
|
125
120
|
rspec (~> 3.0)
|
126
|
-
rubocop (~> 0
|
121
|
+
rubocop (~> 1.0)
|
127
122
|
rubocop-performance (~> 1.0)
|
128
123
|
shoulda-matchers (~> 4.0)
|
129
124
|
simplecov (~> 0.15)
|
130
125
|
timecop (~> 0.9)
|
131
126
|
|
132
127
|
BUNDLED WITH
|
133
|
-
2.
|
128
|
+
2.2.6
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Iron Bank
|
2
2
|
|
3
|
-
|
3
|
+
![CI](https://github.com/zendesk/iron_bank/workflows/CI/badge.svg?branch=main)
|
4
4
|
|
5
5
|
An opinionated Ruby interface to the [Zuora REST API][zuora-dev].
|
6
6
|
|
@@ -13,7 +13,7 @@ This gem provides opinionated resources to interact with the Zuora API through
|
|
13
13
|
their REST interface. It defines **associations** between them, as well as a
|
14
14
|
simple **declaration API** (`with_one`, `with_many`) to extend them.
|
15
15
|
|
16
|
-
This gem is tested against Ruby `>= 2.
|
16
|
+
This gem is tested against Ruby `>= 2.5`.
|
17
17
|
|
18
18
|
Please use [GitHub Issues][issues] to report bugs.
|
19
19
|
|
@@ -23,8 +23,7 @@ You will need:
|
|
23
23
|
|
24
24
|
- a **Zuora tenant** (apisandbox, services, performances or production)
|
25
25
|
- an **administrator access** to this tenant (to gain API access)
|
26
|
-
- and an **OAuth client** for this user
|
27
|
-
([Zuora documentation][zuora-doc-oauth])
|
26
|
+
- and an **OAuth client** for this user ([Zuora documentation][zuora-doc-oauth])
|
28
27
|
|
29
28
|
IronBank is a pure Ruby client, but we do provide a generator (for the
|
30
29
|
configuration) when using it within [Rails][rails-website].
|
@@ -89,9 +88,9 @@ account.active_subscriptions
|
|
89
88
|
|
90
89
|
## Local records
|
91
90
|
|
92
|
-
If your product catalog does not change often, you may want to export
|
93
|
-
|
94
|
-
|
91
|
+
If your product catalog does not change often, you may want to export it locally
|
92
|
+
so that product catalog and related object queries look for **local records**
|
93
|
+
first, then **fallback** to the API if no records are found.
|
95
94
|
|
96
95
|
You can export your product catalog locally using the `LocalRecords` class:
|
97
96
|
|
@@ -155,10 +154,9 @@ CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
155
154
|
specific language governing permissions and limitations under the License.
|
156
155
|
|
157
156
|
[issues]: https://github.com/zendesk/iron_bank/issues
|
158
|
-
[travis-status]: https://travis-ci.com/zendesk/iron_bank.svg?token=Qzkq5papoR7sdedznjeb&branch=master
|
159
|
-
[travis-build]: https://travis-ci.com/zendesk/iron_bank
|
160
157
|
[zuora-describe]: https://www.zuora.com/developer/api-reference/#tag/Describe
|
161
158
|
[zuora-dev]: https://developer.zuora.com
|
162
|
-
[zuora-doc-oauth]:
|
159
|
+
[zuora-doc-oauth]:
|
160
|
+
https://knowledgecenter.zuora.com/CF_Users_and_Administrators/A_Administrator_Settings/Manage_Users#Create_an_OAuth_Client_for_a_User
|
163
161
|
[zuora-website]: https://www.zuora.com
|
164
162
|
[rails-website]: https://rubyonrails.org/
|
data/iron_bank.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
"mturan@zendesk.com"
|
20
20
|
]
|
21
21
|
|
22
|
-
spec.required_ruby_version = ">= 2.
|
22
|
+
spec.required_ruby_version = ">= 2.5"
|
23
23
|
|
24
24
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
25
25
|
f.match(%r{^(test|spec|features)/})
|
@@ -29,21 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
30
|
spec.require_paths = ["lib"]
|
31
31
|
|
32
|
-
spec.
|
33
|
-
spec.
|
34
|
-
spec.
|
35
|
-
spec.add_development_dependency "factory_bot", "~> 5.0"
|
36
|
-
spec.add_development_dependency "pry-byebug", "~> 3.4"
|
37
|
-
spec.add_development_dependency "rake", "~> 12.0"
|
38
|
-
spec.add_development_dependency "reek", "~> 5.0"
|
39
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
40
|
-
spec.add_development_dependency "rubocop", "~> 0.67"
|
41
|
-
spec.add_development_dependency "rubocop-performance", "~> 1.0"
|
42
|
-
spec.add_development_dependency "shoulda-matchers", "~> 4.0"
|
43
|
-
spec.add_development_dependency "simplecov", "~> 0.15"
|
44
|
-
spec.add_development_dependency "timecop", "~> 0.9"
|
45
|
-
|
46
|
-
spec.add_runtime_dependency "faraday", "~> 0"
|
47
|
-
spec.add_runtime_dependency "faraday_middleware", "~> 0"
|
48
|
-
spec.add_runtime_dependency "nokogiri", "~> 1"
|
32
|
+
spec.add_dependency "faraday", "~> 1"
|
33
|
+
spec.add_dependency "faraday_middleware", "~> 1"
|
34
|
+
spec.add_dependency "nokogiri", "~> 1"
|
49
35
|
end
|
data/lib/iron_bank.rb
CHANGED
@@ -25,7 +25,7 @@ module IronBank
|
|
25
25
|
|
26
26
|
return unless configuration.credentials?
|
27
27
|
|
28
|
-
self.client ||= IronBank::Client.new(configuration.credentials)
|
28
|
+
self.client ||= IronBank::Client.new(**configuration.credentials)
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.logger
|
@@ -60,7 +60,9 @@ require "iron_bank/faraday_middleware/response/raise_error"
|
|
60
60
|
require "iron_bank/faraday_middleware/response/renew_auth"
|
61
61
|
|
62
62
|
# Use default configuration
|
63
|
+
# rubocop:disable Lint/EmptyBlock
|
63
64
|
IronBank.configure {}
|
65
|
+
# rubocop:enable Lint/EmptyBlock
|
64
66
|
|
65
67
|
# Actions
|
66
68
|
require "iron_bank/action"
|
data/lib/iron_bank/action.rb
CHANGED
@@ -40,9 +40,11 @@ module IronBank
|
|
40
40
|
|
41
41
|
def response_object
|
42
42
|
@response_object ||= begin
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
if body.is_a?(Array)
|
44
|
+
::IronBank::Object.new(body.first).deep_underscore
|
45
|
+
else
|
46
|
+
{}
|
47
|
+
end
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
@@ -12,7 +12,7 @@ module IronBank
|
|
12
12
|
:resource_name,
|
13
13
|
IronBank::Utils.camelize(name)
|
14
14
|
)
|
15
|
-
foreign_key = options.fetch(:foreign_key, name
|
15
|
+
foreign_key = options.fetch(:foreign_key, "#{name}_id")
|
16
16
|
|
17
17
|
define_method(name) do
|
18
18
|
return unless (foreign_key_value = public_send(foreign_key))
|
@@ -37,7 +37,7 @@ module IronBank
|
|
37
37
|
|
38
38
|
foreign_key = options.fetch(
|
39
39
|
:foreign_key,
|
40
|
-
IronBank::Utils.underscore(object_name)
|
40
|
+
"#{IronBank::Utils.underscore(object_name)}_id"
|
41
41
|
)
|
42
42
|
|
43
43
|
define_method(name) do
|
@@ -60,9 +60,7 @@ module IronBank
|
|
60
60
|
def with_memoization(name)
|
61
61
|
# NOTE: We use `instance_variables.include?` instead of `defined?`.
|
62
62
|
# Later it will always evaluate to `true` because it's an expression.
|
63
|
-
if instance_variables.include?(:"@#{name}")
|
64
|
-
return instance_variable_get(:"@#{name}")
|
65
|
-
end
|
63
|
+
return instance_variable_get(:"@#{name}") if instance_variables.include?(:"@#{name}")
|
66
64
|
|
67
65
|
memoizable = yield
|
68
66
|
instance_variable_set(:"@#{name}", memoizable)
|
@@ -43,7 +43,7 @@ module IronBank
|
|
43
43
|
alias refetch_cookie fetch_cookie
|
44
44
|
|
45
45
|
def fetch_zsession
|
46
|
-
/ZSession=([
|
46
|
+
/ZSession=([^;]+)/.match(cookie)[0]
|
47
47
|
end
|
48
48
|
|
49
49
|
def authenticate
|
@@ -51,7 +51,7 @@ module IronBank
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def connection
|
54
|
-
@connection ||= Faraday.new(faraday_config) do |conn|
|
54
|
+
@connection ||= Faraday.new(**faraday_config) do |conn|
|
55
55
|
IronBank.configuration.middlewares.each do |klass, options|
|
56
56
|
conn.use klass, options
|
57
57
|
end
|
@@ -63,7 +63,7 @@ module IronBank
|
|
63
63
|
@export_directory = value
|
64
64
|
return unless defined? IronBank::Product
|
65
65
|
|
66
|
-
IronBank::LocalRecords::RESOURCE_QUERY_FIELDS.
|
66
|
+
IronBank::LocalRecords::RESOURCE_QUERY_FIELDS.each_key do |resource|
|
67
67
|
IronBank::Resources.const_get(resource).reset_store
|
68
68
|
end
|
69
69
|
end
|
@@ -82,12 +82,12 @@ module IronBank
|
|
82
82
|
def valid_query?
|
83
83
|
# Querying using the ID (which is an indexed field) should return an
|
84
84
|
# empty collection very quickly when successful
|
85
|
-
object.where(id: INVALID_OBJECT_ID)
|
85
|
+
object.where({ id: INVALID_OBJECT_ID })
|
86
86
|
|
87
87
|
info "Successful query for #{object_name}"
|
88
88
|
|
89
89
|
true
|
90
|
-
rescue IronBank::InternalServerError => e
|
90
|
+
rescue IronBank::InternalServerError, IronBank::BadRequestError => e
|
91
91
|
@last_failed_fields = extract_fields_from_exception(e)
|
92
92
|
|
93
93
|
false
|
@@ -96,9 +96,7 @@ module IronBank
|
|
96
96
|
def extract_fields_from_exception(exception)
|
97
97
|
message = exception.message
|
98
98
|
|
99
|
-
unless FAULT_FIELD_MESSAGES.match(message)
|
100
|
-
raise "Could not parse error message: #{message}"
|
101
|
-
end
|
99
|
+
raise "Could not parse error message: #{message}" unless FAULT_FIELD_MESSAGES.match(message)
|
102
100
|
|
103
101
|
failed_fields = Regexp.last_match.
|
104
102
|
captures.
|
@@ -9,8 +9,6 @@ module IronBank
|
|
9
9
|
# This class raises an exception based on the HTTP status code and the
|
10
10
|
# `success` flag (if present in the response) from Zuora.
|
11
11
|
class RaiseError < Faraday::Response::Middleware
|
12
|
-
private
|
13
|
-
|
14
12
|
def on_complete(env)
|
15
13
|
(error = IronBank::Error.from_response(env.response)) && raise(error)
|
16
14
|
end
|
data/lib/iron_bank/local.rb
CHANGED
@@ -8,11 +8,11 @@ module IronBank
|
|
8
8
|
store[id] || super
|
9
9
|
end
|
10
10
|
|
11
|
-
def find_each
|
12
|
-
return enum_for(:find_each) unless
|
11
|
+
def find_each(&block)
|
12
|
+
return enum_for(:find_each) unless block
|
13
13
|
|
14
14
|
values = store.values
|
15
|
-
values.any? ? values.each
|
15
|
+
values.any? ? values.each(&block) : super
|
16
16
|
end
|
17
17
|
|
18
18
|
def all
|
@@ -25,7 +25,9 @@ module IronBank
|
|
25
25
|
|
26
26
|
def where(conditions, limit: IronBank::Actions::Query::DEFAULT_ZUORA_LIMIT)
|
27
27
|
records = store.values.select do |record|
|
28
|
-
conditions.all?
|
28
|
+
conditions.all? do |field, match_value|
|
29
|
+
value_matches?(record.public_send(field), match_value)
|
30
|
+
end
|
29
31
|
end
|
30
32
|
|
31
33
|
records.any? ? records : super
|
@@ -55,7 +57,7 @@ module IronBank
|
|
55
57
|
end
|
56
58
|
|
57
59
|
def load_records
|
58
|
-
CSV.foreach(file_path, csv_options).with_object({}) do |row, store|
|
60
|
+
CSV.foreach(file_path, **csv_options).with_object({}) do |row, store|
|
59
61
|
store[row[:id]] = new(row.to_h.compact)
|
60
62
|
end
|
61
63
|
end
|
@@ -81,5 +83,14 @@ module IronBank
|
|
81
83
|
IronBank.configuration.export_directory
|
82
84
|
)
|
83
85
|
end
|
86
|
+
|
87
|
+
# :reek:UtilityFunction
|
88
|
+
def value_matches?(record_value, match_value)
|
89
|
+
if match_value.is_a? Array
|
90
|
+
match_value.include? record_value
|
91
|
+
else
|
92
|
+
record_value == match_value
|
93
|
+
end
|
94
|
+
end
|
84
95
|
end
|
85
96
|
end
|
@@ -19,7 +19,7 @@ module IronBank
|
|
19
19
|
|
20
20
|
def self.export
|
21
21
|
FileUtils.mkdir_p(directory) unless Dir.exist?(directory)
|
22
|
-
RESOURCE_QUERY_FIELDS.
|
22
|
+
RESOURCE_QUERY_FIELDS.each_key { |resource| new(resource).save_file }
|
23
23
|
end
|
24
24
|
|
25
25
|
def save_file
|
data/lib/iron_bank/logger.rb
CHANGED
@@ -14,7 +14,7 @@ module IronBank
|
|
14
14
|
|
15
15
|
def_delegators :@logger, :debug, :info, :warn, :error, :fatal
|
16
16
|
|
17
|
-
def initialize(logger: ::Logger.new(
|
17
|
+
def initialize(logger: ::Logger.new($stdout), level: LEVEL)
|
18
18
|
@logger = logger
|
19
19
|
@logger.progname = PROGNAME
|
20
20
|
@logger.level = level
|
data/lib/iron_bank/schema.rb
CHANGED
@@ -49,12 +49,10 @@ module IronBank
|
|
49
49
|
|
50
50
|
def export
|
51
51
|
tenant.objects.compact.each do |object|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
next
|
57
|
-
end
|
52
|
+
object.export
|
53
|
+
rescue IronBank::Describe::Object::InvalidXML
|
54
|
+
# TODO: log the object error
|
55
|
+
next
|
58
56
|
end
|
59
57
|
end
|
60
58
|
|
data/lib/iron_bank/version.rb
CHANGED
metadata
CHANGED
@@ -1,228 +1,46 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iron_bank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mickael Pham
|
8
8
|
- Cheng Cui
|
9
9
|
- Ryan Ringler
|
10
10
|
- Mustafa Turan
|
11
|
-
autorequire:
|
11
|
+
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2021-03-03 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
17
|
-
name: bump
|
18
|
-
requirement: !ruby/object:Gem::Requirement
|
19
|
-
requirements:
|
20
|
-
- - "~>"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '0.5'
|
23
|
-
type: :development
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0.5'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: bundler
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
requirements:
|
34
|
-
- - "~>"
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: '2.0'
|
37
|
-
type: :development
|
38
|
-
prerelease: false
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - "~>"
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '2.0'
|
44
|
-
- !ruby/object:Gem::Dependency
|
45
|
-
name: dotenv
|
46
|
-
requirement: !ruby/object:Gem::Requirement
|
47
|
-
requirements:
|
48
|
-
- - "~>"
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: '2.2'
|
51
|
-
type: :development
|
52
|
-
prerelease: false
|
53
|
-
version_requirements: !ruby/object:Gem::Requirement
|
54
|
-
requirements:
|
55
|
-
- - "~>"
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version: '2.2'
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: factory_bot
|
60
|
-
requirement: !ruby/object:Gem::Requirement
|
61
|
-
requirements:
|
62
|
-
- - "~>"
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
version: '5.0'
|
65
|
-
type: :development
|
66
|
-
prerelease: false
|
67
|
-
version_requirements: !ruby/object:Gem::Requirement
|
68
|
-
requirements:
|
69
|
-
- - "~>"
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
version: '5.0'
|
72
|
-
- !ruby/object:Gem::Dependency
|
73
|
-
name: pry-byebug
|
74
|
-
requirement: !ruby/object:Gem::Requirement
|
75
|
-
requirements:
|
76
|
-
- - "~>"
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
version: '3.4'
|
79
|
-
type: :development
|
80
|
-
prerelease: false
|
81
|
-
version_requirements: !ruby/object:Gem::Requirement
|
82
|
-
requirements:
|
83
|
-
- - "~>"
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '3.4'
|
86
|
-
- !ruby/object:Gem::Dependency
|
87
|
-
name: rake
|
88
|
-
requirement: !ruby/object:Gem::Requirement
|
89
|
-
requirements:
|
90
|
-
- - "~>"
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
version: '12.0'
|
93
|
-
type: :development
|
94
|
-
prerelease: false
|
95
|
-
version_requirements: !ruby/object:Gem::Requirement
|
96
|
-
requirements:
|
97
|
-
- - "~>"
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
version: '12.0'
|
100
|
-
- !ruby/object:Gem::Dependency
|
101
|
-
name: reek
|
102
|
-
requirement: !ruby/object:Gem::Requirement
|
103
|
-
requirements:
|
104
|
-
- - "~>"
|
105
|
-
- !ruby/object:Gem::Version
|
106
|
-
version: '5.0'
|
107
|
-
type: :development
|
108
|
-
prerelease: false
|
109
|
-
version_requirements: !ruby/object:Gem::Requirement
|
110
|
-
requirements:
|
111
|
-
- - "~>"
|
112
|
-
- !ruby/object:Gem::Version
|
113
|
-
version: '5.0'
|
114
|
-
- !ruby/object:Gem::Dependency
|
115
|
-
name: rspec
|
116
|
-
requirement: !ruby/object:Gem::Requirement
|
117
|
-
requirements:
|
118
|
-
- - "~>"
|
119
|
-
- !ruby/object:Gem::Version
|
120
|
-
version: '3.0'
|
121
|
-
type: :development
|
122
|
-
prerelease: false
|
123
|
-
version_requirements: !ruby/object:Gem::Requirement
|
124
|
-
requirements:
|
125
|
-
- - "~>"
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
version: '3.0'
|
128
|
-
- !ruby/object:Gem::Dependency
|
129
|
-
name: rubocop
|
130
|
-
requirement: !ruby/object:Gem::Requirement
|
131
|
-
requirements:
|
132
|
-
- - "~>"
|
133
|
-
- !ruby/object:Gem::Version
|
134
|
-
version: '0.67'
|
135
|
-
type: :development
|
136
|
-
prerelease: false
|
137
|
-
version_requirements: !ruby/object:Gem::Requirement
|
138
|
-
requirements:
|
139
|
-
- - "~>"
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: '0.67'
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: rubocop-performance
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
requirements:
|
146
|
-
- - "~>"
|
147
|
-
- !ruby/object:Gem::Version
|
148
|
-
version: '1.0'
|
149
|
-
type: :development
|
150
|
-
prerelease: false
|
151
|
-
version_requirements: !ruby/object:Gem::Requirement
|
152
|
-
requirements:
|
153
|
-
- - "~>"
|
154
|
-
- !ruby/object:Gem::Version
|
155
|
-
version: '1.0'
|
156
|
-
- !ruby/object:Gem::Dependency
|
157
|
-
name: shoulda-matchers
|
158
|
-
requirement: !ruby/object:Gem::Requirement
|
159
|
-
requirements:
|
160
|
-
- - "~>"
|
161
|
-
- !ruby/object:Gem::Version
|
162
|
-
version: '4.0'
|
163
|
-
type: :development
|
164
|
-
prerelease: false
|
165
|
-
version_requirements: !ruby/object:Gem::Requirement
|
166
|
-
requirements:
|
167
|
-
- - "~>"
|
168
|
-
- !ruby/object:Gem::Version
|
169
|
-
version: '4.0'
|
170
|
-
- !ruby/object:Gem::Dependency
|
171
|
-
name: simplecov
|
172
|
-
requirement: !ruby/object:Gem::Requirement
|
173
|
-
requirements:
|
174
|
-
- - "~>"
|
175
|
-
- !ruby/object:Gem::Version
|
176
|
-
version: '0.15'
|
177
|
-
type: :development
|
178
|
-
prerelease: false
|
179
|
-
version_requirements: !ruby/object:Gem::Requirement
|
180
|
-
requirements:
|
181
|
-
- - "~>"
|
182
|
-
- !ruby/object:Gem::Version
|
183
|
-
version: '0.15'
|
184
|
-
- !ruby/object:Gem::Dependency
|
185
|
-
name: timecop
|
186
|
-
requirement: !ruby/object:Gem::Requirement
|
187
|
-
requirements:
|
188
|
-
- - "~>"
|
189
|
-
- !ruby/object:Gem::Version
|
190
|
-
version: '0.9'
|
191
|
-
type: :development
|
192
|
-
prerelease: false
|
193
|
-
version_requirements: !ruby/object:Gem::Requirement
|
194
|
-
requirements:
|
195
|
-
- - "~>"
|
196
|
-
- !ruby/object:Gem::Version
|
197
|
-
version: '0.9'
|
198
16
|
- !ruby/object:Gem::Dependency
|
199
17
|
name: faraday
|
200
18
|
requirement: !ruby/object:Gem::Requirement
|
201
19
|
requirements:
|
202
20
|
- - "~>"
|
203
21
|
- !ruby/object:Gem::Version
|
204
|
-
version: '
|
22
|
+
version: '1'
|
205
23
|
type: :runtime
|
206
24
|
prerelease: false
|
207
25
|
version_requirements: !ruby/object:Gem::Requirement
|
208
26
|
requirements:
|
209
27
|
- - "~>"
|
210
28
|
- !ruby/object:Gem::Version
|
211
|
-
version: '
|
29
|
+
version: '1'
|
212
30
|
- !ruby/object:Gem::Dependency
|
213
31
|
name: faraday_middleware
|
214
32
|
requirement: !ruby/object:Gem::Requirement
|
215
33
|
requirements:
|
216
34
|
- - "~>"
|
217
35
|
- !ruby/object:Gem::Version
|
218
|
-
version: '
|
36
|
+
version: '1'
|
219
37
|
type: :runtime
|
220
38
|
prerelease: false
|
221
39
|
version_requirements: !ruby/object:Gem::Requirement
|
222
40
|
requirements:
|
223
41
|
- - "~>"
|
224
42
|
- !ruby/object:Gem::Version
|
225
|
-
version: '
|
43
|
+
version: '1'
|
226
44
|
- !ruby/object:Gem::Dependency
|
227
45
|
name: nokogiri
|
228
46
|
requirement: !ruby/object:Gem::Requirement
|
@@ -237,7 +55,7 @@ dependencies:
|
|
237
55
|
- - "~>"
|
238
56
|
- !ruby/object:Gem::Version
|
239
57
|
version: '1'
|
240
|
-
description:
|
58
|
+
description:
|
241
59
|
email:
|
242
60
|
- mickael@zendesk.com
|
243
61
|
- ccui@zendesk.com
|
@@ -250,12 +68,12 @@ files:
|
|
250
68
|
- ".env.example"
|
251
69
|
- ".github/CODEOWNERS"
|
252
70
|
- ".github/PULL_REQUEST_TEMPLATE.md"
|
71
|
+
- ".github/workflows/ci.yml"
|
253
72
|
- ".gitignore"
|
254
73
|
- ".reek.yml"
|
255
74
|
- ".rspec"
|
256
75
|
- ".rubocop.yml"
|
257
76
|
- ".ruby-version"
|
258
|
-
- ".travis.yml"
|
259
77
|
- Gemfile
|
260
78
|
- Gemfile.lock
|
261
79
|
- LICENSE
|
@@ -337,7 +155,7 @@ homepage: https://github.com/zendesk/iron_bank
|
|
337
155
|
licenses:
|
338
156
|
- Apache-2.0
|
339
157
|
metadata: {}
|
340
|
-
post_install_message:
|
158
|
+
post_install_message:
|
341
159
|
rdoc_options: []
|
342
160
|
require_paths:
|
343
161
|
- lib
|
@@ -345,16 +163,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
345
163
|
requirements:
|
346
164
|
- - ">="
|
347
165
|
- !ruby/object:Gem::Version
|
348
|
-
version: '2.
|
166
|
+
version: '2.5'
|
349
167
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
350
168
|
requirements:
|
351
169
|
- - ">="
|
352
170
|
- !ruby/object:Gem::Version
|
353
171
|
version: '0'
|
354
172
|
requirements: []
|
355
|
-
rubyforge_project:
|
356
|
-
rubygems_version: 2.6.
|
357
|
-
signing_key:
|
173
|
+
rubyforge_project:
|
174
|
+
rubygems_version: 2.7.6.2
|
175
|
+
signing_key:
|
358
176
|
specification_version: 4
|
359
177
|
summary: An opinionated Ruby interface to the Zuora API.
|
360
178
|
test_files: []
|
data/.travis.yml
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
cache: bundler
|
2
|
-
|
3
|
-
language: ruby
|
4
|
-
|
5
|
-
rvm:
|
6
|
-
- 2.4.6
|
7
|
-
- 2.5.5
|
8
|
-
- 2.6.2
|
9
|
-
|
10
|
-
sudo: false
|
11
|
-
|
12
|
-
branches:
|
13
|
-
only: master
|
14
|
-
|
15
|
-
before_install:
|
16
|
-
- gem update --system
|
17
|
-
- gem install bundler --no-document
|
18
|
-
|
19
|
-
env:
|
20
|
-
global:
|
21
|
-
- ZUORA_CLIENT_ID=something
|
22
|
-
- ZUORA_CLIENT_SECRET=secret
|
23
|
-
- ZUORA_DOMAIN=rest.apisandbox.zuora.com
|