ledger_sync-template_ledger 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.env.test +1 -0
  4. data/.gitignore +21 -0
  5. data/.overcommit.yml +29 -0
  6. data/.rubocop.yml +78 -0
  7. data/.rubocop_todo.yml +25 -0
  8. data/.travis.yml +26 -0
  9. data/Gemfile +8 -0
  10. data/Gemfile.lock +234 -0
  11. data/README.md +13 -0
  12. data/Rakefile +8 -0
  13. data/bin/console +15 -0
  14. data/bin/setup +8 -0
  15. data/ledger_sync-template_ledger.gemspec +45 -0
  16. data/lib/ledger_sync/template_ledger.rb +13 -0
  17. data/lib/ledger_sync/template_ledger/client.rb +61 -0
  18. data/lib/ledger_sync/template_ledger/config.rb +12 -0
  19. data/lib/ledger_sync/template_ledger/deserializer.rb +8 -0
  20. data/lib/ledger_sync/template_ledger/operation.rb +57 -0
  21. data/lib/ledger_sync/template_ledger/operation/create.rb +26 -0
  22. data/lib/ledger_sync/template_ledger/operation/find.rb +23 -0
  23. data/lib/ledger_sync/template_ledger/operation/update.rb +26 -0
  24. data/lib/ledger_sync/template_ledger/resource.rb +8 -0
  25. data/lib/ledger_sync/template_ledger/resources/sample_resource.rb +10 -0
  26. data/lib/ledger_sync/template_ledger/sample_resource/deserializer.rb +14 -0
  27. data/lib/ledger_sync/template_ledger/sample_resource/operations/create.rb +20 -0
  28. data/lib/ledger_sync/template_ledger/sample_resource/operations/find.rb +20 -0
  29. data/lib/ledger_sync/template_ledger/sample_resource/operations/update.rb +20 -0
  30. data/lib/ledger_sync/template_ledger/sample_resource/serializer.rb +14 -0
  31. data/lib/ledger_sync/template_ledger/serializer.rb +8 -0
  32. data/lib/ledger_sync/template_ledger/version.rb +19 -0
  33. metadata +299 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fd3b6d7cd360b639754830dfd763df3683abbbe87e66e117f07ab2b61f7d979c
