ledger_sync-quickbooks_online 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.env.test +9 -0
- data/.gitignore +21 -0
- data/.overcommit.yml +29 -0
- data/.rubocop.yml +78 -0
- data/.rubocop_todo.yml +25 -0
- data/.travis.yml +25 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +211 -0
- data/README.md +19 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/quickbooks_online_oauth_server.rb +104 -0
- data/bin/setup +8 -0
- data/ledger_sync-quickbooks_online.gemspec +46 -0
- data/lib/ledger_sync/quickbooks_online.rb +14 -0
- data/lib/ledger_sync/quickbooks_online/account/deserializer.rb +29 -0
- data/lib/ledger_sync/quickbooks_online/account/operations/create.rb +26 -0
- data/lib/ledger_sync/quickbooks_online/account/operations/find.rb +26 -0
- data/lib/ledger_sync/quickbooks_online/account/operations/update.rb +28 -0
- data/lib/ledger_sync/quickbooks_online/account/searcher.rb +13 -0
- data/lib/ledger_sync/quickbooks_online/account/serializer.rb +29 -0
- data/lib/ledger_sync/quickbooks_online/account_based_expense_line_detail/deserializer.rb +19 -0
- data/lib/ledger_sync/quickbooks_online/account_based_expense_line_detail/serializer.rb +19 -0
- data/lib/ledger_sync/quickbooks_online/bill/deserializer.rb +39 -0
- data/lib/ledger_sync/quickbooks_online/bill/operations/create.rb +27 -0
- data/lib/ledger_sync/quickbooks_online/bill/operations/find.rb +27 -0
- data/lib/ledger_sync/quickbooks_online/bill/operations/update.rb +27 -0
- data/lib/ledger_sync/quickbooks_online/bill/searcher.rb +12 -0
- data/lib/ledger_sync/quickbooks_online/bill/serializer.rb +39 -0
- data/lib/ledger_sync/quickbooks_online/bill_line/deserializer.rb +20 -0
- data/lib/ledger_sync/quickbooks_online/bill_line/serializer.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/bill_payment/deserializer.rb +53 -0
- data/lib/ledger_sync/quickbooks_online/bill_payment/operations/create.rb +31 -0
- data/lib/ledger_sync/quickbooks_online/bill_payment/operations/find.rb +31 -0
- data/lib/ledger_sync/quickbooks_online/bill_payment/operations/update.rb +31 -0
- data/lib/ledger_sync/quickbooks_online/bill_payment/serializer.rb +53 -0
- data/lib/ledger_sync/quickbooks_online/bill_payment_line/deserializer.rb +14 -0
- data/lib/ledger_sync/quickbooks_online/bill_payment_line/serializer.rb +14 -0
- data/lib/ledger_sync/quickbooks_online/check_payment/deserializer.rb +15 -0
- data/lib/ledger_sync/quickbooks_online/check_payment/serializer.rb +15 -0
- data/lib/ledger_sync/quickbooks_online/client.rb +235 -0
- data/lib/ledger_sync/quickbooks_online/config.rb +15 -0
- data/lib/ledger_sync/quickbooks_online/credit_card_payment/deserializer.rb +15 -0
- data/lib/ledger_sync/quickbooks_online/credit_card_payment/serializer.rb +15 -0
- data/lib/ledger_sync/quickbooks_online/currency/deserializer.rb +14 -0
- data/lib/ledger_sync/quickbooks_online/currency/serializer.rb +15 -0
- data/lib/ledger_sync/quickbooks_online/customer/deserializer.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/customer/operations/create.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/customer/operations/find.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/customer/operations/update.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/customer/searcher.rb +13 -0
- data/lib/ledger_sync/quickbooks_online/customer/serializer.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/dashboard_url_helper.rb +32 -0
- data/lib/ledger_sync/quickbooks_online/department/deserializer.rb +20 -0
- data/lib/ledger_sync/quickbooks_online/department/operations/create.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/department/operations/find.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/department/operations/update.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/department/searcher.rb +15 -0
- data/lib/ledger_sync/quickbooks_online/department/serializer.rb +39 -0
- data/lib/ledger_sync/quickbooks_online/deposit/deserializer.rb +34 -0
- data/lib/ledger_sync/quickbooks_online/deposit/operations/create.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/deposit/operations/find.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/deposit/operations/update.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/deposit/searcher.rb +12 -0
- data/lib/ledger_sync/quickbooks_online/deposit/serializer.rb +34 -0
- data/lib/ledger_sync/quickbooks_online/deposit_line/deserializer.rb +20 -0
- data/lib/ledger_sync/quickbooks_online/deposit_line/serializer.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/deposit_line_detail/deserializer.rb +32 -0
- data/lib/ledger_sync/quickbooks_online/deposit_line_detail/serializer.rb +33 -0
- data/lib/ledger_sync/quickbooks_online/deserializer.rb +97 -0
- data/lib/ledger_sync/quickbooks_online/expense/deserializer.rb +52 -0
- data/lib/ledger_sync/quickbooks_online/expense/operations/create.rb +28 -0
- data/lib/ledger_sync/quickbooks_online/expense/operations/find.rb +28 -0
- data/lib/ledger_sync/quickbooks_online/expense/operations/update.rb +28 -0
- data/lib/ledger_sync/quickbooks_online/expense/searcher.rb +12 -0
- data/lib/ledger_sync/quickbooks_online/expense/serializer.rb +51 -0
- data/lib/ledger_sync/quickbooks_online/expense_line/deserializer.rb +20 -0
- data/lib/ledger_sync/quickbooks_online/expense_line/serializer.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/invoice/deserializer.rb +33 -0
- data/lib/ledger_sync/quickbooks_online/invoice/operations/create.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/invoice/operations/find.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/invoice/operations/update.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/invoice/serializer.rb +33 -0
- data/lib/ledger_sync/quickbooks_online/invoice_line/deserializer.rb +19 -0
- data/lib/ledger_sync/quickbooks_online/invoice_line/serializer.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/item/deserializer.rb +11 -0
- data/lib/ledger_sync/quickbooks_online/item/serializer.rb +10 -0
- data/lib/ledger_sync/quickbooks_online/journal_entry/deserializer.rb +26 -0
- data/lib/ledger_sync/quickbooks_online/journal_entry/operations/create.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/journal_entry/operations/find.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/journal_entry/operations/update.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/journal_entry/searcher.rb +12 -0
- data/lib/ledger_sync/quickbooks_online/journal_entry/serializer.rb +26 -0
- data/lib/ledger_sync/quickbooks_online/journal_entry_line/deserializer.rb +18 -0
- data/lib/ledger_sync/quickbooks_online/journal_entry_line/serializer.rb +22 -0
- data/lib/ledger_sync/quickbooks_online/journal_entry_line_detail/deserializer.rb +27 -0
- data/lib/ledger_sync/quickbooks_online/journal_entry_line_detail/serializer.rb +27 -0
- data/lib/ledger_sync/quickbooks_online/ledger_class/deserializer.rb +22 -0
- data/lib/ledger_sync/quickbooks_online/ledger_class/operations/create.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/ledger_class/operations/find.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/ledger_class/operations/update.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/ledger_class/searcher.rb +13 -0
- data/lib/ledger_sync/quickbooks_online/ledger_class/serializer.rb +22 -0
- data/lib/ledger_sync/quickbooks_online/oauth_client.rb +91 -0
- data/lib/ledger_sync/quickbooks_online/operation.rb +59 -0
- data/lib/ledger_sync/quickbooks_online/operation/create.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/operation/find.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/operation/full_update.rb +40 -0
- data/lib/ledger_sync/quickbooks_online/operation/sparse_update.rb +27 -0
- data/lib/ledger_sync/quickbooks_online/payment/deserializer.rb +40 -0
- data/lib/ledger_sync/quickbooks_online/payment/operations/create.rb +28 -0
- data/lib/ledger_sync/quickbooks_online/payment/operations/find.rb +28 -0
- data/lib/ledger_sync/quickbooks_online/payment/operations/update.rb +28 -0
- data/lib/ledger_sync/quickbooks_online/payment/serializer.rb +40 -0
- data/lib/ledger_sync/quickbooks_online/payment_line/deserializer.rb +15 -0
- data/lib/ledger_sync/quickbooks_online/payment_line/serializer.rb +15 -0
- data/lib/ledger_sync/quickbooks_online/preferences/deserializer.rb +22 -0
- data/lib/ledger_sync/quickbooks_online/preferences/operations/find.rb +28 -0
- data/lib/ledger_sync/quickbooks_online/preferences/serializer.rb +22 -0
- data/lib/ledger_sync/quickbooks_online/primary_email_addr/deserializer.rb +11 -0
- data/lib/ledger_sync/quickbooks_online/primary_email_addr/serializer.rb +11 -0
- data/lib/ledger_sync/quickbooks_online/primary_phone/deserializer.rb +11 -0
- data/lib/ledger_sync/quickbooks_online/primary_phone/serializer.rb +11 -0
- data/lib/ledger_sync/quickbooks_online/reference/deserializer.rb +11 -0
- data/lib/ledger_sync/quickbooks_online/reference/serializer.rb +11 -0
- data/lib/ledger_sync/quickbooks_online/request.rb +96 -0
- data/lib/ledger_sync/quickbooks_online/resource.rb +8 -0
- data/lib/ledger_sync/quickbooks_online/resources/account.rb +357 -0
- data/lib/ledger_sync/quickbooks_online/resources/account_based_expense_line_detail.rb +17 -0
- data/lib/ledger_sync/quickbooks_online/resources/bill.rb +29 -0
- data/lib/ledger_sync/quickbooks_online/resources/bill_line.rb +17 -0
- data/lib/ledger_sync/quickbooks_online/resources/bill_payment.rb +42 -0
- data/lib/ledger_sync/quickbooks_online/resources/bill_payment_line.rb +17 -0
- data/lib/ledger_sync/quickbooks_online/resources/check_payment.rb +11 -0
- data/lib/ledger_sync/quickbooks_online/resources/credit_card_payment.rb +11 -0
- data/lib/ledger_sync/quickbooks_online/resources/currency.rb +15 -0
- data/lib/ledger_sync/quickbooks_online/resources/customer.rb +22 -0
- data/lib/ledger_sync/quickbooks_online/resources/department.rb +20 -0
- data/lib/ledger_sync/quickbooks_online/resources/deposit.rb +26 -0
- data/lib/ledger_sync/quickbooks_online/resources/deposit_line.rb +17 -0
- data/lib/ledger_sync/quickbooks_online/resources/deposit_line_detail.rb +20 -0
- data/lib/ledger_sync/quickbooks_online/resources/expense.rb +38 -0
- data/lib/ledger_sync/quickbooks_online/resources/expense_line.rb +17 -0
- data/lib/ledger_sync/quickbooks_online/resources/invoice.rb +26 -0
- data/lib/ledger_sync/quickbooks_online/resources/invoice_line.rb +17 -0
- data/lib/ledger_sync/quickbooks_online/resources/item.rb +9 -0
- data/lib/ledger_sync/quickbooks_online/resources/journal_entry.rb +22 -0
- data/lib/ledger_sync/quickbooks_online/resources/journal_entry_line.rb +18 -0
- data/lib/ledger_sync/quickbooks_online/resources/journal_entry_line_detail.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/resources/ledger_class.rb +18 -0
- data/lib/ledger_sync/quickbooks_online/resources/payment.rb +29 -0
- data/lib/ledger_sync/quickbooks_online/resources/payment_line.rb +17 -0
- data/lib/ledger_sync/quickbooks_online/resources/preferences.rb +22 -0
- data/lib/ledger_sync/quickbooks_online/resources/primary_email_addr.rb +9 -0
- data/lib/ledger_sync/quickbooks_online/resources/primary_phone.rb +9 -0
- data/lib/ledger_sync/quickbooks_online/resources/sales_item_line_detail.rb +17 -0
- data/lib/ledger_sync/quickbooks_online/resources/transfer.rb +22 -0
- data/lib/ledger_sync/quickbooks_online/resources/vendor.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/sales_item_line_detail/deserializer.rb +19 -0
- data/lib/ledger_sync/quickbooks_online/sales_item_line_detail/serializer.rb +19 -0
- data/lib/ledger_sync/quickbooks_online/searcher.rb +58 -0
- data/lib/ledger_sync/quickbooks_online/serialization/type/amount_float_to_integer_type.rb +19 -0
- data/lib/ledger_sync/quickbooks_online/serialization/type/deserialize_transaction_reference_type.rb +28 -0
- data/lib/ledger_sync/quickbooks_online/serialization/type/integer_to_amount_float_type.rb +19 -0
- data/lib/ledger_sync/quickbooks_online/serialization/type/serialize_transaction_reference_type.rb +28 -0
- data/lib/ledger_sync/quickbooks_online/serializer.rb +69 -0
- data/lib/ledger_sync/quickbooks_online/serialziation/type/mapping_type.rb +27 -0
- data/lib/ledger_sync/quickbooks_online/transfer/deserializer.rb +29 -0
- data/lib/ledger_sync/quickbooks_online/transfer/operations/create.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/transfer/operations/find.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/transfer/operations/update.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/transfer/serializer.rb +29 -0
- data/lib/ledger_sync/quickbooks_online/util/error_matcher.rb +68 -0
- data/lib/ledger_sync/quickbooks_online/util/error_parser.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/util/ledger_error_parser.rb +101 -0
- data/lib/ledger_sync/quickbooks_online/util/operation_error_parser.rb +97 -0
- data/lib/ledger_sync/quickbooks_online/vendor/deserializer.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/vendor/operations/create.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/vendor/operations/find.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/vendor/operations/update.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/vendor/searcher.rb +13 -0
- data/lib/ledger_sync/quickbooks_online/vendor/serializer.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/version.rb +19 -0
- data/lib/ledger_sync/quickbooks_online/webhook.rb +56 -0
- data/lib/ledger_sync/quickbooks_online/webhook_event.rb +79 -0
- data/lib/ledger_sync/quickbooks_online/webhook_notification.rb +41 -0
- data/license.txt +4 -0
- metadata +456 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module QuickBooksOnline
|
5
|
+
class LedgerClass
|
6
|
+
module Operations
|
7
|
+
class Find < QuickBooksOnline::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(:Name).maybe(:string)
|
13
|
+
optional(:Active).maybe(:bool?)
|
14
|
+
optional(:SubClass).maybe(:bool?)
|
15
|
+
optional(:FullyQualifiedName).maybe(:string)
|
16
|
+
optional(:Parent).maybe(:hash, Types::Reference)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module QuickBooksOnline
|
5
|
+
class LedgerClass
|
6
|
+
module Operations
|
7
|
+
class Update < QuickBooksOnline::Operation::FullUpdate
|
8
|
+
class Contract < LedgerSync::Ledgers::Contract
|
9
|
+
params do
|
10
|
+
required(:external_id).maybe(:string)
|
11
|
+
required(:ledger_id).filled(:string)
|
12
|
+
required(:Name).filled(:string)
|
13
|
+
required(:Active).filled(:bool?)
|
14
|
+
required(:SubClass).filled(:bool?)
|
15
|
+
optional(:FullyQualifiedName).maybe(:string)
|
16
|
+
optional(:Parent).maybe(:hash, Types::Reference)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../reference/serializer'
|
4
|
+
|
5
|
+
module LedgerSync
|
6
|
+
module QuickBooksOnline
|
7
|
+
class LedgerClass
|
8
|
+
class Serializer < QuickBooksOnline::Serializer
|
9
|
+
id
|
10
|
+
|
11
|
+
attribute :Name
|
12
|
+
attribute :Active
|
13
|
+
attribute :SubClass
|
14
|
+
attribute :FullyQualifiedName
|
15
|
+
|
16
|
+
references_one 'ParentRef',
|
17
|
+
resource_attribute: :Parent,
|
18
|
+
serializer: Reference::Serializer
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module QuickBooksOnline
|
5
|
+
class OAuthClient
|
6
|
+
AUTHORIZE_URL = 'https://appcenter.intuit.com/connect/oauth2'
|
7
|
+
SITE_URL = 'https://appcenter.intuit.com/connect/oauth2'
|
8
|
+
TOKEN_URL = 'https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer'
|
9
|
+
|
10
|
+
class RedirectURIParser
|
11
|
+
attr_reader :uri
|
12
|
+
|
13
|
+
def initialize(uri:)
|
14
|
+
@uri = uri
|
15
|
+
end
|
16
|
+
|
17
|
+
def code
|
18
|
+
@code ||= query.fetch('code').first
|
19
|
+
end
|
20
|
+
|
21
|
+
def parsed_uri
|
22
|
+
@parsed_uri = URI.parse(uri)
|
23
|
+
end
|
24
|
+
|
25
|
+
def query
|
26
|
+
@query ||= CGI.parse(parsed_uri.query)
|
27
|
+
end
|
28
|
+
|
29
|
+
def realm_id
|
30
|
+
@realm_id ||= query.fetch('realmId').first
|
31
|
+
end
|
32
|
+
|
33
|
+
def redirect_uri
|
34
|
+
@redirect_uri ||= begin
|
35
|
+
use_uri = parsed_uri.dup
|
36
|
+
use_uri.fragment = nil
|
37
|
+
use_uri.query = nil
|
38
|
+
ret = use_uri.to_s
|
39
|
+
ret = ret[0..-2] if ret.end_with?('/')
|
40
|
+
ret
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
attr_reader :client_id,
|
46
|
+
:client_secret
|
47
|
+
|
48
|
+
def initialize(client_id:, client_secret:)
|
49
|
+
@client_id = client_id
|
50
|
+
@client_secret = client_secret
|
51
|
+
end
|
52
|
+
|
53
|
+
def authorization_url(redirect_uri:)
|
54
|
+
client.auth_code.authorize_url(
|
55
|
+
redirect_uri: redirect_uri,
|
56
|
+
response_type: 'code',
|
57
|
+
state: SecureRandom.hex(12),
|
58
|
+
scope: 'com.intuit.quickbooks.accounting'
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
def auth_code
|
63
|
+
client.auth_code
|
64
|
+
end
|
65
|
+
|
66
|
+
def client
|
67
|
+
@client ||= OAuth2::Client.new(
|
68
|
+
client_id,
|
69
|
+
client_secret,
|
70
|
+
authorize_url: AUTHORIZE_URL,
|
71
|
+
site: SITE_URL,
|
72
|
+
token_url: TOKEN_URL
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
def get_token(code:, redirect_uri:)
|
77
|
+
auth_code.get_token(
|
78
|
+
code,
|
79
|
+
redirect_uri: redirect_uri
|
80
|
+
)
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.new_from_env
|
84
|
+
new(
|
85
|
+
client_id: ENV.fetch('QUICKBOOKS_ONLINE_CLIENT_ID'),
|
86
|
+
client_secret: ENV.fetch('QUICKBOOKS_ONLINE_CLIENT_SECRET')
|
87
|
+
)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module QuickBooksOnline
|
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.body[quickbooks_online_resource_type.to_s.camelize],
|
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
|
+
quickbooks_online_resource_type.tr('_', '')
|
26
|
+
end
|
27
|
+
|
28
|
+
def response_to_operation_result(response:)
|
29
|
+
if response.success?
|
30
|
+
success(
|
31
|
+
resource: deserialized_resource(response: response),
|
32
|
+
response: response
|
33
|
+
)
|
34
|
+
else
|
35
|
+
failure(
|
36
|
+
Error::OperationError.new(
|
37
|
+
operation: self,
|
38
|
+
response: response
|
39
|
+
)
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def perform
|
45
|
+
super
|
46
|
+
rescue LedgerSync::Error::OperationError, OAuth2::Error => e
|
47
|
+
failure(e)
|
48
|
+
ensure
|
49
|
+
client.update_secrets_in_dotenv
|
50
|
+
end
|
51
|
+
|
52
|
+
def quickbooks_online_resource_type
|
53
|
+
@quickbooks_online_resource_type ||= client.class.ledger_resource_type_for(resource_class: resource.class)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../operation'
|
4
|
+
|
5
|
+
module LedgerSync
|
6
|
+
module QuickBooksOnline
|
7
|
+
class Operation
|
8
|
+
class Create
|
9
|
+
include QuickBooksOnline::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: serializer.serialize(resource: resource)
|
18
|
+
)
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../operation'
|
4
|
+
|
5
|
+
module LedgerSync
|
6
|
+
module QuickBooksOnline
|
7
|
+
class Operation
|
8
|
+
class Find
|
9
|
+
include QuickBooksOnline::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,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../operation'
|
4
|
+
|
5
|
+
module LedgerSync
|
6
|
+
module QuickBooksOnline
|
7
|
+
class Operation
|
8
|
+
class FullUpdate
|
9
|
+
include QuickBooksOnline::Operation::Mixin
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def find_resource
|
14
|
+
client.find(
|
15
|
+
path: ledger_resource_path
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
def operate
|
20
|
+
find_result_hash = find_resource.body[quickbooks_online_resource_type.to_s.classify]
|
21
|
+
merged_resource = deserializer.deserialize(
|
22
|
+
hash: find_result_hash,
|
23
|
+
merge_for_full_update: true,
|
24
|
+
resource: resource
|
25
|
+
)
|
26
|
+
merged_serializer = serializer.class.new
|
27
|
+
response_to_operation_result(
|
28
|
+
response: client.post(
|
29
|
+
path: ledger_resource_type_for_path,
|
30
|
+
payload: merged_serializer.serialize(
|
31
|
+
deep_merge_unmapped_values: find_result_hash,
|
32
|
+
resource: merged_resource
|
33
|
+
)
|
34
|
+
)
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../operation'
|
4
|
+
|
5
|
+
module LedgerSync
|
6
|
+
module QuickBooksOnline
|
7
|
+
class Operation
|
8
|
+
class SparseUpdate
|
9
|
+
include QuickBooksOnline::Operation::Mixin
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def operate
|
14
|
+
response = client.post(
|
15
|
+
resource: quickbooks_online_resource_type,
|
16
|
+
payload: merged_serializer.serialize
|
17
|
+
)
|
18
|
+
|
19
|
+
response_to_operation_result(
|
20
|
+
resource: serializer.deserialize(hash: response),
|
21
|
+
response: response
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../reference/deserializer'
|
4
|
+
require_relative '../payment_line/deserializer'
|
5
|
+
|
6
|
+
module LedgerSync
|
7
|
+
module QuickBooksOnline
|
8
|
+
class Payment
|
9
|
+
class Deserializer < QuickBooksOnline::Deserializer
|
10
|
+
id
|
11
|
+
|
12
|
+
amount :TotalAmt
|
13
|
+
attribute :PaymentRefNum
|
14
|
+
attribute :PrivateNote
|
15
|
+
attribute :ExchangeRate
|
16
|
+
date :TxnDate
|
17
|
+
|
18
|
+
references_one :Currency,
|
19
|
+
hash_attribute: 'CurrencyRef',
|
20
|
+
deserializer: Reference::Deserializer
|
21
|
+
|
22
|
+
references_one :Customer,
|
23
|
+
hash_attribute: 'CustomerRef',
|
24
|
+
deserializer: Reference::Deserializer
|
25
|
+
|
26
|
+
references_one :DepositToAccount,
|
27
|
+
hash_attribute: 'DepositToAccountRef',
|
28
|
+
deserializer: Reference::Deserializer
|
29
|
+
|
30
|
+
references_one :ARAccount,
|
31
|
+
hash_attribute: 'ARAccountRef',
|
32
|
+
deserializer: Account::Deserializer
|
33
|
+
|
34
|
+
references_many :Line,
|
35
|
+
hash_attribute: 'Line',
|
36
|
+
deserializer: PaymentLine::Deserializer
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module QuickBooksOnline
|
5
|
+
class Payment
|
6
|
+
module Operations
|
7
|
+
class Create < Operation::Create
|
8
|
+
class Contract < LedgerSync::Ledgers::Contract
|
9
|
+
params do
|
10
|
+
required(:external_id).maybe(:string)
|
11
|
+
optional(:ARAccount).hash(Types::Reference)
|
12
|
+
required(:Currency).filled(:hash, Types::Reference)
|
13
|
+
required(:Customer).hash(Types::Reference)
|
14
|
+
optional(:DepositToAccount).hash(Types::Reference)
|
15
|
+
optional(:ExchangeRate).maybe(:float)
|
16
|
+
required(:ledger_id).value(:nil)
|
17
|
+
required(:Line).array(Types::Reference)
|
18
|
+
optional(:PrivateNote).filled(:string)
|
19
|
+
optional(:PaymentRefNum).maybe(:string)
|
20
|
+
required(:TotalAmt).filled(:integer)
|
21
|
+
optional(:TxnDate).filled(:date?)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module QuickBooksOnline
|
5
|
+
class Payment
|
6
|
+
module Operations
|
7
|
+
class Find < Operation::Find
|
8
|
+
class Contract < LedgerSync::Ledgers::Contract
|
9
|
+
schema do
|
10
|
+
required(:external_id).maybe(:string)
|
11
|
+
optional(:ARAccount).hash(Types::Reference)
|
12
|
+
optional(:Currency).maybe(:hash, Types::Reference)
|
13
|
+
optional(:Customer).hash(Types::Reference)
|
14
|
+
optional(:DepositToAccount).hash(Types::Reference)
|
15
|
+
optional(:ExchangeRate).maybe(:float)
|
16
|
+
required(:ledger_id).filled(:string)
|
17
|
+
optional(:Line).array(Types::Reference)
|
18
|
+
optional(:PrivateNote).maybe(:string)
|
19
|
+
optional(:PaymentRefNum).maybe(:string)
|
20
|
+
optional(:TotalAmt).maybe(:integer)
|
21
|
+
optional(:TxnDate).maybe(:date?)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|