iron_bank 4.2.0 → 4.3.0
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 +4 -4
- data/.env.example +1 -0
- data/.gitignore +3 -0
- data/.reek.yml +1 -0
- data/Gemfile.lock +1 -1
- data/bin/console +1 -0
- data/lib/iron_bank/configuration.rb +3 -0
- data/lib/iron_bank/user.rb +94 -0
- data/lib/iron_bank/version.rb +1 -1
- data/lib/iron_bank.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00c270266ed85615c32706b617a644cfac0d954a3fc19117733d0a4d1a4a4687
|
4
|
+
data.tar.gz: aad4d425eabc0f6ecdcdec124d00913f471edd2ff431b3c18b8fbfce2ff9ee37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c74322d9de788d46d9137e8d32435163d1543c5a2d71d7b90ce9b2328df22b4ccd452af557e0692b5af1c15537f00e4045a21b916d0cd76a6dbcf2d98249d8f
|
7
|
+
data.tar.gz: 80640919d22b8114f60edff018fb234757ecf4f971166d7beb3a077c1d17a610861994d6b1f4f7abf31ab268e1f4f77be47abf8387420132d5ea4cbae2e75bd0
|
data/.env.example
CHANGED
data/.gitignore
CHANGED
data/.reek.yml
CHANGED
data/Gemfile.lock
CHANGED
data/bin/console
CHANGED
@@ -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
|
@@ -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"
|
@@ -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
|
data/lib/iron_bank/version.rb
CHANGED
data/lib/iron_bank.rb
CHANGED
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.
|
4
|
+
version: 4.3.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-
|
14
|
+
date: 2019-09-20 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
|