ledger_sync 1.1.3 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.env.template +25 -0
- data/.gitignore +3 -1
- data/.rubocop_todo.yml +4 -1
- data/.travis.yml +1 -1
- data/Gemfile.lock +59 -25
- data/README.md +160 -8
- data/_config.yml +1 -0
- data/bin/qa +3 -0
- data/ledger_sync.gemspec +4 -0
- data/lib/ledger_sync.rb +40 -30
- data/lib/ledger_sync/adaptor_configuration.rb +17 -11
- data/lib/ledger_sync/adaptor_configuration_store.rb +13 -9
- data/lib/ledger_sync/adaptors/adaptor.rb +9 -1
- data/lib/ledger_sync/adaptors/ledger_serializer.rb +3 -6
- data/lib/ledger_sync/adaptors/ledger_serializer_attribute_set.rb +1 -1
- data/lib/ledger_sync/adaptors/ledger_serializer_type/references_many_type.rb +1 -1
- data/lib/ledger_sync/adaptors/mixins/infer_adaptor_class_mixin.rb +24 -0
- data/lib/ledger_sync/adaptors/mixins/infer_ledger_serializer_mixin.rb +31 -0
- data/lib/ledger_sync/adaptors/mixins/infer_resource_class_mixin.rb +22 -0
- data/lib/ledger_sync/adaptors/mixins/offset_and_limit_pagination_searcher_mixin.rb +37 -0
- data/lib/ledger_sync/adaptors/netsuite/account/ledger_deserializer.rb +24 -0
- data/lib/ledger_sync/adaptors/netsuite/account/ledger_serializer.rb +22 -0
- data/lib/ledger_sync/adaptors/netsuite/account/operations/create.rb +28 -0
- data/lib/ledger_sync/adaptors/netsuite/account/operations/find.rb +28 -0
- data/lib/ledger_sync/adaptors/netsuite/account/searcher.rb +28 -0
- data/lib/ledger_sync/adaptors/netsuite/adaptor.rb +145 -0
- data/lib/ledger_sync/adaptors/netsuite/config.rb +6 -0
- data/lib/ledger_sync/adaptors/netsuite/currency/deledger_serializer.rb +28 -0
- data/lib/ledger_sync/adaptors/netsuite/currency/ledger_serializer.rb +25 -0
- data/lib/ledger_sync/adaptors/netsuite/currency/operations/create.rb +25 -0
- data/lib/ledger_sync/adaptors/netsuite/currency/operations/delete.rb +23 -0
- data/lib/ledger_sync/adaptors/netsuite/currency/operations/find.rb +23 -0
- data/lib/ledger_sync/adaptors/netsuite/currency/operations/update.rb +23 -0
- data/lib/ledger_sync/adaptors/netsuite/customer/ledger_deserializer.rb +27 -0
- data/lib/ledger_sync/adaptors/netsuite/customer/ledger_serializer.rb +38 -0
- data/lib/ledger_sync/adaptors/netsuite/customer/operations/create.rb +24 -0
- data/lib/ledger_sync/adaptors/netsuite/customer/operations/delete.rb +24 -0
- data/lib/ledger_sync/adaptors/netsuite/customer/operations/find.rb +24 -0
- data/lib/ledger_sync/adaptors/netsuite/customer/operations/update.rb +24 -0
- data/lib/ledger_sync/adaptors/netsuite/ledger_serializer.rb +30 -0
- data/lib/ledger_sync/adaptors/netsuite/ledger_serializer_type/reference_type.rb +24 -0
- data/lib/ledger_sync/adaptors/netsuite/ledger_serializer_type/subsidiary_type.rb +22 -0
- data/lib/ledger_sync/adaptors/netsuite/operation.rb +25 -0
- data/lib/ledger_sync/adaptors/netsuite/operation/create.rb +65 -0
- data/lib/ledger_sync/adaptors/netsuite/operation/delete.rb +49 -0
- data/lib/ledger_sync/adaptors/netsuite/operation/find.rb +56 -0
- data/lib/ledger_sync/adaptors/netsuite/operation/update.rb +68 -0
- data/lib/ledger_sync/adaptors/netsuite/record/http_method.rb +38 -0
- data/lib/ledger_sync/adaptors/netsuite/record/metadata.rb +75 -0
- data/lib/ledger_sync/adaptors/netsuite/record/property.rb +45 -0
- data/lib/ledger_sync/adaptors/netsuite/searcher.rb +17 -0
- data/lib/ledger_sync/adaptors/netsuite/token.rb +162 -0
- data/lib/ledger_sync/adaptors/netsuite/vendor/ledger_deserializer.rb +32 -0
- data/lib/ledger_sync/adaptors/netsuite/vendor/ledger_serializer.rb +35 -0
- data/lib/ledger_sync/adaptors/netsuite/vendor/operations/create.rb +27 -0
- data/lib/ledger_sync/adaptors/netsuite/vendor/operations/delete.rb +27 -0
- data/lib/ledger_sync/adaptors/netsuite/vendor/operations/find.rb +27 -0
- data/lib/ledger_sync/adaptors/netsuite/vendor/operations/update.rb +27 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/adaptor.rb +92 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/config.rb +5 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/customer/ledger_serializer.rb +13 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/customer/operations/create.rb +64 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/customer/operations/find.rb +49 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/ledger_serializer.rb +25 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/operation.rb +40 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/operation/create.rb +29 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/operation/find.rb +15 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/subsidiary/operations/create.rb +42 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/subsidiary/operations/find.rb +38 -0
- data/lib/ledger_sync/adaptors/operation.rb +7 -11
- data/lib/ledger_sync/adaptors/quickbooks_online/account/searcher.rb +2 -13
- data/lib/ledger_sync/adaptors/quickbooks_online/adaptor.rb +158 -109
- data/lib/ledger_sync/adaptors/quickbooks_online/bill/searcher.rb +1 -15
- data/lib/ledger_sync/adaptors/quickbooks_online/config.rb +3 -2
- data/lib/ledger_sync/adaptors/quickbooks_online/customer/operations/create.rb +1 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/customer/operations/find.rb +1 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/customer/operations/update.rb +1 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/customer/searcher.rb +2 -16
- data/lib/ledger_sync/adaptors/quickbooks_online/dashboard_url_helper.rb +57 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/department/ledger_serializer.rb +38 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/department/operations/create.rb +23 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/department/operations/find.rb +23 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/department/operations/update.rb +25 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/department/searcher.rb +17 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/deposit/ledger_serializer.rb +3 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/deposit/operations/create.rb +1 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/deposit/operations/find.rb +1 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/deposit/operations/update.rb +1 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/deposit/searcher.rb +0 -15
- data/lib/ledger_sync/adaptors/quickbooks_online/expense/ledger_serializer.rb +0 -2
- data/lib/ledger_sync/adaptors/quickbooks_online/expense/searcher.rb +1 -15
- data/lib/ledger_sync/adaptors/quickbooks_online/invoice/ledger_serializer.rb +35 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/invoice/operations/create.rb +27 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/invoice/operations/find.rb +25 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/invoice/operations/update.rb +25 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/invoice_sales_line_item/ledger_serializer.rb +30 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/item/ledger_serializer.rb +13 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/journal_entry/searcher.rb +1 -15
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_class/ledger_serializer.rb +25 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_class/operations/create.rb +23 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_class/operations/find.rb +23 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_class/operations/update.rb +25 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_class/searcher.rb +15 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer.rb +8 -5
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/entity_reference_type.rb +4 -14
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/transaction_reference_type.rb +49 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/oauth_client.rb +93 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/operation.rb +42 -7
- data/lib/ledger_sync/adaptors/quickbooks_online/operation/create.rb +5 -8
- data/lib/ledger_sync/adaptors/quickbooks_online/operation/find.rb +9 -9
- data/lib/ledger_sync/adaptors/quickbooks_online/operation/full_update.rb +17 -15
- data/lib/ledger_sync/adaptors/quickbooks_online/payment/ledger_serializer.rb +25 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/payment/operations/create.rb +9 -6
- data/lib/ledger_sync/adaptors/quickbooks_online/payment/operations/find.rb +9 -2
- data/lib/ledger_sync/adaptors/quickbooks_online/payment/operations/update.rb +8 -1
- data/lib/ledger_sync/adaptors/quickbooks_online/payment_line_item/ledger_serializer.rb +19 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/request.rb +98 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/searcher.rb +29 -13
- data/lib/ledger_sync/adaptors/quickbooks_online/util/operation_error_parser.rb +1 -1
- data/lib/ledger_sync/adaptors/quickbooks_online/vendor/operations/create.rb +3 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/vendor/operations/find.rb +3 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/vendor/operations/update.rb +3 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/vendor/searcher.rb +5 -54
- data/lib/ledger_sync/adaptors/quickbooks_online/webhook.rb +58 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/webhook_event.rb +79 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/webhook_notification.rb +42 -0
- data/lib/ledger_sync/adaptors/request.rb +53 -0
- data/lib/ledger_sync/adaptors/response.rb +55 -0
- data/lib/ledger_sync/adaptors/searcher.rb +3 -1
- data/lib/ledger_sync/adaptors/stripe/adaptor.rb +45 -0
- data/lib/ledger_sync/adaptors/stripe/config.rb +6 -0
- data/lib/ledger_sync/adaptors/stripe/customer/operations/create.rb +44 -0
- data/lib/ledger_sync/adaptors/stripe/customer/operations/delete.rb +35 -0
- data/lib/ledger_sync/adaptors/stripe/customer/operations/find.rb +44 -0
- data/lib/ledger_sync/adaptors/stripe/customer/operations/update.rb +43 -0
- data/lib/ledger_sync/adaptors/stripe/operation.rb +35 -0
- data/lib/ledger_sync/adaptors/stripe/operation/create.rb +17 -0
- data/lib/ledger_sync/adaptors/stripe/operation/delete.rb +17 -0
- data/lib/ledger_sync/adaptors/stripe/operation/find.rb +15 -0
- data/lib/ledger_sync/adaptors/stripe/operation/update.rb +17 -0
- data/lib/ledger_sync/adaptors/test/config.rb +0 -1
- data/lib/ledger_sync/adaptors/test/customer/operations/create.rb +1 -0
- data/lib/ledger_sync/adaptors/test/customer/operations/find.rb +1 -0
- data/lib/ledger_sync/adaptors/test/customer/operations/invalid.rb +1 -0
- data/lib/ledger_sync/adaptors/test/customer/operations/update.rb +1 -0
- data/lib/ledger_sync/adaptors/test/customer/operations/valid.rb +1 -0
- data/lib/ledger_sync/adaptors/test/payment/operations/create.rb +8 -1
- data/lib/ledger_sync/adaptors/test/payment/operations/find.rb +9 -2
- data/lib/ledger_sync/adaptors/test/payment/operations/update.rb +9 -5
- data/lib/ledger_sync/adaptors/test/vendor/operations/create.rb +5 -0
- data/lib/ledger_sync/adaptors/test/vendor/operations/find.rb +3 -0
- data/lib/ledger_sync/adaptors/test/vendor/operations/invalid.rb +5 -0
- data/lib/ledger_sync/adaptors/test/vendor/operations/update.rb +5 -0
- data/lib/ledger_sync/adaptors/test/vendor/operations/valid.rb +5 -0
- data/lib/ledger_sync/error/adaptor_errors.rb +18 -5
- data/lib/ledger_sync/error/operation_errors.rb +13 -4
- data/lib/ledger_sync/resource.rb +6 -0
- data/lib/ledger_sync/resource_attribute/dirty_mixin.rb +16 -15
- data/lib/ledger_sync/resources/bill.rb +7 -1
- data/lib/ledger_sync/resources/bill_line_item.rb +2 -0
- data/lib/ledger_sync/resources/currency.rb +9 -0
- data/lib/ledger_sync/resources/customer.rb +16 -0
- data/lib/ledger_sync/resources/department.rb +14 -0
- data/lib/ledger_sync/resources/deposit.rb +7 -0
- data/lib/ledger_sync/resources/deposit_line_item.rb +6 -0
- data/lib/ledger_sync/resources/expense.rb +5 -0
- data/lib/ledger_sync/resources/expense_line_item.rb +2 -0
- data/lib/ledger_sync/resources/invoice.rb +23 -0
- data/lib/ledger_sync/resources/invoice_sales_line_item.rb +17 -0
- data/lib/ledger_sync/resources/item.rb +5 -0
- data/lib/ledger_sync/resources/journal_entry.rb +5 -1
- data/lib/ledger_sync/resources/journal_entry_line_item.rb +4 -0
- data/lib/ledger_sync/resources/ledger_class.rb +14 -0
- data/lib/ledger_sync/resources/payment.rb +13 -0
- data/lib/ledger_sync/resources/payment_line_item.rb +15 -0
- data/lib/ledger_sync/resources/subsidiary.rb +8 -0
- data/lib/ledger_sync/resources/transfer.rb +4 -0
- data/lib/ledger_sync/resources/vendor.rb +9 -2
- data/lib/ledger_sync/type/reference_many.rb +12 -1
- data/lib/ledger_sync/type/reference_one.rb +1 -1
- data/lib/ledger_sync/util/resonad.rb +18 -0
- data/lib/ledger_sync/util/signer.rb +36 -0
- data/lib/ledger_sync/util/string_helpers.rb +12 -12
- data/lib/ledger_sync/version.rb +1 -1
- data/qa/env_spec.rb +5 -0
- data/qa/netsuite/account_spec.rb +20 -0
- data/qa/netsuite/currency_spec.rb +16 -0
- data/qa/netsuite/customer.rb +76 -0
- data/qa/netsuite/customer_spec.rb +21 -0
- data/qa/netsuite/vendor.rb +76 -0
- data/qa/netsuite/vendor_spec.rb +23 -0
- data/qa/netsuite_soap/customer_spec.rb +21 -0
- data/qa/netsuite_soap/subsidiary_spec.rb +0 -0
- data/qa/netsuite_test.rb +42 -0
- data/qa/qa_helper.rb +58 -0
- data/qa/quickbooks_online/account_spec.rb +14 -0
- data/qa/quickbooks_online/customer_spec.rb +13 -0
- data/qa/quickbooks_online/expense_spec.rb +31 -0
- data/qa/quickbooks_online/vendor_spec.rb +13 -0
- data/qa/stripe/customers_spec.rb +15 -0
- data/qa/support/adaptor_helpers.rb +99 -0
- data/qa/support/adaptor_support_setup.rb +23 -0
- data/qa/support/netsuite_helpers.rb +33 -0
- data/qa/support/netsuite_shared_examples.rb +30 -0
- data/qa/support/netsuite_soap_helpers.rb +33 -0
- data/qa/support/netsuite_soap_shared_examples.rb +10 -0
- data/qa/support/quickbooks_online_helpers.rb +42 -0
- data/qa/support/quickbooks_online_shared_examples.rb +82 -0
- data/qa/support/shared_examples.rb +127 -0
- data/qa/support/stripe_helpers.rb +22 -0
- data/qa/support/stripe_shared_examples.rb +10 -0
- data/qa/test.rb +67 -0
- data/release.sh +13 -1
- metadata +189 -3
- data/qa.rb +0 -142
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module LedgerSync
|
|
4
|
+
module Adaptors
|
|
5
|
+
module NetSuite
|
|
6
|
+
module Customer
|
|
7
|
+
class LedgerDeserializer < NetSuite::LedgerSerializer
|
|
8
|
+
attribute ledger_attribute: :id,
|
|
9
|
+
resource_attribute: :ledger_id
|
|
10
|
+
|
|
11
|
+
attribute ledger_attribute: :companyName,
|
|
12
|
+
resource_attribute: :name
|
|
13
|
+
|
|
14
|
+
attribute ledger_attribute: :email,
|
|
15
|
+
resource_attribute: :email
|
|
16
|
+
|
|
17
|
+
attribute ledger_attribute: :phone,
|
|
18
|
+
resource_attribute: :phone_number
|
|
19
|
+
|
|
20
|
+
attribute ledger_attribute: :subsidiary,
|
|
21
|
+
resource_attribute: :subsidiary,
|
|
22
|
+
type: LedgerSerializerType::SubsidiaryType
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module LedgerSync
|
|
4
|
+
module Adaptors
|
|
5
|
+
module NetSuite
|
|
6
|
+
module Customer
|
|
7
|
+
class LedgerSerializer < NetSuite::LedgerSerializer
|
|
8
|
+
api_resource_type :customer
|
|
9
|
+
|
|
10
|
+
attribute ledger_attribute: :companyName,
|
|
11
|
+
resource_attribute: :name
|
|
12
|
+
|
|
13
|
+
attribute ledger_attribute: :entityId,
|
|
14
|
+
resource_attribute: :external_id
|
|
15
|
+
|
|
16
|
+
attribute ledger_attribute: :externalId,
|
|
17
|
+
resource_attribute: :external_id
|
|
18
|
+
|
|
19
|
+
attribute ledger_attribute: :email,
|
|
20
|
+
resource_attribute: :email
|
|
21
|
+
|
|
22
|
+
attribute ledger_attribute: :phone,
|
|
23
|
+
resource_attribute: :phone_number
|
|
24
|
+
|
|
25
|
+
# attribute ledger_attribute: :firstName,
|
|
26
|
+
# resource_attribute: :first_name
|
|
27
|
+
|
|
28
|
+
# attribute ledger_attribute: :lastName,
|
|
29
|
+
# resource_attribute: :last_name
|
|
30
|
+
|
|
31
|
+
attribute ledger_attribute: :subsidiary,
|
|
32
|
+
resource_attribute: :subsidiary,
|
|
33
|
+
type: LedgerSerializerType::ReferenceType
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module LedgerSync
|
|
4
|
+
module Adaptors
|
|
5
|
+
module NetSuite
|
|
6
|
+
module Customer
|
|
7
|
+
module Operations
|
|
8
|
+
class Create < NetSuite::Operation::Create
|
|
9
|
+
class Contract < LedgerSync::Adaptors::Contract
|
|
10
|
+
params do
|
|
11
|
+
required(:external_id).maybe(:string)
|
|
12
|
+
required(:ledger_id).value(:nil)
|
|
13
|
+
required(:email).maybe(:string)
|
|
14
|
+
required(:name).filled(:string)
|
|
15
|
+
required(:phone_number).maybe(:string)
|
|
16
|
+
required(:subsidiary).filled(:hash, Types::Reference)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module LedgerSync
|
|
4
|
+
module Adaptors
|
|
5
|
+
module NetSuite
|
|
6
|
+
module Customer
|
|
7
|
+
module Operations
|
|
8
|
+
class Delete < NetSuite::Operation::Delete
|
|
9
|
+
class Contract < LedgerSync::Adaptors::Contract
|
|
10
|
+
params do
|
|
11
|
+
required(:external_id).maybe(:string)
|
|
12
|
+
required(:ledger_id).filled(:string)
|
|
13
|
+
required(:email).maybe(:string)
|
|
14
|
+
required(:name).maybe(:string)
|
|
15
|
+
required(:phone_number).maybe(:string)
|
|
16
|
+
required(:subsidiary).maybe(:hash, Types::Reference)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module LedgerSync
|
|
4
|
+
module Adaptors
|
|
5
|
+
module NetSuite
|
|
6
|
+
module Customer
|
|
7
|
+
module Operations
|
|
8
|
+
class Find < NetSuite::Operation::Find
|
|
9
|
+
class Contract < LedgerSync::Adaptors::Contract
|
|
10
|
+
params do
|
|
11
|
+
required(:external_id).maybe(:string)
|
|
12
|
+
required(:ledger_id).filled(:string)
|
|
13
|
+
required(:email).maybe(:string)
|
|
14
|
+
required(:name).maybe(:string)
|
|
15
|
+
required(:phone_number).maybe(:string)
|
|
16
|
+
required(:subsidiary).maybe(:hash, Types::Reference)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module LedgerSync
|
|
4
|
+
module Adaptors
|
|
5
|
+
module NetSuite
|
|
6
|
+
module Customer
|
|
7
|
+
module Operations
|
|
8
|
+
class Update < NetSuite::Operation::Update
|
|
9
|
+
class Contract < LedgerSync::Adaptors::Contract
|
|
10
|
+
params do
|
|
11
|
+
required(:external_id).maybe(:string)
|
|
12
|
+
required(:ledger_id).filled(:string)
|
|
13
|
+
required(:email).maybe(:string)
|
|
14
|
+
required(:name).filled(:string)
|
|
15
|
+
required(:phone_number).maybe(:string)
|
|
16
|
+
required(:subsidiary).filled(:hash, Types::Reference)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'ledger_sync/adaptors/ledger_serializer'
|
|
4
|
+
Gem.find_files('ledger_sync/adaptors/netsuite/ledger_serializer_type/**/*.rb').each { |path| require path } # require adaptor-specific types
|
|
5
|
+
|
|
6
|
+
module LedgerSync
|
|
7
|
+
module Adaptors
|
|
8
|
+
module NetSuite
|
|
9
|
+
class LedgerSerializer < Adaptors::LedgerSerializer
|
|
10
|
+
def self.api_resource_path(resource: nil)
|
|
11
|
+
raise 'Resource ledger_id is required to build API request path' if resource.present? && resource.ledger_id.blank?
|
|
12
|
+
|
|
13
|
+
ret = "record/#{api_resource_type}"
|
|
14
|
+
ret += "/#{resource.ledger_id}" if resource.present?
|
|
15
|
+
ret
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.api_resource_type(val = nil)
|
|
19
|
+
raise 'api_resource_type already set' if @api_resource_type.present? && val.present?
|
|
20
|
+
|
|
21
|
+
@api_resource_type ||= val
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.id(**keywords)
|
|
25
|
+
super({ ledger_attribute: 'id', resource_attribute: :ledger_id }.merge(keywords))
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module LedgerSync
|
|
4
|
+
module Adaptors
|
|
5
|
+
module NetSuite
|
|
6
|
+
module LedgerSerializerType
|
|
7
|
+
class ReferenceType < Adaptors::LedgerSerializerType::ValueType
|
|
8
|
+
def convert_from_ledger(value:)
|
|
9
|
+
raise NotImplementedError
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def convert_from_local(value:)
|
|
13
|
+
return if value.nil?
|
|
14
|
+
raise "Resource expected. Given: #{value.class.name}" unless value.is_a?(LedgerSync::Resource)
|
|
15
|
+
|
|
16
|
+
{
|
|
17
|
+
'id' => value.ledger_id
|
|
18
|
+
}
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'reference_type'
|
|
4
|
+
|
|
5
|
+
module LedgerSync
|
|
6
|
+
module Adaptors
|
|
7
|
+
module NetSuite
|
|
8
|
+
module LedgerSerializerType
|
|
9
|
+
class SubsidiaryType < ReferenceType
|
|
10
|
+
def convert_from_ledger(value:)
|
|
11
|
+
return if value.nil?
|
|
12
|
+
raise "Resource hash. Given: #{value.class.name}" unless value.is_a?(Hash)
|
|
13
|
+
|
|
14
|
+
Subsidiary.new(
|
|
15
|
+
ledger_id: value.fetch('id', nil)
|
|
16
|
+
)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module LedgerSync
|
|
4
|
+
module Adaptors
|
|
5
|
+
module NetSuite
|
|
6
|
+
module Operation
|
|
7
|
+
module Mixin
|
|
8
|
+
def self.included(base)
|
|
9
|
+
base.include Adaptors::Operation::Mixin
|
|
10
|
+
base.include InstanceMethods # To ensure these override parent methods
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
module InstanceMethods
|
|
14
|
+
def ledger_deserializer
|
|
15
|
+
@ledger_deserializer ||= begin
|
|
16
|
+
modules = self.class.name.split('::Operations::').first
|
|
17
|
+
Object.const_get("#{modules}::LedgerDeserializer").new(resource: resource)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../operation'
|
|
4
|
+
|
|
5
|
+
module LedgerSync
|
|
6
|
+
module Adaptors
|
|
7
|
+
module NetSuite
|
|
8
|
+
module Operation
|
|
9
|
+
class Create
|
|
10
|
+
include NetSuite::Operation::Mixin
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def create_in_ledger
|
|
15
|
+
return LedgerSync::Result.Success(response) if response.success?
|
|
16
|
+
|
|
17
|
+
failure(
|
|
18
|
+
Error::OperationError.new(
|
|
19
|
+
operation: self,
|
|
20
|
+
response: response
|
|
21
|
+
)
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def find
|
|
26
|
+
resource.ledger_id = ledger_id
|
|
27
|
+
|
|
28
|
+
self.class.operations_module::Find.new(
|
|
29
|
+
adaptor: adaptor,
|
|
30
|
+
resource: resource
|
|
31
|
+
).perform
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def ledger_id
|
|
35
|
+
@ledger_id ||= response.headers['Location'].split('/').last
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def operate
|
|
39
|
+
create_in_ledger
|
|
40
|
+
.and_then { success }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def response
|
|
44
|
+
ledger_hash = ledger_serializer.to_ledger_hash
|
|
45
|
+
ledger_hash.delete('entityId')
|
|
46
|
+
|
|
47
|
+
@response ||= adaptor.post(
|
|
48
|
+
body: ledger_hash,
|
|
49
|
+
path: ledger_serializer.class.api_resource_path
|
|
50
|
+
)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def success
|
|
54
|
+
find.and_then do |find_result|
|
|
55
|
+
super(
|
|
56
|
+
resource: find_result.resource,
|
|
57
|
+
response: response
|
|
58
|
+
)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../operation'
|
|
4
|
+
|
|
5
|
+
module LedgerSync
|
|
6
|
+
module Adaptors
|
|
7
|
+
module NetSuite
|
|
8
|
+
module Operation
|
|
9
|
+
class Delete
|
|
10
|
+
include NetSuite::Operation::Mixin
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def delete
|
|
15
|
+
case response.status
|
|
16
|
+
when 200..299
|
|
17
|
+
LedgerSync::Result.Success(response)
|
|
18
|
+
else
|
|
19
|
+
failure(
|
|
20
|
+
Error::OperationError.new(
|
|
21
|
+
operation: self,
|
|
22
|
+
response: response
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def operate
|
|
29
|
+
delete
|
|
30
|
+
.and_then { success }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def response
|
|
34
|
+
@response ||= adaptor.delete(
|
|
35
|
+
path: ledger_serializer.class.api_resource_path(resource: resource)
|
|
36
|
+
)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def success
|
|
40
|
+
super(
|
|
41
|
+
resource: resource,
|
|
42
|
+
response: response
|
|
43
|
+
)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../operation'
|
|
4
|
+
|
|
5
|
+
module LedgerSync
|
|
6
|
+
module Adaptors
|
|
7
|
+
module NetSuite
|
|
8
|
+
module Operation
|
|
9
|
+
class Find
|
|
10
|
+
include NetSuite::Operation::Mixin
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def find_in_ledger
|
|
15
|
+
case response.status
|
|
16
|
+
when 200
|
|
17
|
+
LedgerSync::Result.Success(response)
|
|
18
|
+
when 404
|
|
19
|
+
failure(
|
|
20
|
+
Error::OperationError::NotFoundError.new(
|
|
21
|
+
operation: self,
|
|
22
|
+
response: response
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
else
|
|
26
|
+
failure(
|
|
27
|
+
Error::OperationError.new(
|
|
28
|
+
operation: self,
|
|
29
|
+
response: response
|
|
30
|
+
)
|
|
31
|
+
)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def operate
|
|
36
|
+
find_in_ledger
|
|
37
|
+
.and_then { success }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def response
|
|
41
|
+
@response ||= adaptor.get(
|
|
42
|
+
path: ledger_serializer.class.api_resource_path(resource: resource)
|
|
43
|
+
)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def success
|
|
47
|
+
super(
|
|
48
|
+
resource: ledger_deserializer.deserialize(hash: response.body),
|
|
49
|
+
response: response
|
|
50
|
+
)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|