iron_bank 0.1.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.env.example +7 -0
- data/.github/CODEOWNERS +1 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +20 -0
- data/.gitignore +6 -1
- data/.reek +95 -0
- data/.rspec +1 -2
- data/.rubocop.yml +55 -0
- data/.travis.yml +22 -3
- data/Gemfile +3 -3
- data/LICENSE +176 -0
- data/README.md +133 -0
- data/Rakefile +39 -3
- data/bin/console +13 -1
- data/bin/setup +1 -0
- data/iron_bank.gemspec +34 -10
- data/lib/generators/iron_bank/install/install_generator.rb +20 -0
- data/lib/generators/iron_bank/install/templates/README +16 -0
- data/lib/generators/iron_bank/install/templates/iron_bank.rb +29 -0
- data/lib/iron_bank/action.rb +39 -0
- data/lib/iron_bank/actions/amend.rb +16 -0
- data/lib/iron_bank/actions/create.rb +19 -0
- data/lib/iron_bank/actions/delete.rb +19 -0
- data/lib/iron_bank/actions/execute.rb +21 -0
- data/lib/iron_bank/actions/generate.rb +19 -0
- data/lib/iron_bank/actions/query.rb +16 -0
- data/lib/iron_bank/actions/query_more.rb +21 -0
- data/lib/iron_bank/actions/subscribe.rb +32 -0
- data/lib/iron_bank/actions/update.rb +19 -0
- data/lib/iron_bank/associations.rb +73 -0
- data/lib/iron_bank/authentication.rb +37 -0
- data/lib/iron_bank/authentications/cookie.rb +80 -0
- data/lib/iron_bank/authentications/token.rb +82 -0
- data/lib/iron_bank/cacheable.rb +52 -0
- data/lib/iron_bank/client.rb +96 -0
- data/lib/iron_bank/collection.rb +31 -0
- data/lib/iron_bank/configuration.rb +86 -0
- data/lib/iron_bank/csv.rb +29 -0
- data/lib/iron_bank/describe/field.rb +65 -0
- data/lib/iron_bank/describe/object.rb +81 -0
- data/lib/iron_bank/describe/related.rb +40 -0
- data/lib/iron_bank/describe/tenant.rb +50 -0
- data/lib/iron_bank/endpoint.rb +36 -0
- data/lib/iron_bank/error.rb +45 -0
- data/lib/iron_bank/instrumentation.rb +14 -0
- data/lib/iron_bank/local.rb +72 -0
- data/lib/iron_bank/local_records.rb +52 -0
- data/lib/iron_bank/logger.rb +23 -0
- data/lib/iron_bank/metadata.rb +36 -0
- data/lib/iron_bank/object.rb +89 -0
- data/lib/iron_bank/open_tracing.rb +17 -0
- data/lib/iron_bank/operation.rb +33 -0
- data/lib/iron_bank/operations/billing_preview.rb +16 -0
- data/lib/iron_bank/query_builder.rb +72 -0
- data/lib/iron_bank/queryable.rb +55 -0
- data/lib/iron_bank/resource.rb +70 -0
- data/lib/iron_bank/resources/account.rb +62 -0
- data/lib/iron_bank/resources/amendment.rb +13 -0
- data/lib/iron_bank/resources/catalog_tiers/discount_amount.rb +26 -0
- data/lib/iron_bank/resources/catalog_tiers/discount_percentage.rb +26 -0
- data/lib/iron_bank/resources/catalog_tiers/price.rb +26 -0
- data/lib/iron_bank/resources/contact.rb +13 -0
- data/lib/iron_bank/resources/export.rb +11 -0
- data/lib/iron_bank/resources/import.rb +12 -0
- data/lib/iron_bank/resources/invoice.rb +37 -0
- data/lib/iron_bank/resources/invoice_adjustment.rb +13 -0
- data/lib/iron_bank/resources/invoice_item.rb +25 -0
- data/lib/iron_bank/resources/invoice_payment.rb +13 -0
- data/lib/iron_bank/resources/payment.rb +17 -0
- data/lib/iron_bank/resources/payment_method.rb +14 -0
- data/lib/iron_bank/resources/product.rb +14 -0
- data/lib/iron_bank/resources/product_rate_plan.rb +32 -0
- data/lib/iron_bank/resources/product_rate_plan_charge.rb +27 -0
- data/lib/iron_bank/resources/product_rate_plan_charge_tier.rb +60 -0
- data/lib/iron_bank/resources/rate_plan.rb +21 -0
- data/lib/iron_bank/resources/rate_plan_charge.rb +30 -0
- data/lib/iron_bank/resources/rate_plan_charge_tier.rb +26 -0
- data/lib/iron_bank/resources/subscription.rb +28 -0
- data/lib/iron_bank/resources/usage.rb +16 -0
- data/lib/iron_bank/response/raise_error.rb +16 -0
- data/lib/iron_bank/schema.rb +58 -0
- data/lib/iron_bank/utils.rb +59 -0
- data/lib/iron_bank/version.rb +4 -1
- data/lib/iron_bank.rb +152 -2
- metadata +300 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2baff3984f831ae315a8b7bf48a2c72156cfcef01aa83fa54622afc85d81c23a
|
4
|
+
data.tar.gz: 15b484fd7ba61b56617e1c12e1fa29d3438cf6d77824fe2f5c923c3bfde7c03a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cc8e60a59e548572627bc9546e5e81f481f7f19b83ca6602925e9776fc4d8e8c60a237b3ee644d822b557c470d45fd9b5b9acfa2e8807f3484b71195189d78e
|
7
|
+
data.tar.gz: 31652f97be5d13281b0cd63cb72b11d6ddc14e2838ca6f7da51cf391117e2c6cf56b4ebe7d0636abce3e6c472db13a61408be484f41eb06c92e1885aa154782c
|
data/.env.example
ADDED
data/.github/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @zendesk/narwhals @zendesk/walrus
|
@@ -0,0 +1,20 @@
|
|
1
|
+
cc: :whale2: @zendesk/billing
|
2
|
+
|
3
|
+
### Description
|
4
|
+
Describe what your changes are and what is the motivation behind them.
|
5
|
+
|
6
|
+
### Notes
|
7
|
+
Extra information (technical references, etc.) that you would like the reviewers
|
8
|
+
to be aware of.
|
9
|
+
|
10
|
+
### Tasks
|
11
|
+
- [ ] TODO item before it can be reviewed and/or merged
|
12
|
+
- [ ] Another TODO item
|
13
|
+
|
14
|
+
### References
|
15
|
+
- JIRA ticket or PR link
|
16
|
+
- Another JIRA ticket or PR link
|
17
|
+
|
18
|
+
### Risks
|
19
|
+
**High.** Because reasons. Use **High**, **Medium**, or **Low** to indicate risk
|
20
|
+
profile of the change.
|
data/.gitignore
CHANGED
data/.reek
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
---
|
2
|
+
|
3
|
+
# Exclude vendor/bundle directory for Travis
|
4
|
+
exclude_paths:
|
5
|
+
- vendor/bundle
|
6
|
+
|
7
|
+
Attribute:
|
8
|
+
exclude:
|
9
|
+
- IronBank#client
|
10
|
+
- IronBank#configuration
|
11
|
+
- IronBank::Configuration#auth_type
|
12
|
+
- IronBank::Configuration#cache
|
13
|
+
- IronBank::Configuration#client_id
|
14
|
+
- IronBank::Configuration#client_secret
|
15
|
+
- IronBank::Configuration#domain
|
16
|
+
- IronBank::Configuration#export_directory
|
17
|
+
- IronBank::Configuration#instrumenter
|
18
|
+
- IronBank::Configuration#instrumenter_options
|
19
|
+
- IronBank::Configuration#logger
|
20
|
+
- IronBank::Configuration#open_tracing_enabled
|
21
|
+
- IronBank::Configuration#open_tracing_service_name
|
22
|
+
- IronBank::Configuration#schema_directory
|
23
|
+
|
24
|
+
BooleanParameter:
|
25
|
+
exclude:
|
26
|
+
- IronBank::Cacheable::ClassMethods#find
|
27
|
+
|
28
|
+
DuplicateMethodCall:
|
29
|
+
exclude:
|
30
|
+
- IronBank::Utils#camelize
|
31
|
+
- IronBank::Local#all
|
32
|
+
|
33
|
+
FeatureEnvy:
|
34
|
+
exclude:
|
35
|
+
- IronBank::Client#connection
|
36
|
+
- IronBank::Authentications::Cookie#connection
|
37
|
+
- IronBank::Authentications::Token#connection
|
38
|
+
- IronBank::Configuration#schema_directory=
|
39
|
+
- IronBank::Resource#==
|
40
|
+
- IronBank::Object#camelize
|
41
|
+
- IronBank::Object#underscore
|
42
|
+
- IronBank::Actions::Subscribe#hash_args
|
43
|
+
- IronBank::Utils#camelize
|
44
|
+
|
45
|
+
IrresponsibleModule:
|
46
|
+
exclude:
|
47
|
+
- Sample
|
48
|
+
|
49
|
+
ManualDispatch:
|
50
|
+
exclude:
|
51
|
+
- IronBank::Resource#inspect
|
52
|
+
|
53
|
+
NestedIterators:
|
54
|
+
exclude:
|
55
|
+
- IronBank::Schema#self.import
|
56
|
+
- IronBank::Local#where
|
57
|
+
- IronBank::Local#load_records
|
58
|
+
- IronBank::Resources::ProductRatePlanChargeTier#self.load_records
|
59
|
+
|
60
|
+
NilCheck:
|
61
|
+
exclude:
|
62
|
+
- IronBank::Local#load_records
|
63
|
+
- IronBank::Resources::ProductRatePlanChargeTier#self.load_records
|
64
|
+
|
65
|
+
TooManyInstanceVariables:
|
66
|
+
max_instance_variables: 6
|
67
|
+
|
68
|
+
TooManyStatements:
|
69
|
+
exclude:
|
70
|
+
- IronBank::Associations::ClassMethods#with_many
|
71
|
+
- IronBank::Associations::ClassMethods#with_one
|
72
|
+
- IronBank::Authentications::Cookie#connection
|
73
|
+
- IronBank::Authentications::Token#connection
|
74
|
+
- IronBank::Client#connection
|
75
|
+
- IronBank::Configuration#schema_directory=
|
76
|
+
- IronBank::Configuration#initialize
|
77
|
+
- IronBank::Queryable#find_each
|
78
|
+
- IronBank::Queryable#where
|
79
|
+
- IronBank::Utils#camelize
|
80
|
+
- IronBank::Utils#underscore
|
81
|
+
- IronBank::Resources::ProductRatePlanChargeTier#self.load_records
|
82
|
+
- IronBank::Error#self.from_response
|
83
|
+
|
84
|
+
UtilityFunction:
|
85
|
+
exclude:
|
86
|
+
- IronBank::Cacheable::ClassMethods#cache
|
87
|
+
- IronBank::Object#convert
|
88
|
+
- IronBank::Object#camelize_array
|
89
|
+
- IronBank::Object#underscore_array
|
90
|
+
- IronBank::OpenTracing#open_tracing_enabled?
|
91
|
+
- IronBank::QueryBuilder#range_query_builder
|
92
|
+
- IronBank::Utils#lower_camelize
|
93
|
+
- IronBank::Utils#upper_camelize
|
94
|
+
- IronBank::Instrumentation#instrumenter
|
95
|
+
- IronBank::Instrumentation#instrumenter_options
|
data/.rspec
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
AllCops:
|
2
|
+
DisplayCopNames: true
|
3
|
+
DisplayStyleGuide: true
|
4
|
+
TargetRubyVersion: 2.3
|
5
|
+
|
6
|
+
Layout/DotPosition:
|
7
|
+
EnforcedStyle: trailing
|
8
|
+
|
9
|
+
Lint/UselessAssignment:
|
10
|
+
Exclude:
|
11
|
+
- bin/console
|
12
|
+
|
13
|
+
Metrics/AbcSize:
|
14
|
+
Exclude:
|
15
|
+
- lib/iron_bank/associations.rb
|
16
|
+
- lib/iron_bank/client.rb
|
17
|
+
|
18
|
+
Metrics/BlockLength:
|
19
|
+
Exclude:
|
20
|
+
- spec/**/*
|
21
|
+
- iron_bank.gemspec
|
22
|
+
|
23
|
+
Metrics/CyclomaticComplexity:
|
24
|
+
Exclude:
|
25
|
+
- lib/iron_bank/error.rb
|
26
|
+
|
27
|
+
Metrics/MethodLength:
|
28
|
+
Exclude:
|
29
|
+
- lib/iron_bank/utils.rb
|
30
|
+
- lib/iron_bank/associations.rb
|
31
|
+
- lib/iron_bank/queryable.rb
|
32
|
+
- lib/iron_bank/resources/product_rate_plan_charge_tier.rb
|
33
|
+
- lib/iron_bank/error.rb
|
34
|
+
- lib/iron_bank/client.rb
|
35
|
+
|
36
|
+
Metrics/LineLength:
|
37
|
+
Exclude:
|
38
|
+
- lib/iron_bank.rb
|
39
|
+
|
40
|
+
Style/ClassAndModuleChildren:
|
41
|
+
EnforcedStyle: nested
|
42
|
+
|
43
|
+
Style/OptionalArguments:
|
44
|
+
Exclude:
|
45
|
+
- lib/iron_bank/local.rb
|
46
|
+
- lib/iron_bank/queryable.rb
|
47
|
+
- lib/iron_bank/resource.rb
|
48
|
+
|
49
|
+
Style/RescueStandardError:
|
50
|
+
Exclude:
|
51
|
+
- lib/iron_bank/csv.rb
|
52
|
+
|
53
|
+
Style/MixinUsage:
|
54
|
+
Exclude:
|
55
|
+
- lib/iron_bank/resource.rb
|
data/.travis.yml
CHANGED
@@ -1,5 +1,24 @@
|
|
1
|
-
|
1
|
+
cache: bundler
|
2
|
+
|
2
3
|
language: ruby
|
4
|
+
|
3
5
|
rvm:
|
4
|
-
- 2.
|
5
|
-
|
6
|
+
- 2.2.9
|
7
|
+
- 2.3.5
|
8
|
+
- 2.4.4
|
9
|
+
- 2.5.1
|
10
|
+
|
11
|
+
sudo: false
|
12
|
+
|
13
|
+
branches:
|
14
|
+
only: master
|
15
|
+
|
16
|
+
before_install:
|
17
|
+
- gem update --system
|
18
|
+
- gem install bundler
|
19
|
+
|
20
|
+
env:
|
21
|
+
global:
|
22
|
+
- ZUORA_CLIENT_ID=something
|
23
|
+
- ZUORA_CLIENT_SECRET=secret
|
24
|
+
- ZUORA_DOMAIN=rest.apisandbox.zuora.com
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
# Specify your gem's dependencies in
|
5
|
+
# Specify your gem's dependencies in zuora.gemspec
|
6
6
|
gemspec
|
data/LICENSE
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
data/README.md
CHANGED
@@ -1,6 +1,139 @@
|
|
1
1
|
# Iron Bank
|
2
2
|
|
3
|
+
[![Build Status][travis-status]][travis-build]
|
4
|
+
|
5
|
+
An opinionated Ruby interface to the [Zuora REST API][zuora-dev].
|
6
|
+
|
3
7
|
> We who serve the Iron Bank face death full as often as you who serve the Iron
|
4
8
|
> Throne.
|
5
9
|
|
6
10
|
_(A Dance with Dragons, Chapter 44, Jon IX)_
|
11
|
+
|
12
|
+
This gem provides opinionated resources to interact with the Zuora API through
|
13
|
+
their REST interface. It defines **associations** between them, as well as a
|
14
|
+
simple **declaration API** (`with_one`, `with_many`) to extend them.
|
15
|
+
|
16
|
+
This gem is tested against Ruby `>= 2.2.9`.
|
17
|
+
|
18
|
+
Please use [GitHub Issues][issues] to report bugs.
|
19
|
+
|
20
|
+
## Getting Started
|
21
|
+
|
22
|
+
You will need:
|
23
|
+
|
24
|
+
- a **Zuora tenant** (apisandbox, services, performances or production)
|
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])
|
28
|
+
|
29
|
+
IronBank is a pure Ruby client, but we do provide a generator (for the
|
30
|
+
configuration) when using it within [Rails][rails-website].
|
31
|
+
|
32
|
+
Add the gem to your `Gemfile` with:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
gem 'iron_bank'
|
36
|
+
```
|
37
|
+
|
38
|
+
And run the `bundle` command to install it. You then need to run the generator:
|
39
|
+
|
40
|
+
```
|
41
|
+
$ rails generate iron_bank:install
|
42
|
+
```
|
43
|
+
|
44
|
+
Use the `client_id` and `client_secret` from your Zuora OAuth client and add
|
45
|
+
them to the generated `config/initializers/iron_bank.rb` file.
|
46
|
+
|
47
|
+
## Usage
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
# make a query to Zuora using ZOQL
|
51
|
+
IronBank::Query.call "select Name from Account where Id='zuora-account-id'"
|
52
|
+
|
53
|
+
# retrieve an account
|
54
|
+
account = IronBank::Account.find 'zuora-account-id'
|
55
|
+
# => #<IronBank::Resources::Account>
|
56
|
+
|
57
|
+
# access this resource attributes
|
58
|
+
account.name # => 'My Company Inc.'
|
59
|
+
|
60
|
+
# or associated objects
|
61
|
+
account.bill_to
|
62
|
+
# => #<IronBank::Resources::Contact>
|
63
|
+
|
64
|
+
account.active_subscriptions
|
65
|
+
# => [#<IronBank::Resources::Subscription>]
|
66
|
+
```
|
67
|
+
|
68
|
+
## Local records
|
69
|
+
|
70
|
+
If your product catalog does not change often, you may want to export
|
71
|
+
it locally so that product catalog and related object queries look for
|
72
|
+
**local records** first, then **fallback** to the API if no records are found.
|
73
|
+
|
74
|
+
You can export your product catalog locally using the `LocalRecords` class:
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
# Save CSV files in the directory specified by `config.export_directory`
|
78
|
+
IronBank::LocalRecords.export
|
79
|
+
```
|
80
|
+
|
81
|
+
Then, making a query/looking for a record will first search through the local
|
82
|
+
records, then default to the API if no records are found.
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
product = IronBank::Product.find 'zuora-product-id'
|
86
|
+
# => #<IronBank::Resources::Product>
|
87
|
+
|
88
|
+
product.plans[0].charges[0].tiers[0]
|
89
|
+
# => #<IronBank::Resources::ProductRatePlanChargeTier>
|
90
|
+
```
|
91
|
+
|
92
|
+
Without local records, the previous scenario will make **4 requests** to Zuora
|
93
|
+
to access the charge tiers. By exporting local records, you can significantly
|
94
|
+
reduce your execution time, e.g., when building a `SubscriptionRequest`.
|
95
|
+
|
96
|
+
## Development
|
97
|
+
|
98
|
+
1. After checking out the repo, run `bin/setup` to install dependencies
|
99
|
+
2. Edit the copied `.env` file with your Zuora credentials
|
100
|
+
3. Execute `bundle exec rake` to run the linters and tests
|
101
|
+
4. You can also run `bin/console` for an interactive prompt that will allow you
|
102
|
+
to experiment with the Zuora APIs
|
103
|
+
|
104
|
+
## Contributing
|
105
|
+
|
106
|
+
Bug reports and pull requests are welcome on GitHub at
|
107
|
+
https://github.com/zendesk/iron_bank.
|
108
|
+
|
109
|
+
## Known issues
|
110
|
+
|
111
|
+
- `AutoPay` field on the `Invoice` object is not queryable using ZOQL despite
|
112
|
+
the metadata showing `<selectable>true</selectable>`, hence it has been added
|
113
|
+
to the `exclude_fields` method.
|
114
|
+
|
115
|
+
|
116
|
+
## Copyright and license
|
117
|
+
|
118
|
+
Copyright 2018 Zendesk, Inc.
|
119
|
+
|
120
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
121
|
+
this file except in compliance with the License.
|
122
|
+
|
123
|
+
You may obtain a copy of the License at
|
124
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
125
|
+
|
126
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
127
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
128
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
129
|
+
specific language governing permissions and limitations under the License.
|
130
|
+
|
131
|
+
|
132
|
+
[issues]: https://github.com/zendesk/iron_bank/issues
|
133
|
+
[travis-status]: https://travis-ci.com/zendesk/iron_bank.svg?token=Qzkq5papoR7sdedznjeb&branch=master
|
134
|
+
[travis-build]: https://travis-ci.com/zendesk/iron_bank
|
135
|
+
[zuora-describe]: https://www.zuora.com/developer/api-reference/#tag/Describe
|
136
|
+
[zuora-dev]: https://developer.zuora.com
|
137
|
+
[zuora-doc-oauth]: https://knowledgecenter.zuora.com/CF_Users_and_Administrators/A_Administrator_Settings/Manage_Users#Create_an_OAuth_Client_for_a_User
|
138
|
+
[zuora-website]: https://www.zuora.com
|
139
|
+
[rails-website]: https://rubyonrails.org/
|
data/Rakefile
CHANGED
@@ -1,6 +1,42 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'reek/rake/task'
|
2
4
|
require 'rspec/core/rake_task'
|
5
|
+
require 'rubocop/rake_task'
|
6
|
+
require 'private_gem/tasks'
|
7
|
+
require 'bump/tasks'
|
8
|
+
|
9
|
+
Reek::Rake::Task.new do |reek|
|
10
|
+
reek.fail_on_error = true
|
11
|
+
end
|
12
|
+
|
13
|
+
RuboCop::RakeTask.new
|
14
|
+
|
15
|
+
RSpec::Core::RakeTask.new(:spec) do |rspec|
|
16
|
+
rspec.verbose = false
|
17
|
+
end
|
18
|
+
|
19
|
+
task test: :spec
|
20
|
+
|
21
|
+
task default: %i[rubocop reek spec]
|
22
|
+
|
23
|
+
desc 'Delete the VCR cassettes folder'
|
24
|
+
task :clean do
|
25
|
+
sh 'rm -rf spec/vcr'
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'Export the Zuora Schema using the Describe API'
|
29
|
+
task :export_schema do
|
30
|
+
require 'dotenv/load'
|
31
|
+
require 'iron_bank'
|
3
32
|
|
4
|
-
|
33
|
+
# Set up the client
|
34
|
+
IronBank.client = IronBank::Client.new(
|
35
|
+
domain: ENV['ZUORA_DOMAIN'],
|
36
|
+
client_id: ENV['ZUORA_CLIENT_ID'],
|
37
|
+
client_secret: ENV['ZUORA_CLIENT_SECRET'],
|
38
|
+
auth_type: ENV['ZUORA_AUTH_TYPE']
|
39
|
+
)
|
5
40
|
|
6
|
-
|
41
|
+
IronBank::Schema.export
|
42
|
+
end
|
data/bin/console
CHANGED
@@ -1,7 +1,19 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
4
|
+
require 'dotenv/load'
|
3
5
|
require 'bundler/setup'
|
4
6
|
require 'iron_bank'
|
5
|
-
require 'pry'
|
7
|
+
require 'pry-byebug'
|
8
|
+
|
9
|
+
credentials = {
|
10
|
+
domain: ENV['ZUORA_DOMAIN'],
|
11
|
+
client_id: ENV['ZUORA_CLIENT_ID'],
|
12
|
+
client_secret: ENV['ZUORA_CLIENT_SECRET'],
|
13
|
+
auth_type: ENV['ZUORA_AUTH_TYPE']
|
14
|
+
}
|
15
|
+
|
16
|
+
# If credentials are present in environment variables
|
17
|
+
IronBank.client = IronBank::Client.new(credentials) if credentials.values.all?
|
6
18
|
|
7
19
|
Pry.start
|
data/bin/setup
CHANGED