4
+ data.tar.gz: 5ca0a20073a1ea3ddc8082c7dccd9882d34e1b5a336c4d6a1a208ccee0df5aaf
5
+ SHA512:
6
+ metadata.gz: e4ea149bb9a0b238deef6ad7a771e156a7efb44ebdb6b80919bf750e0d4df04de543466794cb45bb6fefe53a1245b289d5b02aac146f40adc59e71485d87ea4d
7
+ data.tar.gz: 17a2d45ed9c5ae6c8c2472b406c7d8058dfe4881f3a5ed4556d9b7b9bf8d87bb018caaf63d62b7123da0d11056ead1995306d065a1999e57075748635614c2a0
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -0,0 +1 @@
1
+ TEMPLATE_LEDGER_API_KEY=TEMPLATE_LEDGER_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-template_ledger.gemspec
8
+ gemspec
@@ -0,0 +1,234 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ledger_sync-template_ledger (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-template_ledger!
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,13 @@
1
+ # LedgerSync::TemplateLedger
2
+
3
+ [ledgersync.dev](www.ledgersync.dev)
4
+
5
+ ## Usage
6
+
7
+ This template ledger enables you to easily create your own ledger for public or private use. Although this is not an
8
+ exhaustive list, a good place to start assuming your ledger name is `NewLedger`:
9
+
10
+ 1. Find and replace all `TEMPLATE_LEDGER` with `NEW_LEDGER`
11
+ 2. Find and replace all `TemplateLedger` with `NewLedger`
12
+ 3. Find and replace all `template_ledger` with `new_ledger`
13
+ 4. Find and replace all `Template Ledger` with `New Ledger`
@@ -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/template_ledger'
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/template_ledger/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'ledger_sync-template_ledger'
9
+ spec.version = LedgerSync::TemplateLedger::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, TemplateLedger, 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 TemplateLedger
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 'template_ledger/config'
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module TemplateLedger
5
+ class Client
6
+ include Ledgers::Client::Mixin
7
+
8
+ ROOT_URI = 'https://api.template_ledger.com'
9
+ DEFAULT_HEADERS = { 'Accept' => 'application/json', 'Content-Type' => 'application/json' }.freeze
10
+
11
+ attr_reader :api_key
12
+
13
+ def initialize(args = {})
14
+ @api_key = args.fetch(:api_key)
15
+ end
16
+
17
+ def find(path:)
18
+ url = File.join(ROOT_URI, path)
19
+
20
+ request(
21
+ headers: DEFAULT_HEADERS,
22
+ method: :get,
23
+ url: url
24
+ )
25
+ end
26
+
27
+ def post(path:, payload:)
28
+ url = File.join(ROOT_URI, path)
29
+
30
+ request(
31
+ headers: DEFAULT_HEADERS,
32
+ method: :post,
33
+ body: payload,
34
+ url: url
35
+ )
36
+ end
37
+
38
+ def request(method:, url:, body: nil, headers: {})
39
+ LedgerSync::Ledgers::Request.new(
40
+ client: self,
41
+ body: body,
42
+ headers: headers,
43
+ method: method,
44
+ url: url
45
+ ).perform
46
+ end
47
+
48
+ def self.new_from_env(**override)
49
+ new(
50
+ {
51
+ api_key: ENV.fetch('TEMPLATE_LEDGER_API_KEY')
52
+ }.merge(override)
53
+ )
54
+ end
55
+
56
+ def self.ledger_attributes_to_save
57
+ %i[api_key]
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'client'
4
+
5
+ args = {
6
+ base_module: LedgerSync::TemplateLedger,
7
+ root_path: 'ledger_sync/template_ledger'
8
+ }
9
+
10
+ LedgerSync.register_ledger(:template_ledger, args) do |config|
11
+ config.name = 'TemplateLedger'
12
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module TemplateLedger
5
+ class Deserializer < LedgerSync::Deserializer
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module TemplateLedger
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 deserialized_resource(response:)
14
+ deserializer.deserialize(
15
+ hash: response,
16
+ resource: resource
17
+ )
18
+ end
19
+
20
+ def ledger_resource_path
21
+ @ledger_resource_path ||= "#{ledger_resource_type_for_path}/#{resource.ledger_id}"
22
+ end
23
+
24
+ def ledger_resource_type_for_path
25
+ template_ledger_resource_type.pluralize.downcase
26
+ end
27
+
28
+ def response_to_operation_result(response:)
29
+ if response.success?
30
+ success(
31
+ resource: deserialized_resource(
32
+ response: response.body
33
+ ),
34
+ response: response
35
+ )
36
+ else
37
+ failure
38
+ # TODO: implement failure handler
39
+ end
40
+ end
41
+
42
+ def perform
43
+ super
44
+ rescue LedgerSync::Error::OperationError, OAuth2::Error => e
45
+ failure(e)
46
+ ensure
47
+ client.update_secrets_in_dotenv
48
+ end
49
+
50
+ def template_ledger_resource_type
51
+ @template_ledger_resource_type ||= client.class.ledger_resource_type_for(resource_class: resource.class)
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../operation'
4
+
5
+ module LedgerSync
6
+ module TemplateLedger
7
+ class Operation
8
+ class Create
9
+ include TemplateLedger::Operation::Mixin
10
+
11
+ private
12
+
13
+ def operate
14
+ response_to_operation_result(
15
+ response: client.post(
16
+ path: ledger_resource_type_for_path,
17
+ payload: [
18
+ serializer.serialize(resource: resource)
19
+ ]
20
+ )
21
+ )
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../operation'
4
+
5
+ module LedgerSync
6
+ module TemplateLedger
7
+ class Operation
8
+ class Find
9
+ include TemplateLedger::Operation::Mixin
10
+
11
+ private
12
+
13
+ def operate
14
+ response_to_operation_result(
15
+ response: client.find(
16
+ path: ledger_resource_path
17
+ )
18
+ )
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../operation'
4
+
5
+ module LedgerSync
6
+ module TemplateLedger
7
+ class Operation
8
+ class Update
9
+ include TemplateLedger::Operation::Mixin
10
+
11
+ private
12
+
13
+ def operate
14
+ response_to_operation_result(
15
+ response: client.post(
16
+ path: ledger_resource_type_for_path,
17
+ payload: [
18
+ serializer.serialize(resource: resource)
19
+ ]
20
+ )
21
+ )
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module TemplateLedger
5
+ class Resource < LedgerSync::Resource
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module TemplateLedger
5
+ class SampleResource < TemplateLedger::Resource
6
+ attribute :Name, type: Type::String
7
+ attribute :Email, type: Type::String
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module TemplateLedger
5
+ class SampleResource
6
+ class Deserializer < TemplateLedger::Deserializer
7
+ attribute :ledger_id,
8
+ hash_attribute: 'Id'
9
+ attribute :Name
10
+ attribute :Email
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module TemplateLedger
5
+ class SampleResource
6
+ module Operations
7
+ class Create < TemplateLedger::Operation::Create
8
+ class Contract < LedgerSync::Ledgers::Contract
9
+ params do
10
+ required(:external_id).filled(:string)
11
+ required(:ledger_id).value(:nil)
12
+ required(:Name).maybe(:string)
13
+ required(:Email).maybe(:string)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module TemplateLedger
5
+ class SampleResource
6
+ module Operations
7
+ class Find < TemplateLedger::Operation::Find
8
+ class Contract < LedgerSync::Ledgers::Contract
9
+ params do
10
+ optional(:external_id).filled(:string)
11
+ required(:ledger_id).filled(:string)
12
+ optional(:Name).maybe(:string)
13
+ optional(:Email).maybe(:string)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module TemplateLedger
5
+ class SampleResource
6
+ module Operations
7
+ class Update < TemplateLedger::Operation::Update
8
+ class Contract < LedgerSync::Ledgers::Contract
9
+ params do
10
+ required(:external_id).filled(:string)
11
+ required(:ledger_id).filled(:string)
12
+ required(:Name).maybe(:string)
13
+ required(:Email).maybe(:string)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module TemplateLedger
5
+ class SampleResource
6
+ class Serializer < TemplateLedger::Serializer
7
+ attribute :Id,
8
+ resource_attribute: :ledger_id
9
+ attribute :Name
10
+ attribute :Email
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module TemplateLedger
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 TemplateLedger
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-template_ledger
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-06 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, TemplateLedger, NetSuite,
239
+ etc.
240
+ email:
241
+ - ledgersync@moderntreasury.com
242
+ executables: []
243
+ extensions: []
244
+ extra_rdoc_files: []
245
+ files:
246
+ - ".coveralls.yml"
247
+ - ".env.test"
248
+ - ".gitignore"
249
+ - ".overcommit.yml"
250
+ - ".rubocop.yml"
251
+ - ".rubocop_todo.yml"
252
+ - ".travis.yml"
253
+ - Gemfile
254
+ - Gemfile.lock
255
+ - README.md
256
+ - Rakefile
257
+ - bin/console
258
+ - bin/setup
259
+ - ledger_sync-template_ledger.gemspec
260
+ - lib/ledger_sync/template_ledger.rb
261
+ - lib/ledger_sync/template_ledger/client.rb
262
+ - lib/ledger_sync/template_ledger/config.rb
263
+ - lib/ledger_sync/template_ledger/deserializer.rb
264
+ - lib/ledger_sync/template_ledger/operation.rb
265
+ - lib/ledger_sync/template_ledger/operation/create.rb
266
+ - lib/ledger_sync/template_ledger/operation/find.rb
267
+ - lib/ledger_sync/template_ledger/operation/update.rb
268
+ - lib/ledger_sync/template_ledger/resource.rb
269
+ - lib/ledger_sync/template_ledger/resources/sample_resource.rb
270
+ - lib/ledger_sync/template_ledger/sample_resource/deserializer.rb
271
+ - lib/ledger_sync/template_ledger/sample_resource/operations/create.rb
272
+ - lib/ledger_sync/template_ledger/sample_resource/operations/find.rb
273
+ - lib/ledger_sync/template_ledger/sample_resource/operations/update.rb
274
+ - lib/ledger_sync/template_ledger/sample_resource/serializer.rb
275
+ - lib/ledger_sync/template_ledger/serializer.rb
276
+ - lib/ledger_sync/template_ledger/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: []