iron_bank 4.2.0 → 5.0.0

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
  SHA256:
3
- metadata.gz: c43b87965a20a054d039009a4da852974532dc4b079b8ceb20d6ec9849a00eb3
4
- data.tar.gz: a23c602da14f5bcfcf1ed9cc9dcece5a21dc083c7d941c63e444870c3384dfb4
3
+ metadata.gz: 456e503d0ff6a9b1213bc8111b02f49502c01b2448d65006c6cbed9d78a28234
4
+ data.tar.gz: 564b5542ad7f12be3a5ae7afc310c22827125b3c67861fb997a5c705c5bb0f34
5
5
  SHA512:
6
- metadata.gz: e026432778a617ffebe80df42f2fde537a85be17682d34c8f451b8e3548d0d149c74d35c386d7bc038da6bbde18515688e662d582e82ff9a1249853e3a7136d4
7
- data.tar.gz: 8b7ec698f0e0ecf5a19db78d246980ce117abdaae68dbc67bf5572fd98d366fe48160be8ae35ad17e9db609cbe1798f58828104e4dfae4a7fda0e677abd87637
6
+ metadata.gz: 2d2131d770bf910f786c257dbf57c9fa4eeb250e57b862424046eb6ede0ee11bd24854be8692b25169cf2785f9c88b3967783b4a48720965c3475ed8aef52ac9
7
+ data.tar.gz: b0416ab3fcd57700c3b180c9ab51191bd9e3ee2f4874f109c7622ed1de20a7eb93c2e84710c1408d4fad908b7020eb3786c46a9475d14415dfaed919537a5f4a
@@ -4,3 +4,4 @@ ZUORA_AUTH_TYPE=token
4
4
  ZUORA_DOMAIN=rest.apisandbox.zuora.com
5
5
  ZUORA_TENANT_ID=00000
6
6
  ZUORA_EXCLUDED_FIELDS_FILE=excluded_fields.yml
7
+ ZUORA_USERS_FILE=users.csv
@@ -0,0 +1,49 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ branches:
9
+ - master
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
+
22
+ runs-on: ubuntu-latest
23
+
24
+ steps:
25
+ - uses: zendesk/checkout@v2
26
+
27
+ - uses: zendesk/setup-ruby@v1
28
+ with:
29
+ ruby-version: ${{ matrix.ruby }}
30
+
31
+ - uses: zendesk/cache@v2
32
+ with:
33
+ path: vendor/bundle
34
+ key: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }}
35
+ restore-keys: |
36
+ ${{ runner.os }}-gems-
37
+
38
+ - name: Install Dependencies
39
+ run: |
40
+ bundle config deployment true
41
+ bundle config path vendor/bundle
42
+ bundle install --jobs 4
43
+
44
+ - name: Run Tests
45
+ run: bundle exec rake
46
+ env:
47
+ ZUORA_CLIENT_ID: something
48
+ ZUORA_CLIENT_SECRET: secret
49
+ ZUORA_DOMAIN: rest.apisandbox.zuora.com
data/.gitignore CHANGED
@@ -18,3 +18,6 @@
18
18
 
19
19
  # do not version specific excluded fields
20
20
  excluded_fields.yml
21
+
22
+ # do not version exported users
23
+ users.csv
data/.reek.yml CHANGED
@@ -18,6 +18,7 @@ detectors:
18
18
  - IronBank::Configuration#logger
19
19
  - IronBank::Configuration#middlewares
20
20
  - IronBank::Configuration#schema_directory
21
+ - IronBank::Configuration#users_file
21
22
 
22
23
  BooleanParameter:
23
24
  exclude:
@@ -3,15 +3,32 @@ require: rubocop-performance
3
3
  AllCops:
4
4
  DisplayCopNames: true
5
5
  DisplayStyleGuide: true
6
- TargetRubyVersion: 2.4
7
6
 
8
7
  Layout/DotPosition:
9
8
  EnforcedStyle: trailing
10
9
 
11
- Layout/AlignHash:
10
+ Layout/EmptyLinesAroundAttributeAccessor:
11
+ Enabled: true
12
+
13
+ Layout/HashAlignment:
12
14
  EnforcedHashRocketStyle: table
