embulk-input-stripe 0.1.0 → 0.2.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/lib/embulk/input/stripe.rb +6 -1
- data/lib/embulk/input/stripe/charges.rb +10 -0
- data/lib/embulk/input/stripe/stripe_items.rb +16 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dec6b8863fd51c494e86648eee325183181cbfe
|
4
|
+
data.tar.gz: 04053c6698600553235ceaed3fba204da86e455d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5e78a9a6dacc71c2906dfd75cbc6705637fd357bf8dca8787796959ff04c68fe4209f9bb96e03bf12dad9075884e3a609a69b2425ad6ec37cd9b021fb05bff8
|
7
|
+
data.tar.gz: 1a06f0b0ae36bc069cc635924a59f4c45b377487e691d9a7d3e13b2c1ebb189c15551191f0ec843f662fc0497135fb67a92ab6ec3398fb7a69a1cecd5898b669
|
data/lib/embulk/input/stripe.rb
CHANGED
@@ -4,6 +4,7 @@ require 'stripe'
|
|
4
4
|
require_relative 'stripe/customers'
|
5
5
|
require_relative 'stripe/invoices'
|
6
6
|
require_relative 'stripe/subscriptions'
|
7
|
+
require_relative 'stripe/charges'
|
7
8
|
|
8
9
|
module Embulk
|
9
10
|
module Input
|
@@ -22,7 +23,7 @@ module Embulk
|
|
22
23
|
columns = fields.map.with_index do |field, index|
|
23
24
|
field_name = field['name']
|
24
25
|
field_type = field['type'].to_sym
|
25
|
-
Column.new(index, field_name.gsub(
|
26
|
+
Column.new(index, field_name.gsub(/[\.\[\]]+/, '_'), field_type)
|
26
27
|
end
|
27
28
|
|
28
29
|
resume(task, columns, 1, &control)
|
@@ -47,6 +48,8 @@ module Embulk
|
|
47
48
|
@invoices = Invoices.new(fields)
|
48
49
|
when 'subscriptions'
|
49
50
|
@subscriptions = Subscriptions.new(fields)
|
51
|
+
when 'charges'
|
52
|
+
@charges = Charges.new(fields)
|
50
53
|
else
|
51
54
|
raise StandardError, "Resource type #{resource_type} is not supported."
|
52
55
|
end
|
@@ -60,6 +63,8 @@ module Embulk
|
|
60
63
|
@invoices
|
61
64
|
when 'subscriptions'
|
62
65
|
@subscriptions
|
66
|
+
when 'charges'
|
67
|
+
@charges
|
63
68
|
end
|
64
69
|
|
65
70
|
target_items.get.each do |item|
|
@@ -3,6 +3,9 @@
|
|
3
3
|
require 'embulk/column'
|
4
4
|
|
5
5
|
class StripeItems
|
6
|
+
BEFORE_BRACKET_REGEX = Regexp.compile(/^([^\[]+)/)
|
7
|
+
INDEX_REGEX = Regexp.compile(/\[([0-9]+)\]/)
|
8
|
+
|
6
9
|
def initialize(fields)
|
7
10
|
@fields = fields
|
8
11
|
end
|
@@ -27,7 +30,19 @@ class StripeItems
|
|
27
30
|
# Drill down into sub items (assumes fields are delimited with '.').
|
28
31
|
sub_fields = field['name'].split('.')
|
29
32
|
sub_fields.reduce(sub) do |memo, sub_field|
|
30
|
-
|
33
|
+
name_match = BEFORE_BRACKET_REGEX.match(sub_field)
|
34
|
+
before_bracket = name_match[1]
|
35
|
+
|
36
|
+
child = memo[before_bracket]
|
37
|
+
|
38
|
+
index_match = INDEX_REGEX.match(sub_field)
|
39
|
+
|
40
|
+
if index_match
|
41
|
+
index = index_match[1]
|
42
|
+
child[index.to_i]
|
43
|
+
else
|
44
|
+
child
|
45
|
+
end
|
31
46
|
end
|
32
47
|
end
|
33
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-stripe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daisuke Shimamoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -46,6 +46,7 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- lib/embulk/input/stripe.rb
|
49
|
+
- lib/embulk/input/stripe/charges.rb
|
49
50
|
- lib/embulk/input/stripe/customers.rb
|
50
51
|
- lib/embulk/input/stripe/invoices.rb
|
51
52
|
- lib/embulk/input/stripe/stripe_items.rb
|