iron_bank 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.reek.yml +1 -0
- data/lib/iron_bank/local.rb +11 -4
- data/lib/iron_bank/local_records.rb +2 -1
- data/lib/iron_bank/metadata.rb +2 -2
- data/lib/iron_bank/queryable.rb +8 -6
- data/lib/iron_bank/resource.rb +2 -2
- data/lib/iron_bank/resources/invoice.rb +1 -1
- data/lib/iron_bank/resources/product_rate_plan_charge_tier.rb +4 -4
- data/lib/iron_bank/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8234b3d722f4748c284fd3d3e0a1e813e9f41835156937971cb8777e6fb3df94
|
4
|
+
data.tar.gz: 3009116645a7c107b0d046993d4b75df937f04c0ef68e6547fb5aebcff3ce873
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e327dc8139567cec93b02a5dce35bce8f83031f6481b78d6f021a4556415b3a1e2a04aeb789e49eca4e32c70efabb0759396ec276b5bba5337d99115b8c78adc
|
7
|
+
data.tar.gz: caaf42d97da52409e99c1f777a1b2b2f200a49728ad9aa3a4b0bf892ca6f1fac17ce67dbf29f109d4fb129161d1c116b36fb5d30a2a8bc09161f184e30e5c733
|
data/.reek.yml
CHANGED
data/lib/iron_bank/local.rb
CHANGED
@@ -43,18 +43,25 @@ module IronBank
|
|
43
43
|
# this line, delete the other one, since `Hash#compact` is available in
|
44
44
|
# 2.4.x and we can remove two smells from `.reek` while we are at it
|
45
45
|
#
|
46
|
-
# store[row[
|
47
|
-
store[row[
|
46
|
+
# store[row[:id]] = new(row.to_h.compact)
|
47
|
+
store[row[:id]] = new(row.to_h.reject { |_, value| value.nil? })
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
def csv_options
|
52
52
|
{
|
53
|
-
headers:
|
54
|
-
|
53
|
+
headers: true,
|
54
|
+
header_converters: header_converters,
|
55
|
+
converters: csv_converters
|
55
56
|
}
|
56
57
|
end
|
57
58
|
|
59
|
+
def header_converters
|
60
|
+
%i[
|
61
|
+
symbol
|
62
|
+
]
|
63
|
+
end
|
64
|
+
|
58
65
|
def csv_converters
|
59
66
|
%i[
|
60
67
|
decimal_integer
|
data/lib/iron_bank/metadata.rb
CHANGED
@@ -28,8 +28,8 @@ module IronBank
|
|
28
28
|
|
29
29
|
def with_schema
|
30
30
|
fields.each do |field|
|
31
|
-
|
32
|
-
define_method(:"#{
|
31
|
+
field_name = IronBank::Utils.underscore(field).to_sym
|
32
|
+
define_method(:"#{field_name}") { remote[field_name] }
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/lib/iron_bank/queryable.rb
CHANGED
@@ -8,9 +8,11 @@ module IronBank
|
|
8
8
|
def find(id)
|
9
9
|
raise IronBank::NotFound unless id
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
response = IronBank.client.connection.get(
|
12
|
+
"v1/object/#{object_name}/#{id}"
|
13
13
|
)
|
14
|
+
|
15
|
+
new(IronBank::Object.new(response.body).deep_underscore)
|
14
16
|
end
|
15
17
|
|
16
18
|
# This methods leverages the fact that Zuora only returns 2,000 records at a
|
@@ -23,10 +25,10 @@ module IronBank
|
|
23
25
|
query_result = client.query(query_string) # up to 2k records from Zuora
|
24
26
|
|
25
27
|
loop do
|
26
|
-
query_result[
|
27
|
-
break if query_result[
|
28
|
+
query_result[:records].each { |data| yield new(data) }
|
29
|
+
break if query_result[:done]
|
28
30
|
|
29
|
-
query_result = client.query_more(query_result[
|
31
|
+
query_result = client.query_more(query_result[:queryLocator])
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
@@ -44,7 +46,7 @@ module IronBank
|
|
44
46
|
# FIXME: need to use logger instance instead
|
45
47
|
# puts "query: #{query_string}"
|
46
48
|
|
47
|
-
records = IronBank::Query.call(query_string)[
|
49
|
+
records = IronBank::Query.call(query_string)[:records]
|
48
50
|
return [] unless records
|
49
51
|
|
50
52
|
records.each.with_object([]) do |data, result|
|
data/lib/iron_bank/resource.rb
CHANGED
@@ -31,7 +31,7 @@ module IronBank
|
|
31
31
|
# Every Zuora object has an ID, so we can safely declare it for each
|
32
32
|
# resource
|
33
33
|
def id
|
34
|
-
remote[
|
34
|
+
remote[:id]
|
35
35
|
end
|
36
36
|
|
37
37
|
def inspect
|
@@ -56,7 +56,7 @@ module IronBank
|
|
56
56
|
|
57
57
|
def to_csv_row
|
58
58
|
self.class.fields.each.with_object([]) do |field, row|
|
59
|
-
row << remote[field]
|
59
|
+
row << remote[IronBank::Utils.underscore(field).to_sym]
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -30,7 +30,7 @@ module IronBank
|
|
30
30
|
# We can only retrieve one invoice body at a time, hence Body is excluded
|
31
31
|
# from the query fields, but is populated using the `find` class method
|
32
32
|
def body
|
33
|
-
remote[
|
33
|
+
remote[:body] || reload[:body]
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -36,7 +36,7 @@ module IronBank
|
|
36
36
|
# discount-fixed amount and regular pricing).
|
37
37
|
def to_csv_row
|
38
38
|
ProductRatePlanChargeTier.fields.each.with_object([]) do |field, row|
|
39
|
-
row << remote[field]
|
39
|
+
row << remote[IronBank::Utils.underscore(field).to_sym]
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -44,15 +44,15 @@ module IronBank
|
|
44
44
|
CSV.foreach(file_path, csv_options).with_object({}) do |row, store|
|
45
45
|
remote = row.to_h.reject { |_, value| value.nil? }
|
46
46
|
|
47
|
-
record = if remote[
|
47
|
+
record = if remote[:discount_amount]
|
48
48
|
CatalogTiers::DiscountAmount.new(remote)
|
49
|
-
elsif remote[
|
49
|
+
elsif remote[:discount_percentage]
|
50
50
|
CatalogTiers::DiscountPercentage.new(remote)
|
51
51
|
else
|
52
52
|
CatalogTiers::Price.new(remote)
|
53
53
|
end
|
54
54
|
|
55
|
-
store[row[
|
55
|
+
store[row[:id]] = record
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
data/lib/iron_bank/version.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: 2.0.
|
4
|
+
version: 2.0.1
|
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: 2018-12-
|
14
|
+
date: 2018-12-21 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bump
|
@@ -380,7 +380,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
380
380
|
version: '0'
|
381
381
|
requirements: []
|
382
382
|
rubyforge_project:
|
383
|
-
rubygems_version: 2.
|
383
|
+
rubygems_version: 2.7.8
|
384
384
|
signing_key:
|
385
385
|
specification_version: 4
|
386
386
|
summary: An opinionated Ruby interface to the Zuora API.
|