13
15
  EnforcedColonStyle: table
14
16
 
17
+ Layout/SpaceAroundMethodCallOperator:
18
+ Enabled: true
19
+
20
+ Lint/DeprecatedOpenSSLConstant:
21
+ Enabled: true
22
+
23
+ Lint/MixedRegexpCaptureTypes:
24
+ Enabled: true
25
+
26
+ Lint/RaiseException:
27
+ Enabled: true
28
+
29
+ Lint/StructNewOverride:
30
+ Enabled: true
31
+
15
32
  Lint/UselessAssignment:
16
33
  Exclude:
17
34
  - bin/console
@@ -39,10 +56,6 @@ Metrics/MethodLength:
39
56
  - lib/iron_bank/error.rb
40
57
  - lib/iron_bank/client.rb
41
58
 
42
- Metrics/LineLength:
43
- Exclude:
44
- - lib/iron_bank.rb
45
-
46
59
  Style/ClassAndModuleChildren:
47
60
  EnforcedStyle: nested
48
61
 
@@ -50,12 +63,33 @@ Style/MixinUsage:
50
63
  Exclude:
51
64
  - lib/iron_bank/resource.rb
52
65
 
66
+ Style/StringLiterals:
67
+ EnforcedStyle: double_quotes
68
+
69
+ Style/ExponentialNotation:
70
+ Enabled: true
71
+
72
+ Style/HashEachMethods:
73
+ Enabled: true
74
+
75
+ Style/HashTransformKeys:
76
+ Enabled: true
77
+
78
+ Style/HashTransformValues:
79
+ Enabled: true
80
+
53
81
  Style/OptionalArguments:
54
82
  Exclude:
55
83
  - lib/iron_bank/local.rb
56
84
  - lib/iron_bank/queryable.rb
57
85
  - lib/iron_bank/resource.rb
58
86
 
87
+ Style/RedundantRegexpCharacterClass:
88
+ Enabled: true
89
+
90
+ Style/RedundantRegexpEscape:
91
+ Enabled: true
92
+
59
93
  Style/RegexpLiteral:
60
94
  Exclude:
61
95
  - lib/iron_bank/describe/excluded_fields.rb
@@ -64,5 +98,5 @@ Style/RescueStandardError:
64
98
  Exclude:
65
99
  - lib/iron_bank/csv.rb
66
100
 
