ledger_sync-stripe 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: eec806004e5aa1758aa84d2ca9363a3e1e9f369c2b58288a0e3d730635018717
4
+ data.tar.gz: 69db7ed2e7ee88fb5108ece2fa15acc441799da07ec8077de2dea811f95ef7a4
5
+ SHA512:
6
+ metadata.gz: '0285175ceab0d0558f631f6aecc98cc143153e6115ddbd5a938ee720b20ed5577c9931c361595f84d6b6366d8a130f14c9f0ee6cc271c4c850374c9f216eab8c'
7
+ data.tar.gz: c37c2dd3b0ad1750b314f3a7c1a4284048c05c73c15dfa1b006ebd3ec26bf7b1402af83b9c30ad7738a350b2c8b4b1eebccab6d776c21c43194599dd0136f4a2
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -0,0 +1 @@
1
+ STRIPE_API_KEY=STRIPE_API_KEY
@@ -0,0 +1,21 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp
9
+
10
+ # byebug
11
+ .byebug_history
12
+
13
+ # Mac
14
+ .DS_Store
15
+
16
+ # dotenv
17
+ .env
18
+ *.local
19
+
20
+ .tool-versions
21
+ .ruby-version
@@ -0,0 +1,29 @@
1
+ # Use this file to configure the Overcommit hooks you wish to use. This will
2
+ # extend the default configuration defined in:
3
+ # https://github.com/sds/overcommit/blob/master/config/default.yml
4
+ #
5
+ # At the topmost level of this YAML file is a key representing type of hook
6
+ # being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
7
+ # customize each hook, such as whether to only run it on certain files (via
8
+ # `include`), whether to only display output if it fails (via `quiet`), etc.
9
+ #
10
+ # For a complete list of hooks, see:
11
+ # https://github.com/sds/overcommit/tree/master/lib/overcommit/hook
12
+ #
13
+ # For a complete list of options that you can use to customize hooks, see:
14
+ # https://github.com/sds/overcommit#configuration
15
+ #
16
+ # Uncomment the following lines to make the configuration take effect.
17
+ gemfile: Gemfile
18
+
19
+ PreCommit:
20
+ RuboCop:
21
+ command: ['bundle', 'exec', 'rubocop']
22
+ enabled: true
23
+ on_warn: fail # Treat all warnings as failures
24
+
25
+ TrailingWhitespace:
26
+ enabled: true
27
+
28
+ LineEndings:
29
+ enabled: true
@@ -0,0 +1,78 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.5.8
5
+ NewCops: enable
6
+
7
+ Layout/LineLength:
8
+ Enabled: True
9
+ Max: 120
10
+
11
+ Style/HashEachMethods:
12
+ Enabled: True
13
+
14
+ Style/HashTransformKeys:
15
+ Enabled: True
16
+
17
+ Style/HashTransformValues:
18
+ Enabled: True
19
+
20
+ Layout/EmptyLinesAroundAttributeAccessor:
21
+ Enabled: True
22
+
23
+ Layout/SpaceAroundMethodCallOperator:
24
+ Enabled: True
25
+
26
+ Lint/DeprecatedOpenSSLConstant:
27
+ Enabled: True
28
+
29
+ Lint/DuplicateElsifCondition:
30
+ Enabled: True
31
+
32
+ Lint/MixedRegexpCaptureTypes:
33
+ Enabled: True
34
+
35
+ Lint/RaiseException:
36
+ Enabled: True
37
+
38
+ Lint/StructNewOverride:
39
+ Enabled: True
40
+
41
+ Style/AccessorGrouping:
42
+ Enabled: True
43
+
44
+ Style/ArrayCoercion:
45
+ Enabled: True
46
+
47
+ Style/BisectedAttrAccessor:
48
+ Enabled: True
49
+
50
+ Style/CaseLikeIf:
51
+ Enabled: True
52
+
53
+ Style/ExponentialNotation:
54
+ Enabled: True
55
+
56
+ Style/HashAsLastArrayItem:
57
+ Enabled: True
58
+
59
+ Style/HashLikeCase:
60
+ Enabled: True
61
+
62
+ Style/RedundantAssignment:
63
+ Enabled: True
64
+
65
+ Style/RedundantFetchBlock:
66
+ Enabled: True
67
+
68
+ Style/RedundantFileExtensionInRequire:
69
+ Enabled: True
70
+
71
+ Style/RedundantRegexpCharacterClass:
72
+ Enabled: True
73
+
74
+ Style/RedundantRegexpEscape:
75
+ Enabled: True
76
+
77
+ Style/SlicingWithRange:
78
+ Enabled: False
@@ -0,0 +1,25 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2019-03-29 13:21:38 +0100 using RuboCop version 0.66.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ Metrics/AbcSize:
10
+ Enabled: False
11
+
12
+ Metrics/BlockLength:
13
+ Enabled: False
14
+
15
+ Metrics/ClassLength:
16
+ Enabled: False
17
+
18
+ Metrics/MethodLength:
19
+ Enabled: False
20
+
21
+ Metrics/ParameterLists:
22
+ Enabled: False
23
+
24
+ Style/Documentation:
25
+ Enabled: False
@@ -0,0 +1,26 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 2.5.8
5
+ - 2.6.6
6
+ - 2.6.3
7
+ - 2.7.1
8
+ - ruby-head
9
+ before_install:
10
+ - gem update --system
11
+ - gem install bundler
12
+ - rm Gemfile.lock
13
+ - bundle install
14
+ script:
15
+ - bundle exec rspec --order rand
16
+ - bundle exec overcommit --sign && bundle exec overcommit --run
17
+ jobs:
18
+ allow_failures:
19
+ - rvm: ruby-head
20
+ deploy:
21
+ - api_key:
22
+ secure: b7Ubc7/+EX4zHJ5zz15xiHntizhuZCU8SKR/jcbrR86wZx1DW8kIABBoVIHMh5CaMvrjF63B1qEoG4HcuovKZWezFLPgj4IQqlwlUle0/Vm0smO1kPMEOuMIv5P3TTgXZ99h1OdnfRQtDgbjxgKGszawMxNcw9Q8mqvVCc8Pmr+Uiw9DOOkHNMfLH+xOl00Ir9ST+K4/GKq19h8Z3glZE0oQAPajt5kgDZdDGD3en+t2g3kafJ9Hv6twKSb5rd5I9BN+VJ0m66OofGxnZFUxM/cb8T+s+6DdPXGWJq4IZ/q9SO108qfl1aTd7EiFa+hVtlLii7QaSMHARrbWT3wMYH3QhgTBPly8Dky92c74ziLkqaDdaxmGfYnzLDVCRVlGmGzUkOLx1ey9XK2kwSods+ud8rJ2pHWaT7NQROzTD4O0YhLHvEAoN6PwtIWm1v78OViBng36PKW0WtAE1rG9CEK1FjhA7ZZoctAsKqSaXWZR39+0xgSv+1axLXru/TG8QLqKNEOgNbE5lqR7sF2cVQgmmUstlMqiEgKMF0cFWWVi1wqR6VNxrgwgWeWtwzHLkchY6T3vhK9sl+cUM6SebfCOCAJHPBxSvHRHtJcrDY8qMqjlfFBSagjaClFt1Uzy//ab4XRzEs8VQcVkz9Yw7S51iOYBdj6135lfE0ZxE1c=
23
+ edge: true
24
+ on:
25
+ all_branches: true
26
+ provider: rubygems
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in ledger_sync-stripe.gemspec
8
+ gemspec
@@ -0,0 +1,234 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ledger_sync-stripe (0.1.0)
5
+ dotenv
6
+ ledger_sync
7
+ nokogiri
8
+ oauth2
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activemodel (6.0.3.4)
14
+ activesupport (= 6.0.3.4)
15
+ activesupport (6.0.3.4)
16
+ concurrent-ruby (~> 1.0, >= 1.0.2)
17
+ i18n (>= 0.7, < 2)
18
+ minitest (~> 5.1)
19
+ tzinfo (~> 1.1)
20
+ zeitwerk (~> 2.2, >= 2.2.2)
21
+ addressable (2.7.0)
22
+ public_suffix (>= 2.0.2, < 5.0)
23
+ akami (1.3.1)
24
+ gyoku (>= 0.4.0)
25
+ nokogiri
26
+ ast (2.4.1)
27
+ awesome_print (1.8.0)
28
+ builder (3.2.4)
29
+ bump (0.9.0)
30
+ byebug (11.1.3)
31
+ childprocess (4.0.0)
32
+ climate_control (0.2.0)
33
+ colorize (0.8.1)
34
+ concurrent-ruby (1.1.7)
35
+ coveralls (0.8.23)
36
+ json (>= 1.8, < 3)
37
+ simplecov (~> 0.16.1)
38
+ term-ansicolor (~> 1.3)
39
+ thor (>= 0.19.4, < 2.0)
40
+ tins (~> 1.6)
41
+ crack (0.4.4)
42
+ diff-lcs (1.4.4)
43
+ docile (1.3.2)
44
+ dotenv (2.7.6)
45
+ dry-configurable (0.11.6)
46
+ concurrent-ruby (~> 1.0)
47
+ dry-core (~> 0.4, >= 0.4.7)
48
+ dry-equalizer (~> 0.2)
49
+ dry-container (0.7.2)
50
+ concurrent-ruby (~> 1.0)
51
+ dry-configurable (~> 0.1, >= 0.1.3)
52
+ dry-core (0.4.9)
53
+ concurrent-ruby (~> 1.0)
54
+ dry-equalizer (0.3.0)
55
+ dry-inflector (0.2.0)
56
+ dry-initializer (3.0.4)
57
+ dry-logic (1.0.8)
58
+ concurrent-ruby (~> 1.0)
59
+ dry-core (~> 0.2)
60
+ dry-equalizer (~> 0.2)
61
+ dry-schema (1.5.6)
62
+ concurrent-ruby (~> 1.0)
63
+ dry-configurable (~> 0.8, >= 0.8.3)
64
+ dry-core (~> 0.4)
65
+ dry-equalizer (~> 0.2)
66
+ dry-initializer (~> 3.0)
67
+ dry-logic (~> 1.0)
68
+ dry-types (~> 1.4)
69
+ dry-types (1.4.0)
70
+ concurrent-ruby (~> 1.0)
71
+ dry-container (~> 0.3)
72
+ dry-core (~> 0.4, >= 0.4.4)
73
+ dry-equalizer (~> 0.3)
74
+ dry-inflector (~> 0.1, >= 0.1.2)
75
+ dry-logic (~> 1.0, >= 1.0.2)
76
+ dry-validation (1.5.6)
77
+ concurrent-ruby (~> 1.0)
78
+ dry-container (~> 0.7, >= 0.7.1)
79
+ dry-core (~> 0.4)
80
+ dry-equalizer (~> 0.2)
81
+ dry-initializer (~> 3.0)
82
+ dry-schema (~> 1.5, >= 1.5.2)
83
+ factory_bot (6.1.0)
84
+ activesupport (>= 5.0.0)
85
+ faraday (1.1.0)
86
+ multipart-post (>= 1.2, < 3)
87
+ ruby2_keywords
88
+ faraday-detailed_logger (2.3.0)
89
+ faraday (>= 0.8, < 2)
90
+ faraday_middleware (1.0.0)
91
+ faraday (~> 1.0)
92
+ fingerprintable (1.2.1)
93
+ colorize
94
+ gyoku (1.3.1)
95
+ builder (>= 2.1.2)
96
+ hashdiff (1.0.1)
97
+ httpi (2.4.5)
98
+ rack
99
+ socksify
100
+ i18n (1.8.5)
101
+ concurrent-ruby (~> 1.0)
102
+ iniparse (1.5.0)
103
+ json (2.3.1)
104
+ jwt (2.2.2)
105
+ ledger_sync (1.6.0)
106
+ activemodel
107
+ colorize
108
+ dry-schema (~> 1.5.4)
109
+ dry-validation (~> 1.5.6)
110
+ faraday
111
+ faraday-detailed_logger
112
+ faraday_middleware
113
+ fingerprintable (>= 1.2.1)
114
+ netsuite (~> 0.8.6)
115
+ nokogiri
116
+ oauth2
117
+ pd_ruby
118
+ resonad
119
+ simply_serializable (>= 1.5.1)
120
+ stripe (~> 5.26.0)
121
+ mini_portile2 (2.4.0)
122
+ minitest (5.14.2)
123
+ multi_json (1.15.0)
124
+ multi_xml (0.6.0)
125
+ multipart-post (2.1.1)
126
+ netsuite (0.8.6)
127
+ savon (>= 2.3.0, <= 2.11.1)
128
+ nokogiri (1.10.10)
129
+ mini_portile2 (~> 2.4.0)
130
+ nori (2.6.0)
131
+ oauth2 (1.4.4)
132
+ faraday (>= 0.8, < 2.0)
133
+ jwt (>= 1.0, < 3.0)
134
+ multi_json (~> 1.3)
135
+ multi_xml (~> 0.5)
136
+ rack (>= 1.2, < 3)
137
+ overcommit (0.57.0)
138
+ childprocess (>= 0.6.3, < 5)
139
+ iniparse (~> 1.4)
140
+ parallel (1.19.2)
141
+ parser (2.7.2.0)
142
+ ast (~> 2.4.1)
143
+ pd_ruby (0.2.3)
144
+ colorize
145
+ public_suffix (4.0.6)
146
+ rack (2.2.3)
147
+ rainbow (3.0.0)
148
+ rake (13.0.1)
149
+ regexp_parser (1.8.2)
150
+ resonad (1.3.0)
151
+ rexml (3.2.4)
152
+ rspec (3.10.0)
153
+ rspec-core (~> 3.10.0)
154
+ rspec-expectations (~> 3.10.0)
155
+ rspec-mocks (~> 3.10.0)
156
+ rspec-core (3.10.0)
157
+ rspec-support (~> 3.10.0)
158
+ rspec-expectations (3.10.0)
159
+ diff-lcs (>= 1.2.0, < 2.0)
160
+ rspec-support (~> 3.10.0)
161
+ rspec-mocks (3.10.0)
162
+ diff-lcs (>= 1.2.0, < 2.0)
163
+ rspec-support (~> 3.10.0)
164
+ rspec-support (3.10.0)
165
+ rubocop (1.2.0)
166
+ parallel (~> 1.10)
167
+ parser (>= 2.7.1.5)
168
+ rainbow (>= 2.2.2, < 4.0)
169
+ regexp_parser (>= 1.8)
170
+ rexml
171
+ rubocop-ast (>= 1.0.1)
172
+ ruby-progressbar (~> 1.7)
173
+ unicode-display_width (>= 1.4.0, < 2.0)
174
+ rubocop-ast (1.1.1)
175
+ parser (>= 2.7.1.5)
176
+ ruby-progressbar (1.10.1)
177
+ ruby2_keywords (0.0.2)
178
+ savon (2.11.1)
179
+ akami (~> 1.2)
180
+ builder (>= 2.1.2)
181
+ gyoku (~> 1.2)
182
+ httpi (~> 2.3)
183
+ nokogiri (>= 1.4.0)
184
+ nori (~> 2.4)
185
+ wasabi (~> 3.4)
186
+ simplecov (0.16.1)
187
+ docile (~> 1.1)
188
+ json (>= 1.8, < 3)
189
+ simplecov-html (~> 0.10.0)
190
+ simplecov-html (0.10.2)
191
+ simply_serializable (1.5.1)
192
+ fingerprintable (>= 1.2.1)
193
+ socksify (1.7.1)
194
+ stripe (5.26.0)
195
+ sync (0.5.0)
196
+ term-ansicolor (1.7.1)
197
+ tins (~> 1.0)
198
+ thor (1.0.1)
199
+ thread_safe (0.3.6)
200
+ tins (1.26.0)
201
+ sync
202
+ tzinfo (1.2.7)
203
+ thread_safe (~> 0.1)
204
+ unicode-display_width (1.7.0)
205
+ wasabi (3.6.1)
206
+ addressable
207
+ httpi (~> 2.0)
208
+ nokogiri (>= 1.4.2)
209
+ webmock (3.9.4)
210
+ addressable (>= 2.3.6)
211
+ crack (>= 0.3.2)
212
+ hashdiff (>= 0.4.0, < 2.0.0)
213
+ zeitwerk (2.4.1)
214
+
215
+ PLATFORMS
216
+ ruby
217
+
218
+ DEPENDENCIES
219
+ awesome_print
220
+ bump (~> 0.9.0)
221
+ bundler (~> 2.1)
222
+ byebug
223
+ climate_control
224
+ coveralls (~> 0.8.23)
225
+ factory_bot (~> 6.1.0)
226
+ ledger_sync-stripe!
227
+ overcommit (~> 0.57.0)
228
+ rake (~> 13.0)
229
+ rspec (~> 3.2)
230
+ rubocop
231
+ webmock
232
+
233
+ BUNDLED WITH
234
+ 2.1.4
@@ -0,0 +1,26 @@
1
+ # LedgerSync::Stripe
2
+
3
+ [![Coverage Status](https://coveralls.io/repos/github/LedgerSync/ledger_sync-stripe/badge.svg?branch=master)](https://coveralls.io/github/LedgerSync/ledger_sync-stripe?branch=master)
4
+
5
+
6
+ [ledgersync.dev](www.ledgersync.dev)
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'ledger_sync-stripe'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install ledger_sync-stripe
23
+
24
+ ## Usage
25
+
26
+ Please visit [ledgersync.dev](www.ledgersync.dev) for full documentation, guidelines, and contribution help.
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'ledger_sync/stripe'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'ledger_sync/stripe/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'ledger_sync-stripe'
9
+ spec.version = LedgerSync::Stripe::VERSION
10
+ spec.authors = ['Modern Treasury']
11
+ spec.email = ['ledgersync@moderntreasury.com']
12
+
13
+ spec.required_ruby_version = '>= 2.5.8'
14
+
15
+ spec.summary = 'Sync common objects to accounting software.'
16
+ spec.description = 'LedgerSync is a simple library that allows you to sync common objects to popular accounting '\
17
+ 'software like QuickBooks Online, Stripe, NetSuite, etc.'
18
+ spec.homepage = 'https://www.ledgersync.dev'
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ spec.bindir = 'exe'
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ['lib']
28
+
29
+ spec.add_development_dependency('awesome_print', '>= 0')
30
+ spec.add_development_dependency('bump', '~> 0.9.0')
31
+ spec.add_development_dependency('bundler', '~> 2.1')
32
+ spec.add_development_dependency('byebug')
33
+ spec.add_development_dependency('climate_control')
34
+ spec.add_development_dependency('coveralls', '~> 0.8.23')
35
+ spec.add_development_dependency('factory_bot', '~> 6.1.0')
36
+ spec.add_development_dependency('overcommit', '~> 0.57.0')
37
+ spec.add_development_dependency('rake', '~> 13.0')
38
+ spec.add_development_dependency('rspec', '~> 3.2')
39
+ spec.add_development_dependency('rubocop', '>= 0')
40
+ spec.add_development_dependency('webmock', '>= 0')
41
+ spec.add_runtime_dependency('dotenv')
42
+ spec.add_runtime_dependency('ledger_sync')
43
+ spec.add_runtime_dependency('nokogiri', '>= 0')
44
+ spec.add_runtime_dependency('oauth2', '>= 0')
45
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ledger_sync'
4
+
5
+ module LedgerSync
6
+ module Stripe
7
+ def self.root(*paths)
8
+ File.join(File.expand_path('../..', __dir__), *paths.map(&:to_s))
9
+ end
10
+ end
11
+ end
12
+
13
+ require_relative 'stripe/config'
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'oauth2'
4
+
5
+ module LedgerSync
6
+ module Stripe
7
+ class Client
8
+ include Ledgers::Client::Mixin
9
+
10
+ attr_reader :api_key
11
+
12
+ def initialize(
13
+ api_key:
14
+ )
15
+ @api_key = api_key
16
+
17
+ super()
18
+ end
19
+
20
+ def url_for(resource:)
21
+ DashboardURLHelper.new(
22
+ resource: resource,
23
+ base_url: 'https://dashboard.stripe.com'
24
+ ).url
25
+ end
26
+
27
+ def wrap_perform
28
+ ::Stripe.api_key = api_key
29
+ yield
30
+ ensure
31
+ ::Stripe.api_key = nil
32
+ end
33
+
34
+ def self.ledger_attributes_to_save
35
+ []
36
+ end
37
+
38
+ def self.new_from_env(**override)
39
+ new(
40
+ {
41
+ api_key: ENV.fetch('STRIPE_API_KEY', nil)
42
+ }.merge(override)
43
+ )
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'client'
4
+
5
+ opts = {
6
+ base_module: LedgerSync::Stripe,
7
+ root_path: 'ledger_sync/stripe'
8
+ }
9
+
10
+ LedgerSync.register_ledger(:stripe, opts) do |config|
11
+ config.name = 'Stripe'
12
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module Stripe
5
+ class Customer
6
+ module Operations
7
+ class Create < Stripe::Operation::Create
8
+ class Contract < LedgerSync::Ledgers::Contract
9
+ params do
10
+ required(:external_id).maybe(:string)
11
+ required(:ledger_id).value(:nil)
12
+ required(:email).maybe(:string)
13
+ required(:name).filled(:string)
14
+ required(:phone_number).maybe(:string)
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def operate
21
+ stripe_customer = ::Stripe::Customer.create(
22
+ email: resource.email,
23
+ metadata: {
24
+ external_id: resource.external_id
25
+ },
26
+ name: resource.name,
27
+ phone: resource.phone_number
28
+ )
29
+
30
+ resource.ledger_id = stripe_customer.id
31
+
32
+ success(
33
+ resource: resource,
34
+ response: stripe_customer
35
+ )
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module Stripe
5
+ class Customer
6
+ module Operations
7
+ class Delete < Stripe::Operation::Delete
8
+ class Contract < LedgerSync::Ledgers::Contract
9
+ params do
10
+ required(:external_id).maybe(:string)
11
+ required(:ledger_id).filled(:string)
12
+ required(:email).maybe(:string)
13
+ required(:name).maybe(:string)
14
+ required(:phone_number).maybe(:string)
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def operate
21
+ stripe_customer = ::Stripe::Customer.delete(resource.ledger_id)
22
+
23
+ success(
24
+ resource: resource,
25
+ response: stripe_customer
26
+ )
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module Stripe
5
+ class Customer
6
+ module Operations
7
+ class Find < Stripe::Operation::Find
8
+ class Contract < LedgerSync::Ledgers::Contract
9
+ params do
10
+ required(:external_id).maybe(:string)
11
+ required(:ledger_id).filled(:string)
12
+ optional(:email).maybe(:string)
13
+ optional(:name).maybe(:string)
14
+ optional(:phone_number).maybe(:string)
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def operate
21
+ stripe_customer = ::Stripe::Customer.retrieve(
22
+ resource.ledger_id
23
+ )
24
+
25
+ resource.external_id = stripe_customer.metadata['external_id']
26
+ resource.email = stripe_customer.email
27
+ resource.name = stripe_customer.name
28
+ resource.phone_number = stripe_customer.phone
29
+
30
+ resource.ledger_id = stripe_customer.id
31
+
32
+ success(
33
+ resource: resource,
34
+ response: stripe_customer
35
+ )
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module Stripe
5
+ class Customer
6
+ module Operations
7
+ class Update < Stripe::Operation::Update
8
+ class Contract < LedgerSync::Ledgers::Contract
9
+ params do
10
+ required(:external_id).maybe(:string)
11
+ required(:ledger_id).value(:string)
12
+ required(:email).maybe(:string)
13
+ required(:name).filled(:string)
14
+ required(:phone_number).maybe(:string)
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def operate
21
+ stripe_customer = ::Stripe::Customer.update(
22
+ resource.ledger_id,
23
+ email: resource.email,
24
+ metadata: {
25
+ external_id: resource.external_id
26
+ },
27
+ name: resource.name,
28
+ phone: resource.phone_number
29
+ )
30
+
31
+ success(
32
+ resource: resource,
33
+ response: stripe_customer
34
+ )
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module Stripe
5
+ class DashboardURLHelper < LedgerSync::Ledgers::DashboardURLHelper
6
+ def resource_path
7
+ @resource_path = case resource
8
+ when Stripe::Customer
9
+ "/customers/#{resource.ledger_id}"
10
+ else
11
+ raise Error::LedgerError::UnknownURLFormat.new(
12
+ client: self,
13
+ resource: resource
14
+ )
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module Stripe
5
+ class Deserializer < LedgerSync::Deserializer
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module Stripe
5
+ class Operation
6
+ module Mixin
7
+ def self.included(base)
8
+ base.include Ledgers::Operation::Mixin
9
+ base.include InstanceMethods # To ensure these override parent methods
10
+ end
11
+
12
+ module InstanceMethods
13
+ def stripe_resource_type
14
+ @stripe_resource_type ||= serializer.class.stripe_resource_type
15
+ end
16
+
17
+ def perform
18
+ client.wrap_perform do
19
+ super
20
+ end
21
+ rescue ::Stripe::StripeError => e
22
+ case e.code
23
+ when 'resource_missing'
24
+ failure(e)
25
+ else
26
+ raise e
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../operation'
4
+
5
+ module LedgerSync
6
+ module Stripe
7
+ class Operation
8
+ class Create
9
+ include Stripe::Operation::Mixin
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../operation'
4
+
5
+ module LedgerSync
6
+ module Stripe
7
+ class Operation
8
+ class Delete
9
+ include Stripe::Operation::Mixin
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../operation'
4
+
5
+ module LedgerSync
6
+ module Stripe
7
+ class Operation
8
+ class Find
9
+ include Stripe::Operation::Mixin
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../operation'
4
+
5
+ module LedgerSync
6
+ module Stripe
7
+ class Operation
8
+ class Update
9
+ include Stripe::Operation::Mixin
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module Stripe
5
+ class Resource < LedgerSync::Resource
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module Stripe
5
+ class Customer < Stripe::Resource
6
+ attribute :email, type: LedgerSync::Type::String
7
+ attribute :name, type: LedgerSync::Type::String
8
+ attribute :phone_number, type: LedgerSync::Type::String
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module Stripe
5
+ class Serializer < LedgerSync::Serializer
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nocov:
4
+ module LedgerSync
5
+ module Stripe
6
+ VERSION = '0.1.0'
7
+
8
+ def self.version(args = {})
9
+ pre = args.fetch(:pre, false)
10
+
11
+ if !pre && (!ENV['TRAVIS'] || ENV.fetch('TRAVIS_TAG', '') != '')
12
+ VERSION
13
+ else
14
+ "#{VERSION}.pre.#{ENV['TRAVIS_BUILD_NUMBER']}"
15
+ end
16
+ end
17
+ end
18
+ end
19
+ # :nocov:
metadata ADDED
@@ -0,0 +1,299 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ledger_sync-stripe
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Modern Treasury
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-11-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: awesome_print
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bump
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: climate_control
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.8.23
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.8.23
97
+ - !ruby/object:Gem::Dependency
98
+ name: factory_bot
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 6.1.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 6.1.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: overcommit
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.57.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.57.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: rake
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '13.0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '13.0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '3.2'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '3.2'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: webmock
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: dotenv
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: ledger_sync
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: nokogiri
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :runtime
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: oauth2
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :runtime
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
237
+ description: LedgerSync is a simple library that allows you to sync common objects
238
+ to popular accounting software like QuickBooks Online, Stripe, NetSuite, etc.
239
+ email:
240
+ - ledgersync@moderntreasury.com
241
+ executables: []
242
+ extensions: []
243
+ extra_rdoc_files: []
244
+ files:
245
+ - ".coveralls.yml"
246
+ - ".env.test"
247
+ - ".gitignore"
248
+ - ".overcommit.yml"
249
+ - ".rubocop.yml"
250
+ - ".rubocop_todo.yml"
251
+ - ".travis.yml"
252
+ - Gemfile
253
+ - Gemfile.lock
254
+ - README.md
255
+ - Rakefile
256
+ - bin/console
257
+ - bin/setup
258
+ - ledger_sync-stripe.gemspec
259
+ - lib/ledger_sync/stripe.rb
260
+ - lib/ledger_sync/stripe/client.rb
261
+ - lib/ledger_sync/stripe/config.rb
262
+ - lib/ledger_sync/stripe/customer/operations/create.rb
263
+ - lib/ledger_sync/stripe/customer/operations/delete.rb
264
+ - lib/ledger_sync/stripe/customer/operations/find.rb
265
+ - lib/ledger_sync/stripe/customer/operations/update.rb
266
+ - lib/ledger_sync/stripe/dashboard_url_helper.rb
267
+ - lib/ledger_sync/stripe/deserializer.rb
268
+ - lib/ledger_sync/stripe/operation.rb
269
+ - lib/ledger_sync/stripe/operation/create.rb
270
+ - lib/ledger_sync/stripe/operation/delete.rb
271
+ - lib/ledger_sync/stripe/operation/find.rb
272
+ - lib/ledger_sync/stripe/operation/update.rb
273
+ - lib/ledger_sync/stripe/resource.rb
274
+ - lib/ledger_sync/stripe/resources/customer.rb
275
+ - lib/ledger_sync/stripe/serializer.rb
276
+ - lib/ledger_sync/stripe/version.rb
277
+ homepage: https://www.ledgersync.dev
278
+ licenses: []
279
+ metadata: {}
280
+ post_install_message:
281
+ rdoc_options: []
282
+ require_paths:
283
+ - lib
284
+ required_ruby_version: !ruby/object:Gem::Requirement
285
+ requirements:
286
+ - - ">="
287
+ - !ruby/object:Gem::Version
288
+ version: 2.5.8
289
+ required_rubygems_version: !ruby/object:Gem::Requirement
290
+ requirements:
291
+ - - ">="
292
+ - !ruby/object:Gem::Version
293
+ version: '0'
294
+ requirements: []
295
+ rubygems_version: 3.0.3
296
+ signing_key:
297
+ specification_version: 4
298
+ summary: Sync common objects to accounting software.
299
+ test_files: []