iron_bank 4.2.0 → 4.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: c43b87965a20a054d039009a4da852974532dc4b079b8ceb20d6ec9849a00eb3
4
- data.tar.gz: a23c602da14f5bcfcf1ed9cc9dcece5a21dc083c7d941c63e444870c3384dfb4
2
+ SHA1:
3
+ metadata.gz: 83c23241ccd3c9228badb707b4f12c031f3d338d
4
+ data.tar.gz: 142aa1b442282003b63012e58d418c8d6dce6ca0
5
5
  SHA512:
6
- metadata.gz: e026432778a617ffebe80df42f2fde537a85be17682d34c8f451b8e3548d0d149c74d35c386d7bc038da6bbde18515688e662d582e82ff9a1249853e3a7136d4
7
- data.tar.gz: 8b7ec698f0e0ecf5a19db78d246980ce117abdaae68dbc67bf5572fd98d366fe48160be8ae35ad17e9db609cbe1798f58828104e4dfae4a7fda0e677abd87637
6
+ metadata.gz: 010ba8a30e6918ea5d13c6df9bba5860811c4fd14d940a2a1eee89a3c2028029aa1af33771b9eec14b969deef3b68019ec725b95f902af7f27054de510111053
7
+ data.tar.gz: d3ba4a439cbf0b307d6cd178f1f0c7a82de78545c47c65212f61759f690c135cd2ef62a150b501c0f7efa6b70f9c99567da4dfc5ba4797db774aef45d35bd35b
@@ -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
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:
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- iron_bank (4.2.0)
4
+ iron_bank (4.4.3)
5
5
  faraday (~> 0)
6
6
  faraday_middleware (~> 0)
7
7
  nokogiri (~> 1)
@@ -35,9 +35,9 @@ GEM
35
35
  equalizer (0.0.11)
36
36
  factory_bot (5.0.2)
37
37
  activesupport (>= 4.2.0)
38
- faraday (0.15.4)
38
+ faraday (0.17.3)
39
39
  multipart-post (>= 1.2, < 3)
40
- faraday_middleware (0.13.1)
40
+ faraday_middleware (0.14.0)
41
41
  faraday (>= 0.7.4, < 1.0)
42
42
  i18n (1.6.0)
43
43
  concurrent-ruby (~> 1.0)
@@ -49,7 +49,7 @@ GEM
49
49
  mini_portile2 (2.4.0)
50
50
  minitest (5.11.3)
51
51
  multipart-post (2.1.1)
52
- nokogiri (1.10.4)
52
+ nokogiri (1.10.10)
53
53
  mini_portile2 (~> 2.4.0)
54
54
  parallel (1.17.0)
55
55
  parser (2.6.3.0)
@@ -130,4 +130,4 @@ DEPENDENCIES
130
130
  timecop (~> 0.9)
131
131
 
132
132
  BUNDLED WITH
133
- 2.0.2
133
+ 2.1.4
@@ -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
@@ -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"
@@ -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"
@@ -7,7 +7,7 @@ module IronBank
7
7
  private_class_method :new
8
8
 
9
9
  PRODUCTION = /\Arest\.zuora\.com\z/i.freeze
10
- SERVICES = /\Aservices(\d+)\.zuora\.com(:\d+)?\z/i.freeze
10
+ SERVICES = /\A(rest)?services(\d+)\.zuora\.com(:\d+)?\z/i.freeze
11
11
  APISANDBOX = /\Arest.apisandbox.zuora\.com\z/i.freeze
12
12
 
13
13
  def self.base_url(domain = "")
@@ -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
@@ -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 = "4.4.3"
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: 4.4.3
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-08-27 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bump
@@ -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
@@ -351,7 +352,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
351
352
  - !ruby/object:Gem::Version
352
353
  version: '0'
353
354
  requirements: []
354
- rubygems_version: 3.0.6
355
+ rubyforge_project:
356
+ rubygems_version: 2.6.14.4
355
357
  signing_key:
356
358
  specification_version: 4
357
359
  summary: An opinionated Ruby interface to the Zuora API.