67
- Style/StringLiterals:
68
- EnforcedStyle: double_quotes
101
+ Style/SlicingWithRange:
102
+ Enabled: true
@@ -1 +1 @@
1
- 2.4.6
1
+ 2.5.8
@@ -1,114 +1,101 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- iron_bank (4.2.0)
5
- faraday (~> 0)
6
- faraday_middleware (~> 0)
4
+ iron_bank (5.0.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 (5.2.3)
12
+ activesupport (6.0.3.1)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
14
  i18n (>= 0.7, < 2)
15
15
  minitest (~> 5.1)
16
16
  tzinfo (~> 1.1)
17
+ zeitwerk (~> 2.2, >= 2.2.2)
17
18
  ast (2.4.0)
18
- axiom-types (0.1.1)
19
- descendants_tracker (~> 0.0.4)
20
- ice_nine (~> 0.11.0)
21
- thread_safe (~> 0.3, >= 0.3.1)
22
- bump (0.8.0)
23
- byebug (11.0.1)
24
- codeclimate-engine-rb (0.4.1)
25
- virtus (~> 1.0)
26
- coderay (1.1.2)
27
- coercible (1.0.0)
28
- descendants_tracker (~> 0.0.1)
29
- concurrent-ruby (1.1.5)
30
- descendants_tracker (0.0.4)
31
- thread_safe (~> 0.3, >= 0.3.1)
19
+ bump (0.9.0)
20
+ byebug (11.1.3)
21
+ coderay (1.1.3)
22
+ concurrent-ruby (1.1.6)
32
23
  diff-lcs (1.3)
33
24
  docile (1.3.2)
34
25
  dotenv (2.7.5)
35
- equalizer (0.0.11)
36
- factory_bot (5.0.2)
26
+ factory_bot (5.2.0)
37
27
  activesupport (>= 4.2.0)
38
- faraday (0.15.4)
28
+ faraday (1.0.1)
39
29
  multipart-post (>= 1.2, < 3)
40
- faraday_middleware (0.13.1)
41
- faraday (>= 0.7.4, < 1.0)
42
- i18n (1.6.0)
30
+ faraday_middleware (1.0.0)
31
+ faraday (~> 1.0)
32
+ i18n (1.8.2)
43
33
  concurrent-ruby (~> 1.0)
44
- ice_nine (0.11.2)
45
- jaro_winkler (1.5.3)
46
- json (2.2.0)
47
34
  kwalify (0.7.2)
48
- method_source (0.9.2)
35
+ method_source (1.0.0)
49
36
  mini_portile2 (2.4.0)
50
- minitest (5.11.3)
37
+ minitest (5.14.1)
51
38
  multipart-post (2.1.1)
52
- nokogiri (1.10.4)
39
+ nokogiri (1.10.9)
53
40
  mini_portile2 (~> 2.4.0)
54
- parallel (1.17.0)
55
- parser (2.6.3.0)
41
+ parallel (1.19.1)
42
+ parser (2.7.1.3)
56
43
  ast (~> 2.4.0)
57
- pry (0.12.2)
58
- coderay (~> 1.1.0)
59
- method_source (~> 0.9.0)
60
- pry-byebug (3.7.0)
44
+ pry (0.13.1)
45
+ coderay (~> 1.1)
46
+ method_source (~> 1.0)
47
+ pry-byebug (3.9.0)
61
48
  byebug (~> 11.0)
62
- pry (~> 0.10)
49
+ pry (~> 0.13.0)
63
50
  psych (3.1.0)
64
51
  rainbow (3.0.0)
65
- rake (12.3.3)
66
- reek (5.4.0)
67
- codeclimate-engine-rb (~> 0.4.0)
52
+ rake (13.0.1)
53
+ reek (6.0.1)
68
54
  kwalify (~> 0.7.0)
69
- parser (>= 2.5.0.0, < 2.7, != 2.5.1.1)
55
+ parser (>= 2.5.0.0, < 2.8, != 2.5.1.1)
70
56
  psych (~> 3.1.0)
71
57
  rainbow (>= 2.0, < 4.0)
72
- rspec (3.8.0)
73
- rspec-core (~> 3.8.0)
74
- rspec-expectations (~> 3.8.0)
75
- rspec-mocks (~> 3.8.0)
76
- rspec-core (3.8.2)
77
- rspec-support (~> 3.8.0)
78
- rspec-expectations (3.8.4)
58
+ regexp_parser (1.7.0)
59
+ rexml (3.2.4)
60
+ rspec (3.9.0)
61
+ rspec-core (~> 3.9.0)
62
+ rspec-expectations (~> 3.9.0)
63
+ rspec-mocks (~> 3.9.0)
64
+ rspec-core (3.9.2)
65
+ rspec-support (~> 3.9.3)
66
+ rspec-expectations (3.9.2)
79
67
  diff-lcs (>= 1.2.0, < 2.0)
80
- rspec-support (~> 3.8.0)
81
- rspec-mocks (3.8.1)
68
+ rspec-support (~> 3.9.0)
69
+ rspec-mocks (3.9.1)
82
70
  diff-lcs (>= 1.2.0, < 2.0)
83
- rspec-support (~> 3.8.0)
84
- rspec-support (3.8.2)
85
- rubocop (0.74.0)
86
- jaro_winkler (~> 1.5.1)
71
+ rspec-support (~> 3.9.0)
72
+ rspec-support (3.9.3)
73
+ rubocop (0.85.0)
87
74
  parallel (~> 1.10)
88
- parser (>= 2.6)
75
+ parser (>= 2.7.0.1)
89
76
  rainbow (>= 2.2.2, < 4.0)
77
+ regexp_parser (>= 1.7)
78
+ rexml
79
+ rubocop-ast (>= 0.0.3)
90
80
  ruby-progressbar (~> 1.7)
91
- unicode-display_width (>= 1.4.0, < 1.7)
92
- rubocop-performance (1.4.1)
81
+ unicode-display_width (>= 1.4.0, < 2.0)
82
+ rubocop-ast (0.0.3)
83
+ parser (>= 2.7.0.1)
84
+ rubocop-performance (1.6.0)
93
85
  rubocop (>= 0.71.0)
94
86
  ruby-progressbar (1.10.1)
95
- shoulda-matchers (4.1.2)
87
+ shoulda-matchers (4.3.0)
96
88
  activesupport (>= 4.2.0)
97
- simplecov (0.17.0)
89
+ simplecov (0.18.5)
98
90
  docile (~> 1.1)
99
- json (>= 1.8, < 3)
100
- simplecov-html (~> 0.10.0)
101
- simplecov-html (0.10.2)
91
+ simplecov-html (~> 0.11)
92
+ simplecov-html (0.12.2)
102
93
  thread_safe (0.3.6)
103
94
  timecop (0.9.1)
104
- tzinfo (1.2.5)
95
+ tzinfo (1.2.7)
105
96
  thread_safe (~> 0.1)
106
- unicode-display_width (1.6.0)
107
- virtus (1.0.5)
108
- axiom-types (~> 0.1)
109
- coercible (~> 1.0)
110
- descendants_tracker (~> 0.0, >= 0.0.3)
111
- equalizer (~> 0.0, >= 0.0.9)
97
+ unicode-display_width (1.7.0)
98
+ zeitwerk (2.3.0)
112
99
 
113
100
  PLATFORMS
114
101
  ruby
@@ -120,8 +107,8 @@ DEPENDENCIES
120
107
  factory_bot (~> 5.0)
121
108
  iron_bank!
122
109
  pry-byebug (~> 3.4)
123
- rake (~> 12.0)
124
- reek (~> 5.0)
110
+ rake (~> 13.0)
111
+ reek (~> 6.0)
125
112
  rspec (~> 3.0)
126
113
  rubocop (~> 0.67)
127
114
  rubocop-performance (~> 1.0)
@@ -130,4 +117,4 @@ DEPENDENCIES
130
117
  timecop (~> 0.9)
131
118
 
132
119
  BUNDLED WITH
133
- 2.0.2
120
+ 2.1.4
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Iron Bank
2
2
 
3
- [![Build Status][travis-status]][travis-build]
3
+ ![CI](https://github.com/zendesk/iron_bank/workflows/CI/badge.svg?branch=master)
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.4`.
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
- it locally so that product catalog and related object queries look for
94
- **local records** first, then **fallback** to the API if no records are found.
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]: https://knowledgecenter.zuora.com/CF_Users_and_Administrators/A_Administrator_Settings/Manage_Users#Create_an_OAuth_Client_for_a_User
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/
@@ -12,6 +12,7 @@ IronBank.configure do |config|
12
12
  config.auth_type = ENV.fetch("ZUORA_AUTH_TYPE", "token")
13
13
  config.domain = ENV["ZUORA_DOMAIN"]
14
14
  config.excluded_fields_file = ENV["ZUORA_EXCLUDED_FIELDS_FILE"]
15
+ config.users_file = ENV["ZUORA_USERS_FILE"]
15
16
  end
16
17
 
17
18
  Pry.start
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  "mturan@zendesk.com"
20
20
  ]
21
21
 
22
- spec.required_ruby_version = ">= 2.4"
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)/})
@@ -34,8 +34,8 @@ Gem::Specification.new do |spec|
34
34
  spec.add_development_dependency "dotenv", "~> 2.2"
35
35
  spec.add_development_dependency "factory_bot", "~> 5.0"
36
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"
37
+ spec.add_development_dependency "rake", "~> 13.0"
38
+ spec.add_development_dependency "reek", "~> 6.0"
39
39
  spec.add_development_dependency "rspec", "~> 3.0"
40
40
  spec.add_development_dependency "rubocop", "~> 0.67"
41
41
  spec.add_development_dependency "rubocop-performance", "~> 1.0"
@@ -43,7 +43,7 @@ Gem::Specification.new do |spec|
43
43
  spec.add_development_dependency "simplecov", "~> 0.15"
44
44
  spec.add_development_dependency "timecop", "~> 0.9"
45
45
 
46
- spec.add_runtime_dependency "faraday", "~> 0"
47
- spec.add_runtime_dependency "faraday_middleware", "~> 0"
46
+ spec.add_runtime_dependency "faraday", "~> 1"
47
+ spec.add_runtime_dependency "faraday_middleware", "~> 1"
48
48
  spec.add_runtime_dependency "nokogiri", "~> 1"
49
49
  end
@@ -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
@@ -88,6 +88,7 @@ require "iron_bank/object"
88
88
  require "iron_bank/schema"
89
89
  require "iron_bank/query_builder"
90
90
  require "iron_bank/payment_run"
91
+ require "iron_bank/user"
91
92
 
92
93
  # Operations
93
94
  require "iron_bank/operation"
@@ -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)
@@ -17,7 +17,7 @@ module IronBank
17
17
  end
18
18
 
19
19
  def create_session
20
- @session = adapter.new(params)
20
+ @session = adapter.new(**params)
21
21
  end
22
22
  alias renew_session create_session
23
23
 
@@ -43,7 +43,7 @@ module IronBank
43
43
  alias refetch_cookie fetch_cookie
44
44
 
45
45
  def fetch_zsession
46
- /ZSession=([^\;]+)/.match(cookie)[0]
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
@@ -9,6 +9,7 @@ module IronBank
9
9
  def_delegators :@records,
10
10
  :[],
11
11
  :each,
12
+ :empty?,
12
13
  :length,
13
14
  :map,
14
15
  :size
@@ -34,6 +34,9 @@ module IronBank
34
34
  # Directory where the local records are exported.
35
35
  attr_reader :export_directory
36
36
 
37
+ # File path for Zuora users export
38
+ attr_accessor :users_file
39
+
37
40
  def initialize
38
41
  @schema_directory = "./config/schema"
39
42
  @export_directory = "./config/export"
@@ -60,7 +63,7 @@ module IronBank
60
63
  @export_directory = value
61
64
  return unless defined? IronBank::Product
62
65
 
63
- IronBank::LocalRecords::RESOURCE_QUERY_FIELDS.keys.each do |resource|
66
+ IronBank::LocalRecords::RESOURCE_QUERY_FIELDS.each_key do |resource|
64
67
  IronBank::Resources.const_get(resource).reset_store
65
68
  end
66
69
  end
@@ -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.
@@ -55,7 +55,7 @@ module IronBank
55
55
  end
56
56
 
57
57
  def load_records
58
- CSV.foreach(file_path, csv_options).with_object({}) do |row, store|
58
+ CSV.foreach(file_path, **csv_options).with_object({}) do |row, store|
59
59
  store[row[:id]] = new(row.to_h.compact)
60
60
  end
61
61
  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.keys.each { |resource| new(resource).save_file }
22
+ RESOURCE_QUERY_FIELDS.each_key { |resource| new(resource).save_file }
23
23
  end
24
24
 
25
25
  def save_file
@@ -5,12 +5,14 @@ module IronBank
5
5
  # A rate plan charge belongs to a subscription rate plan.
6
6
  #
7
7
  class RatePlanCharge < Resource
8
+ extend Gem::Deprecate
9
+
8
10
  def self.excluded_fields
9
11
  super + single_resource_query_fields
10
12
  end
11
13
 
12
14
  def self.single_resource_query_fields
13
- %w[RolloverBalance]
15
+ %w[RolloverBalance Price]
14
16
  end
15
17
 
16
18
  with_schema
@@ -25,6 +27,21 @@ module IronBank
25
27
  def rollover_balance
26
28
  remote[:rollover_balance] || reload.remote[:rollover_balance]
27
29
  end
30
+
31
+ # NOTE: #price was only available when (1) the pricing model for the
32
+ # charge is either "Flat Fee" or "Per Unit" AND (2) the charge was
33
+ # queried through ZOQL, i.e, using `IronBank::Charge#where` method.
34
+ #
35
+ # Testing Zuora REST API (using the `IronBank::Charge#find` method)
36
+ # shows that Zuora does not return a `price` attribute in their
37
+ # response. This means we consider #price to be a remain from the
38
+ # SOAP ZOQL query operation. We are deprecating this method without
39
+ # replacement. Instead, users should be fetching the `#tiers` for
40
+ # the current charge and get the price information from there.
41
+ def price
42
+ nil
43
+ end
44
+ deprecate :price, :none, 2020, 1
28
45
  end
29
46
  end
30
47
  end
@@ -49,12 +49,10 @@ module IronBank
49
49
 
50
50
  def export
51
51
  tenant.objects.compact.each do |object|
52
- begin
53
- object.export
54
- rescue IronBank::Describe::Object::InvalidXML
55
- # TODO: log the object error
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
 
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ module IronBank
4
+ # A Zuora user, only available if the user data has been exported and provided
5
+ # to IronBank through the `users_file` configuration option.
6
+ #
7
+ # Cf. https://knowledgecenter.zuora.com/CF_Users_and_Administrators/A_Administrator_Settings/Manage_Users#Export_User_Data_to_a_CSV_File
8
+ #
9
+ class User
10
+ extend IronBank::Local
11
+ extend SingleForwardable
12
+
13
+ def_delegators "IronBank.configuration", :users_file
14
+
15
+ class << self
16
+ def store
17
+ return {} unless users_file
18
+
19
+ @store ||= begin
20
+ if File.exist?(users_file)
21
+ load_records
22
+ else
23
+ IronBank.logger.warn "File does not exist: #{users_file}"
24
+ {}
25
+ end
26
+ end
27
+ end
28
+
29
+ def load_records
30
+ CSV.foreach(users_file, headers: true).with_object({}) do |row, store|
31
+ store[row["User ID"]] = new(row.to_h.compact)
32
+ end
33
+ end
34
+
35
+ def all
36
+ store.values
37
+ end
38
+
39
+ def find(user_id)
40
+ store[user_id] || raise(IronBank::NotFoundError, "user id: #{user_id}")
41
+ end
42
+ end
43
+
44
+ US_DATE_FORMAT = "%m/%d/%Y"
45
+
46
+ FIELDS = [
47
+ "User ID",
48
+ "User Name",
49
+ "First Name",
50
+ "Last Name",
51
+ "Status",
52
+ "Work Email",
53
+ "Created On",
54
+ "Zuora Billing Role",
55
+ "Zuora Payment Role",
56
+ "Zuora Commerce Role",
57
+ "Zuora Platform Role",
58
+ "Zuora Finance Role",
59
+ "Zuora Reporting Role",
60
+ "Zuora Insights Role",
61
+ "Last Login"
62
+ ].freeze
63
+
64
+ FIELDS.each do |field|
65
+ method_name = IronBank::Utils.underscore(field.tr(" ", ""))
66
+
67
+ define_method(method_name) do
68
+ attributes[field]
69
+ end
70
+ end
71
+
72
+ attr_reader :attributes
73
+
74
+ alias id user_id
75
+
76
+ def initialize(attributes)
77
+ @attributes = attributes
78
+ end
79
+
80
+ def inspect
81
+ ruby_id = "#{self.class.name}:0x#{(object_id << 1).to_s(16)} id=\"#{id}\""
82
+
83
+ "#<#{ruby_id} user_name=\"#{user_name}\">"
84
+ end
85
+
86
+ def last_login
87
+ @last_login ||= Date.strptime(attributes["Last Login"], US_DATE_FORMAT)
88
+ end
89
+
90
+ def created_on
91
+ @created_on ||= Date.strptime(attributes["Created On"], US_DATE_FORMAT)
92
+ end
93
+ end
94
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IronBank
4
- VERSION = "4.2.0"
4
+ VERSION = "5.0.0"
5
5
  API_VERSION = "v1"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iron_bank
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mickael Pham
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2019-09-19 00:00:00.000000000 Z
14
+ date: 2020-06-15 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bump
@@ -89,28 +89,28 @@ dependencies:
89
89
  requirements:
90
90
  - - "~>"
91
91
  - !ruby/object:Gem::Version
92
- version: '12.0'
92
+ version: '13.0'
93
93
  type: :development
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
97
  - - "~>"
98
98
  - !ruby/object:Gem::Version
99
- version: '12.0'
99
+ version: '13.0'
100
100
  - !ruby/object:Gem::Dependency
101
101
  name: reek
102
102
  requirement: !ruby/object:Gem::Requirement
103
103
  requirements:
104
104
  - - "~>"
105
105
  - !ruby/object:Gem::Version
106
- version: '5.0'
106
+ version: '6.0'
107
107
  type: :development
108
108
  prerelease: false
109
109
  version_requirements: !ruby/object:Gem::Requirement
110
110
  requirements:
111
111
  - - "~>"
112
112
  - !ruby/object:Gem::Version
113
- version: '5.0'
113
+ version: '6.0'
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: rspec
116
116
  requirement: !ruby/object:Gem::Requirement
@@ -201,28 +201,28 @@ dependencies:
201
201
  requirements:
202
202
  - - "~>"
203
203
  - !ruby/object:Gem::Version
204
- version: '0'
204
+ version: '1'
205
205
  type: :runtime
206
206
  prerelease: false
207
207
  version_requirements: !ruby/object:Gem::Requirement
208
208
  requirements:
209
209
  - - "~>"
210
210
  - !ruby/object:Gem::Version
211
- version: '0'
211
+ version: '1'
212
212
  - !ruby/object:Gem::Dependency
213
213
  name: faraday_middleware
214
214
  requirement: !ruby/object:Gem::Requirement
215
215
  requirements:
216
216
  - - "~>"
217
217
  - !ruby/object:Gem::Version
218
- version: '0'
218
+ version: '1'
219
219
  type: :runtime
220
220
  prerelease: false
221
221
  version_requirements: !ruby/object:Gem::Requirement
222
222
  requirements:
223
223
  - - "~>"
224
224
  - !ruby/object:Gem::Version
225
- version: '0'
225
+ version: '1'
226
226
  - !ruby/object:Gem::Dependency
227
227
  name: nokogiri
228
228
  requirement: !ruby/object:Gem::Requirement
@@ -250,12 +250,12 @@ files:
250
250
  - ".env.example"
251
251
  - ".github/CODEOWNERS"
252
252
  - ".github/PULL_REQUEST_TEMPLATE.md"
253
+ - ".github/workflows/ci.yml"
253
254
  - ".gitignore"
254
255
  - ".reek.yml"
255
256
  - ".rspec"
256
257
  - ".rubocop.yml"
257
258
  - ".ruby-version"
258
- - ".travis.yml"
259
259
  - Gemfile
260
260
  - Gemfile.lock
261
261
  - LICENSE
@@ -330,6 +330,7 @@ files:
330
330
  - lib/iron_bank/resources/taxation_item.rb
331
331
  - lib/iron_bank/resources/usage.rb
332
332
  - lib/iron_bank/schema.rb
333
+ - lib/iron_bank/user.rb
333
334
  - lib/iron_bank/utils.rb
334
335
  - lib/iron_bank/version.rb
335
336
  homepage: https://github.com/zendesk/iron_bank
@@ -344,14 +345,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
344
345
  requirements:
345
346
  - - ">="
346
347
  - !ruby/object:Gem::Version
347
- version: '2.4'
348
+ version: '2.5'
348
349
  required_rubygems_version: !ruby/object:Gem::Requirement
349
350
  requirements:
350
351
  - - ">="
351
352
  - !ruby/object:Gem::Version
352
353
  version: '0'
353
354
  requirements: []
354
- rubygems_version: 3.0.6
355
+ rubygems_version: 3.1.3
355
356
  signing_key:
356
357
  specification_version: 4
357
358
  summary: An opinionated Ruby interface to the Zuora API.
@@ -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