ledger_sync 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +14 -1
- data/.ruby-version +1 -0
- data/.travis.yml +3 -2
- data/Dockerfile +2 -2
- data/Gemfile.lock +11 -11
- data/LICENSE.txt +97 -21
- data/README.md +28 -11
- data/bin/quickbooks_online_oauth_server.rb +101 -0
- data/lib/ledger_sync.rb +8 -0
- data/lib/ledger_sync/adaptor_configuration.rb +4 -4
- data/lib/ledger_sync/adaptor_configuration_store.rb +4 -4
- data/lib/ledger_sync/adaptors/adaptor.rb +4 -6
- data/lib/ledger_sync/adaptors/dashboard_url_helper.rb +23 -0
- data/lib/ledger_sync/adaptors/ledger_serializer_attribute_set.rb +3 -5
- data/lib/ledger_sync/adaptors/mixins/infer_ledger_serializer_mixin.rb +16 -0
- data/lib/ledger_sync/adaptors/netsuite/account/searcher_ledger_deserializer.rb +30 -0
- data/lib/ledger_sync/adaptors/netsuite/adaptor.rb +11 -3
- data/lib/ledger_sync/adaptors/netsuite/customer/searcher.rb +12 -0
- data/lib/ledger_sync/adaptors/netsuite/customer/searcher_ledger_deserializer.rb +23 -0
- data/lib/ledger_sync/adaptors/netsuite/dashboard_url_helper.rb +24 -0
- data/lib/ledger_sync/adaptors/netsuite/department/searcher_ledger_deserializer.rb +21 -0
- data/lib/ledger_sync/adaptors/netsuite/ledger_serializer_type/active_type.rb +26 -0
- data/lib/ledger_sync/adaptors/netsuite/location/ledger_serializer.rb +18 -0
- data/lib/ledger_sync/adaptors/netsuite/location/operations/create.rb +21 -0
- data/lib/ledger_sync/adaptors/netsuite/location/operations/delete.rb +21 -0
- data/lib/ledger_sync/adaptors/netsuite/location/operations/find.rb +21 -0
- data/lib/ledger_sync/adaptors/netsuite/location/operations/update.rb +21 -0
- data/lib/ledger_sync/adaptors/netsuite/location/searcher.rb +12 -0
- data/lib/ledger_sync/adaptors/netsuite/record/http_method.rb +1 -1
- data/lib/ledger_sync/adaptors/netsuite/record/metadata.rb +11 -7
- data/lib/ledger_sync/adaptors/netsuite/searcher.rb +30 -8
- data/lib/ledger_sync/adaptors/netsuite/vendor/searcher.rb +12 -0
- data/lib/ledger_sync/adaptors/netsuite/vendor/searcher_ledger_deserializer.rb +23 -0
- data/lib/ledger_sync/adaptors/operation.rb +7 -3
- data/lib/ledger_sync/adaptors/quickbooks_online/adaptor.rb +7 -2
- data/lib/ledger_sync/adaptors/quickbooks_online/dashboard_url_helper.rb +1 -26
- data/lib/ledger_sync/adaptors/quickbooks_online/department/ledger_serializer.rb +6 -3
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer.rb +1 -1
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/department_reference_type.rb +26 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/operation/full_update.rb +0 -1
- data/lib/ledger_sync/adaptors/quickbooks_online/util/adaptor_error_parser.rb +5 -5
- data/lib/ledger_sync/adaptors/quickbooks_online/util/error_matcher.rb +1 -1
- data/lib/ledger_sync/adaptors/quickbooks_online/util/error_parser.rb +1 -1
- data/lib/ledger_sync/adaptors/quickbooks_online/util/operation_error_parser.rb +5 -5
- data/lib/ledger_sync/adaptors/stripe/adaptor.rb +4 -12
- data/lib/ledger_sync/adaptors/stripe/dashboard_url_helper.rb +21 -0
- data/lib/ledger_sync/deserializer.rb +59 -0
- data/lib/ledger_sync/error/adaptor_errors.rb +2 -2
- data/lib/ledger_sync/error/resource_errors.rb +18 -19
- data/lib/ledger_sync/resource.rb +9 -8
- data/lib/ledger_sync/resource_attribute.rb +30 -7
- data/lib/ledger_sync/resource_attribute/mixin.rb +13 -23
- data/lib/ledger_sync/resource_attribute/reference/many.rb +11 -5
- data/lib/ledger_sync/resource_attribute/reference/one.rb +10 -4
- data/lib/ledger_sync/resource_attribute_set.rb +3 -7
- data/lib/ledger_sync/resources/location.rb +7 -0
- data/lib/ledger_sync/serialization/attribute.rb +47 -0
- data/lib/ledger_sync/serialization/attribute_set_mixin.rb +27 -0
- data/lib/ledger_sync/serialization/deserializer_attribute.rb +60 -0
- data/lib/ledger_sync/serialization/deserializer_attribute_set.rb +22 -0
- data/lib/ledger_sync/serialization/deserializer_delegator.rb +17 -0
- data/lib/ledger_sync/serialization/mixin.rb +72 -0
- data/lib/ledger_sync/serialization/serializer_attribute.rb +51 -0
- data/lib/ledger_sync/serialization/serializer_attribute_set.rb +22 -0
- data/lib/ledger_sync/serialization/serializer_delegator.rb +17 -0
- data/lib/ledger_sync/serialization/type/references_many_type.rb +19 -0
- data/lib/ledger_sync/serialization/type/references_one_type.rb +12 -0
- data/lib/ledger_sync/serialization/type/serializer_type.rb +23 -0
- data/lib/ledger_sync/serialization/type/value_type.rb +15 -0
- data/lib/ledger_sync/serializer.rb +46 -0
- data/lib/ledger_sync/type/date.rb +2 -0
- data/lib/ledger_sync/type/id.rb +2 -0
- data/lib/ledger_sync/type/reference_one.rb +8 -4
- data/lib/ledger_sync/type/value_mixin.rb +2 -2
- data/lib/ledger_sync/util/mixins/delegate_iterable_methods_mixin.rb +42 -0
- data/lib/ledger_sync/util/mixins/dupable_mixin.rb +13 -0
- data/lib/ledger_sync/version.rb +1 -1
- metadata +39 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88373f5810a2313413c6d0a51ac42ff1fd80c7a58661ae37e04a0bad1d9d5e77
|
4
|
+
data.tar.gz: 626de0eb9096dc719354afee2e82fefdb392595869c07a22b8cfe2a89c502d0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 489544c4dfb222723cf76a439d22b8e12624b0862de85ae5c49d419d3d1dac9b4120de88157fc9c8f0cd310924e23f776558c0a5a3663d727a90b289f1d52023
|
7
|
+
data.tar.gz: 81bf1d1a74339ad6d8ad664d9e79f07c738ef19b18e0bfb3bd9ba99c9bfe96c446133426ad582a4bed16a3ab08779efa59f9c5a7cdd3926e5b1ef19f9437bb0c
|
data/.rubocop.yml
CHANGED
@@ -1,4 +1,17 @@
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
2
2
|
|
3
3
|
AllCops:
|
4
|
-
TargetRubyVersion: 2.6
|
4
|
+
TargetRubyVersion: 2.6
|
5
|
+
|
6
|
+
Layout/LineLength:
|
7
|
+
Enabled: True
|
8
|
+
Max: 120
|
9
|
+
|
10
|
+
Style/HashEachMethods:
|
11
|
+
Enabled: True
|
12
|
+
|
13
|
+
Style/HashTransformKeys:
|
14
|
+
Enabled: True
|
15
|
+
|
16
|
+
Style/HashTransformValues:
|
17
|
+
Enabled: True
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.6
|
data/.travis.yml
CHANGED
data/Dockerfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ledger_sync (1.3.
|
4
|
+
ledger_sync (1.3.5)
|
5
5
|
activemodel
|
6
6
|
colorize
|
7
7
|
coveralls
|
@@ -54,7 +54,7 @@ GEM
|
|
54
54
|
diff-lcs (1.3)
|
55
55
|
docile (1.3.2)
|
56
56
|
dotenv (2.7.5)
|
57
|
-
dry-configurable (0.11.
|
57
|
+
dry-configurable (0.11.5)
|
58
58
|
concurrent-ruby (~> 1.0)
|
59
59
|
dry-core (~> 0.4, >= 0.4.7)
|
60
60
|
dry-equalizer (~> 0.2)
|
@@ -70,14 +70,14 @@ GEM
|
|
70
70
|
concurrent-ruby (~> 1.0)
|
71
71
|
dry-core (~> 0.2)
|
72
72
|
dry-equalizer (~> 0.2)
|
73
|
-
dry-schema (1.
|
73
|
+
dry-schema (1.5.0)
|
74
74
|
concurrent-ruby (~> 1.0)
|
75
75
|
dry-configurable (~> 0.8, >= 0.8.3)
|
76
76
|
dry-core (~> 0.4)
|
77
77
|
dry-equalizer (~> 0.2)
|
78
78
|
dry-initializer (~> 3.0)
|
79
79
|
dry-logic (~> 1.0)
|
80
|
-
dry-types (~> 1.
|
80
|
+
dry-types (~> 1.4)
|
81
81
|
dry-types (1.4.0)
|
82
82
|
concurrent-ruby (~> 1.0)
|
83
83
|
dry-container (~> 0.3)
|
@@ -85,21 +85,21 @@ GEM
|
|
85
85
|
dry-equalizer (~> 0.3)
|
86
86
|
dry-inflector (~> 0.1, >= 0.1.2)
|
87
87
|
dry-logic (~> 1.0, >= 1.0.2)
|
88
|
-
dry-validation (1.
|
88
|
+
dry-validation (1.5.0)
|
89
89
|
concurrent-ruby (~> 1.0)
|
90
90
|
dry-container (~> 0.7, >= 0.7.1)
|
91
91
|
dry-core (~> 0.4)
|
92
92
|
dry-equalizer (~> 0.2)
|
93
93
|
dry-initializer (~> 3.0)
|
94
|
-
dry-schema (~> 1.
|
94
|
+
dry-schema (~> 1.5)
|
95
95
|
factory_bot (5.1.1)
|
96
96
|
activesupport (>= 4.2.0)
|
97
|
-
faraday (0.
|
97
|
+
faraday (1.0.1)
|
98
98
|
multipart-post (>= 1.2, < 3)
|
99
99
|
faraday-detailed_logger (2.3.0)
|
100
100
|
faraday (>= 0.8, < 2)
|
101
|
-
faraday_middleware (0.
|
102
|
-
faraday (
|
101
|
+
faraday_middleware (1.0.0)
|
102
|
+
faraday (~> 1.0)
|
103
103
|
fingerprintable (1.2.1)
|
104
104
|
colorize
|
105
105
|
gyoku (1.3.1)
|
@@ -132,7 +132,7 @@ GEM
|
|
132
132
|
parallel (1.19.1)
|
133
133
|
parser (2.7.0.3)
|
134
134
|
ast (~> 2.4.0)
|
135
|
-
pd_ruby (0.2.
|
135
|
+
pd_ruby (0.2.3)
|
136
136
|
colorize
|
137
137
|
public_suffix (4.0.3)
|
138
138
|
rack (2.2.2)
|
@@ -179,7 +179,7 @@ GEM
|
|
179
179
|
simply_serializable (1.4.2)
|
180
180
|
fingerprintable (>= 1.2.1)
|
181
181
|
socksify (1.7.1)
|
182
|
-
stripe (5.
|
182
|
+
stripe (5.21.0)
|
183
183
|
sync (0.5.0)
|
184
184
|
term-ansicolor (1.7.1)
|
185
185
|
tins (~> 1.0)
|
data/LICENSE.txt
CHANGED
@@ -1,21 +1,97 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
1
|
+
Business Source License 1.1
|
2
|
+
|
3
|
+
Parameters
|
4
|
+
|
5
|
+
Licensor: Modern Treasury Corp.
|
6
|
+
Licensed Work: LedgerSync
|
7
|
+
The Licensed Work is (c) 2020 Modern Treasury Corp.
|
8
|
+
Additional Use Grant: You may make use of the Licensed Work, provided that you
|
9
|
+
may not use the Licensed Work for a Connector Service.
|
10
|
+
|
11
|
+
A “Connector Service” is a commercial offering that
|
12
|
+
allows third parties (other than your employees and
|
13
|
+
contractors) to access the functionality of the Licensed
|
14
|
+
Work by connecting to and exchanging information with
|
15
|
+
general ledgers, accounting software, or other adaptors
|
16
|
+
defined in the library that are controlled by such
|
17
|
+
third parties.
|
18
|
+
|
19
|
+
Notice
|
20
|
+
|
21
|
+
The Business Source License (this document, or the “License”) is not an Open
|
22
|
+
Source license. However, the Licensed Work will eventually be made available
|
23
|
+
under an Open Source License, as stated in this License.
|
24
|
+
|
25
|
+
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
|
26
|
+
“Business Source License” is a trademark of MariaDB Corporation Ab.
|
27
|
+
|
28
|
+
-----------------------------------------------------------------------------
|
29
|
+
|
30
|
+
Business Source License 1.1
|
31
|
+
|
32
|
+
Terms
|
33
|
+
|
34
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
35
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
36
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
37
|
+
production use.
|
38
|
+
|
39
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
40
|
+
available distribution of a specific version of the Licensed Work under this
|
41
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
42
|
+
the terms of the Change License, and the rights granted in the paragraph
|
43
|
+
above terminate.
|
44
|
+
|
45
|
+
If your use of the Licensed Work does not comply with the requirements
|
46
|
+
currently in effect as described in this License, you must purchase a
|
47
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
48
|
+
resellers, or you must refrain from using the Licensed Work.
|
49
|
+
|
50
|
+
All copies of the original and modified Licensed Work, and derivative works
|
51
|
+
of the Licensed Work, are subject to this License. This License applies
|
52
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
53
|
+
for each version of the Licensed Work released by Licensor.
|
54
|
+
|
55
|
+
You must conspicuously display this License on each original or modified copy
|
56
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
57
|
+
modified form from a third party, the terms and conditions set forth in this
|
58
|
+
License apply to your use of that work.
|
59
|
+
|
60
|
+
Any use of the Licensed Work in violation of this License will automatically
|
61
|
+
terminate your rights under this License for the current and all other
|
62
|
+
versions of the Licensed Work.
|
63
|
+
|
64
|
+
This License does not grant you any right in any trademark or logo of
|
65
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
66
|
+
Licensor as expressly required by this License).
|
67
|
+
|
68
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
69
|
+
AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
70
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
71
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
72
|
+
TITLE.
|
73
|
+
|
74
|
+
MariaDB hereby grants you permission to use this License’s text to license
|
75
|
+
your works, and to refer to it using the trademark “Business Source License”,
|
76
|
+
as long as you comply with the Covenants of Licensor below.
|
77
|
+
|
78
|
+
Covenants of Licensor
|
79
|
+
|
80
|
+
In consideration of the right to use this License’s text and the “Business
|
81
|
+
Source License” name and trademark, Licensor covenants to MariaDB, and to all
|
82
|
+
other recipients of the licensed work to be provided by Licensor:
|
83
|
+
|
84
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
85
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
86
|
+
where “compatible” means that software provided under the Change License can
|
87
|
+
be included in a program with software provided under GPL Version 2.0 or a
|
88
|
+
later version. Licensor may specify additional Change Licenses without
|
89
|
+
limitation.
|
90
|
+
|
91
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
92
|
+
impose any additional restriction on the right granted in this License, as
|
93
|
+
the Additional Use Grant; or (b) insert the text “None”.
|
94
|
+
|
95
|
+
3. To specify a Change Date.
|
96
|
+
|
97
|
+
4. Not to modify this License in any other way.
|
data/README.md
CHANGED
@@ -4,6 +4,10 @@
|
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/ledger_sync.svg)](https://badge.fury.io/rb/ledger_sync)
|
5
5
|
[![Coverage Status](https://coveralls.io/repos/github/LedgerSync/ledger_sync/badge.svg?branch=master)](https://coveralls.io/github/LedgerSync/ledger_sync?branch=master)
|
6
6
|
|
7
|
+
## Join the Conversation
|
8
|
+
|
9
|
+
[Click here](https://join.slack.com/t/ledger-sync/shared_invite/zt-cn4qfhb8-~6BrVy8v7~upxQk6Pfo7oQ) to join our public Slack group.
|
10
|
+
|
7
11
|
## Installation
|
8
12
|
|
9
13
|
Add this line to your application's Gemfile:
|
@@ -118,25 +122,25 @@ custom_attributes_for_customers = [
|
|
118
122
|
]
|
119
123
|
|
120
124
|
custom_customer_classes = custom_attributes_for_customers.map do |attributes|
|
121
|
-
|
125
|
+
customer_class = Class.new(LedgerSync::Customer)
|
122
126
|
attributes.each do |name, type|
|
123
|
-
|
127
|
+
customer_class.attribute name, type: type
|
124
128
|
end
|
125
|
-
|
129
|
+
customer_class
|
126
130
|
end
|
127
131
|
|
128
|
-
|
132
|
+
customer_class_1, customer_class_2 = custom_customer_classes
|
129
133
|
|
130
134
|
# First Custom Customer Class
|
131
|
-
|
132
|
-
|
133
|
-
|
135
|
+
customer_class_1.resource_attributes.include?(:foo) # => true
|
136
|
+
customer_class_1.resource_attributes[:foo].type # => #<LedgerSync::Type::String:0x00007fe04e9529b0 @precision=nil, @scale=nil, @limit=nil>
|
137
|
+
customer_class_1.resource_attributes.include?(:bar) # => false
|
134
138
|
|
135
139
|
# Second Custom Customer Class
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
+
customer_class_2.resource_attributes.include?(:foo) # => true
|
141
|
+
customer_class_2.resource_attributes[:foo].type # => #<LedgerSync::Type::Integer:0x00007fe04e2c7898 @precision=nil, @scale=nil, @limit=nil, @range=-2147483648...2147483648>
|
142
|
+
customer_class_2.resource_attributes.include?(:bar) # => true
|
143
|
+
customer_class_2.resource_attributes[:bar].type # => #<LedgerSync::Type::Boolean:0x00007fe04e2e4f10 @precision=nil, @scale=nil, @limit=nil>
|
140
144
|
```
|
141
145
|
|
142
146
|
You can now use these custom resources in operations that require custom attributes.
|
@@ -297,6 +301,19 @@ LedgerSync supports the NetSuite SOAP adaptor, leveraging [the NetSuite gem](htt
|
|
297
301
|
|
298
302
|
QuickBooks Online utilizes OAuth 2.0, which requires frequent refreshing of the access token. The adaptor will handle this automatically, attempting a single token refresh on any single request authentication failure. Depending on how you use the library, every adaptor has implements a class method `ledger_attributes_to_save`, which is an array of attributes that may change as the adaptor is used. You can also call the instance method `ledger_attributes_to_save` which will be a hash of these values. It is a good practice to always store these attributes if you are saving access tokens in your database.
|
299
303
|
|
304
|
+
#### Retrieve Access Token
|
305
|
+
|
306
|
+
The library contains a lightweight script that is helpful in retrieving and refreshing access tokens. To use, do the following:
|
307
|
+
|
308
|
+
1. Create a `.env` file in the library root.
|
309
|
+
2. Add values for `QUICKBOOKS_ONLINE_CLIENT_ID` and `QUICKBOOKS_ONLINE_CLIENT_SECRET` (you can copy `.env.template`).
|
310
|
+
3. Ensure your developer application in [the QuickBooks Online developer portal](https://developer.intuit.com) contains this redirect URI: `http://localhost:5678` (note: no trailing slash and port configurable with `PORT` environment variable)
|
311
|
+
4. Run `ruby bin/quickbooks_online_oauth_server.rb` from the library root (note: it must run from the root in order to update `.env`).
|
312
|
+
5. Visit the URL output in the terminal.
|
313
|
+
6. Upon redirect back to your `localhost`, the new values will be printed to the console and saved back to your `.env`
|
314
|
+
|
315
|
+
#### Adaptor Helper Methods
|
316
|
+
|
300
317
|
The adaptor also implements some helper methods for getting tokens. For example, you can set up an adaptor using the following:
|
301
318
|
|
302
319
|
```ruby
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# Setup
|
2
|
+
#
|
3
|
+
# gem install bundler
|
4
|
+
# Ensure you have http://localhost:5678 (or PORT) as a Redirect URI in QBO.
|
5
|
+
|
6
|
+
require 'bundler/inline'
|
7
|
+
|
8
|
+
gemfile do
|
9
|
+
source 'https://rubygems.org'
|
10
|
+
gem 'dotenv'
|
11
|
+
gem 'ledger_sync'
|
12
|
+
gem 'rack'
|
13
|
+
gem 'pd_ruby', '0.2.2', require: true
|
14
|
+
end
|
15
|
+
|
16
|
+
puts 'Gems installed and loaded!'
|
17
|
+
|
18
|
+
require 'socket'
|
19
|
+
require 'dotenv'
|
20
|
+
require 'rack'
|
21
|
+
require 'ledger_sync'
|
22
|
+
require 'rack/lobster'
|
23
|
+
|
24
|
+
Dotenv.load
|
25
|
+
|
26
|
+
port = ENV.fetch('PORT', 5678)
|
27
|
+
app = Rack::Lobster.new
|
28
|
+
server = TCPServer.new port
|
29
|
+
|
30
|
+
base_url = "http://localhost:#{port}"
|
31
|
+
|
32
|
+
puts "Listening at #{base_url}"
|
33
|
+
|
34
|
+
client_id = ENV.fetch('QUICKBOOKS_ONLINE_CLIENT_ID')
|
35
|
+
|
36
|
+
raise 'QUICKBOOKS_ONLINE_CLIENT_ID not set in ../.env' if client_id.blank?
|
37
|
+
|
38
|
+
adaptor = LedgerSync::Adaptors::QuickBooksOnline::Adaptor.new_from_env(test: true)
|
39
|
+
|
40
|
+
puts 'Go to the following URL:'
|
41
|
+
puts adaptor.authorization_url(redirect_uri: base_url)
|
42
|
+
|
43
|
+
while session = server.accept
|
44
|
+
request = session.gets
|
45
|
+
|
46
|
+
puts request
|
47
|
+
|
48
|
+
# 1
|
49
|
+
method, full_path = request.split(' ')
|
50
|
+
|
51
|
+
# 2
|
52
|
+
path, query = full_path.split('?')
|
53
|
+
|
54
|
+
params = Hash[query.split('&').map { |e| e.split('=') }] if query.present?
|
55
|
+
|
56
|
+
adaptor.set_credentials_from_oauth_code(
|
57
|
+
code: params.fetch('code'),
|
58
|
+
realm_id: params.fetch('realmId'),
|
59
|
+
redirect_uri: base_url
|
60
|
+
)
|
61
|
+
|
62
|
+
puts "\n"
|
63
|
+
|
64
|
+
puts 'access_token:'
|
65
|
+
puts adaptor.access_token
|
66
|
+
puts "\n"
|
67
|
+
puts 'client_id:'
|
68
|
+
puts adaptor.client_id
|
69
|
+
puts "\n"
|
70
|
+
puts 'client_secret:'
|
71
|
+
puts adaptor.client_secret
|
72
|
+
puts "\n"
|
73
|
+
puts 'realm_id:'
|
74
|
+
puts adaptor.realm_id
|
75
|
+
puts "\n"
|
76
|
+
puts 'refresh_token:'
|
77
|
+
puts adaptor.refresh_token
|
78
|
+
puts "\n"
|
79
|
+
|
80
|
+
puts 'Done!'
|
81
|
+
|
82
|
+
status = 200
|
83
|
+
body = 'Done'
|
84
|
+
headers = {
|
85
|
+
'Content-Length' => body.size
|
86
|
+
}
|
87
|
+
|
88
|
+
session.print "HTTP/1.1 #{status}\r\n"
|
89
|
+
|
90
|
+
headers.each do |key, value|
|
91
|
+
session.print "#{key}: #{value}\r\n"
|
92
|
+
end
|
93
|
+
|
94
|
+
session.print "\r\n"
|
95
|
+
|
96
|
+
session.print body
|
97
|
+
|
98
|
+
session.close
|
99
|
+
|
100
|
+
break
|
101
|
+
end
|
data/lib/ledger_sync.rb
CHANGED
@@ -44,11 +44,18 @@ require 'ledger_sync/adaptor_configuration_store'
|
|
44
44
|
require 'ledger_sync/util/performer'
|
45
45
|
require 'ledger_sync/util/validator'
|
46
46
|
require 'ledger_sync/util/string_helpers'
|
47
|
+
require 'ledger_sync/util/mixins/delegate_iterable_methods_mixin'
|
48
|
+
require 'ledger_sync/util/mixins/dupable_mixin'
|
47
49
|
require 'ledger_sync/result'
|
50
|
+
require 'ledger_sync/serializer'
|
51
|
+
require 'ledger_sync/deserializer'
|
52
|
+
require 'ledger_sync/serialization/deserializer_delegator'
|
53
|
+
require 'ledger_sync/serialization/serializer_delegator'
|
48
54
|
|
49
55
|
# Adaptors
|
50
56
|
Gem.find_files('ledger_sync/adaptors/mixins/**/*.rb').each { |path| require path }
|
51
57
|
require 'ledger_sync/adaptors/adaptor'
|
58
|
+
require 'ledger_sync/adaptors/dashboard_url_helper'
|
52
59
|
require 'ledger_sync/adaptors/searcher'
|
53
60
|
require 'ledger_sync/adaptors/ledger_serializer'
|
54
61
|
require 'ledger_sync/adaptors/operation'
|
@@ -146,5 +153,6 @@ LedgerSync.register_resource(resource: LedgerSync::Payment)
|
|
146
153
|
LedgerSync.register_resource(resource: LedgerSync::PaymentLineItem)
|
147
154
|
LedgerSync.register_resource(resource: LedgerSync::Transfer)
|
148
155
|
LedgerSync.register_resource(resource: LedgerSync::Vendor)
|
156
|
+
LedgerSync.register_resource(resource: LedgerSync::Location)
|
149
157
|
|
150
158
|
LedgerSync.register_resource(resource: LedgerSync::Adaptors::QuickBooksOnline::Preferences)
|