ledger_sync 1.1.3 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- 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 Vendor
|
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(:company_name).filled(:string)
|
14
|
+
required(:display_name).filled(:string)
|
15
|
+
optional(:first_name).maybe(:string)
|
16
|
+
optional(:last_name).maybe(:string)
|
17
|
+
optional(:email).maybe(:string)
|
18
|
+
optional(:phone_number).maybe(:string)
|
19
|
+
required(:subsidiary).filled(:hash, Types::Reference)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module Adaptors
|
5
|
+
module NetSuite
|
6
|
+
module Vendor
|
7
|
+
module Operations
|
8
|
+
class Delete < NetSuite::Operation::Delete
|
9
|
+
class Contract < LedgerSync::Adaptors::Contract
|
10
|
+
params do
|
11
|
+
optional(:external_id).maybe(:string)
|
12
|
+
required(:ledger_id).filled(:string)
|
13
|
+
optional(:company_name).maybe(:string)
|
14
|
+
optional(:display_name).maybe(:string)
|
15
|
+
optional(:first_name).maybe(:string)
|
16
|
+
optional(:last_name).maybe(:string)
|
17
|
+
optional(:email).maybe(:string)
|
18
|
+
optional(:phone_number).maybe(:string)
|
19
|
+
optional(:subsidiary).maybe(:hash, Types::Reference)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module Adaptors
|
5
|
+
module NetSuite
|
6
|
+
module Vendor
|
7
|
+
module Operations
|
8
|
+
class Find < NetSuite::Operation::Find
|
9
|
+
class Contract < LedgerSync::Adaptors::Contract
|
10
|
+
params do
|
11
|
+
optional(:external_id).maybe(:string)
|
12
|
+
required(:ledger_id).filled(:string)
|
13
|
+
optional(:company_name).maybe(:string)
|
14
|
+
optional(:display_name).maybe(:string)
|
15
|
+
optional(:first_name).maybe(:string)
|
16
|
+
optional(:last_name).maybe(:string)
|
17
|
+
optional(:email).maybe(:string)
|
18
|
+
optional(:phone_number).maybe(:string)
|
19
|
+
optional(:subsidiary).maybe(:hash, Types::Reference)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module Adaptors
|
5
|
+
module NetSuite
|
6
|
+
module Vendor
|
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(:company_name).filled(:string)
|
14
|
+
required(:display_name).filled(:string)
|
15
|
+
optional(:first_name).maybe(:string)
|
16
|
+
optional(:last_name).maybe(:string)
|
17
|
+
optional(:email).maybe(:string)
|
18
|
+
optional(:phone_number).maybe(:string)
|
19
|
+
required(:subsidiary).filled(:hash, Types::Reference)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'oauth2'
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module Adaptors
|
5
|
+
module NetSuiteSOAP
|
6
|
+
class Adaptor < Adaptors::Adaptor
|
7
|
+
DEFAULT_API_VERSION = '2016_2'.freeze
|
8
|
+
|
9
|
+
attr_reader :account_id,
|
10
|
+
:api_version,
|
11
|
+
:consumer_key,
|
12
|
+
:consumer_secret,
|
13
|
+
:account_id,
|
14
|
+
:token_id,
|
15
|
+
:token_secret
|
16
|
+
|
17
|
+
def initialize(
|
18
|
+
account_id:,
|
19
|
+
api_version: nil,
|
20
|
+
consumer_key:,
|
21
|
+
consumer_secret:,
|
22
|
+
token_id:,
|
23
|
+
token_secret:
|
24
|
+
)
|
25
|
+
@account_id = account_id
|
26
|
+
@api_version = api_version || DEFAULT_API_VERSION
|
27
|
+
@consumer_key = consumer_key
|
28
|
+
@consumer_secret = consumer_secret
|
29
|
+
@token_id = token_id
|
30
|
+
@token_secret = token_secret
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# Converts an account_id for use by the NetSuite gem
|
35
|
+
#
|
36
|
+
# @return [String] Converted account_id
|
37
|
+
#
|
38
|
+
def account_id_for_gem
|
39
|
+
account_id.downcase.split('-sb').join('_SB')
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
# Converts an account_id for use in the API URL
|
44
|
+
#
|
45
|
+
# @return [String] API URL compliant account_id
|
46
|
+
#
|
47
|
+
def account_id_for_url
|
48
|
+
account_id.downcase.split('_SB').join('-sb')
|
49
|
+
end
|
50
|
+
|
51
|
+
def setup
|
52
|
+
setup_account_id_for_gem = account_id_for_gem
|
53
|
+
setup_account_id_for_url = account_id_for_url
|
54
|
+
setup_api_version = api_version
|
55
|
+
setup_consumer_key = consumer_key
|
56
|
+
setup_consumer_secret = consumer_secret
|
57
|
+
setup_token_id = token_id
|
58
|
+
setup_token_secret = token_secret
|
59
|
+
|
60
|
+
::NetSuite.configure do
|
61
|
+
reset!
|
62
|
+
|
63
|
+
account setup_account_id_for_gem
|
64
|
+
consumer_key setup_consumer_key
|
65
|
+
consumer_secret setup_consumer_secret
|
66
|
+
token_id setup_token_id
|
67
|
+
token_secret setup_token_secret
|
68
|
+
api_version setup_api_version
|
69
|
+
wsdl_domain "#{setup_account_id_for_url}.suitetalk.api.netsuite.com"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def teardown
|
74
|
+
::NetSuite.configure do
|
75
|
+
reset!
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def wrap_perform
|
80
|
+
setup
|
81
|
+
yield
|
82
|
+
ensure
|
83
|
+
teardown
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.ledger_attributes_to_save
|
87
|
+
[]
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module LedgerSync
|
2
|
+
module Adaptors
|
3
|
+
module NetSuiteSOAP
|
4
|
+
module Customer
|
5
|
+
module Operations
|
6
|
+
class Create < NetSuiteSOAP::Operation::Create
|
7
|
+
class Contract < LedgerSync::Adaptors::Contract
|
8
|
+
params do
|
9
|
+
required(:external_id).maybe(:string)
|
10
|
+
required(:ledger_id).value(:nil)
|
11
|
+
required(:email).maybe(:string)
|
12
|
+
required(:name).filled(:string)
|
13
|
+
required(:phone_number).maybe(:string)
|
14
|
+
required(:subsidiary).hash(Types::Reference)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def operate
|
21
|
+
netsuite_subsidiary = ::NetSuite::Records::Subsidiary.get(
|
22
|
+
internal_id: resource.subsidiary.ledger_id
|
23
|
+
)
|
24
|
+
|
25
|
+
unless netsuite_subsidiary
|
26
|
+
return failure(
|
27
|
+
error: Error::OperationError.new(
|
28
|
+
message: "Subsidiary with ID '#{resource.subsidiary.ledger_id}' does not exist.",
|
29
|
+
operation: self
|
30
|
+
)
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
netsuite_resource = ::NetSuite::Records::Customer.new(
|
35
|
+
company_name: resource.name,
|
36
|
+
email: resource.email,
|
37
|
+
external_id: resource.external_id,
|
38
|
+
entity_id: resource.external_id,
|
39
|
+
first_name: resource.first_name,
|
40
|
+
last_name: resource.last_name,
|
41
|
+
phone: resource.phone_number,
|
42
|
+
subsidiary: netsuite_subsidiary
|
43
|
+
)
|
44
|
+
|
45
|
+
return netsuite_failure(netsuite_resource: netsuite_resource) unless netsuite_resource.add
|
46
|
+
|
47
|
+
resource.email = netsuite_resource.email
|
48
|
+
resource.external_id = netsuite_resource.external_id
|
49
|
+
resource.name = "#{netsuite_resource.first_name} #{netsuite_resource.last_name}"
|
50
|
+
resource.phone_number = netsuite_resource.phone
|
51
|
+
|
52
|
+
resource.ledger_id = netsuite_resource.internal_id
|
53
|
+
|
54
|
+
success(
|
55
|
+
resource: resource,
|
56
|
+
response: netsuite_resource
|
57
|
+
)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module Adaptors
|
5
|
+
module NetSuiteSOAP
|
6
|
+
module Customer
|
7
|
+
module Operations
|
8
|
+
class Find < NetSuiteSOAP::Operation::Find
|
9
|
+
class Contract < LedgerSync::Adaptors::Contract
|
10
|
+
params do
|
11
|
+
optional(:external_id).maybe(:string)
|
12
|
+
required(:ledger_id).filled(:string)
|
13
|
+
optional(:email).maybe(:string)
|
14
|
+
optional(:name).maybe(:string)
|
15
|
+
optional(:phone_number).maybe(:string)
|
16
|
+
required(:subsidiary).maybe(:hash, Types::Reference)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def operate
|
23
|
+
customer = ::NetSuite::Records::Customer.get(
|
24
|
+
internal_id: resource.ledger_id
|
25
|
+
)
|
26
|
+
|
27
|
+
resource.email = customer.email
|
28
|
+
resource.external_id = customer.external_id
|
29
|
+
resource.external_id = customer.internal_id
|
30
|
+
resource.name = if customer.is_person
|
31
|
+
"#{customer.first_name} #{customer.last_name}"
|
32
|
+
else
|
33
|
+
customer.company_name
|
34
|
+
end
|
35
|
+
resource.phone_number = customer.phone
|
36
|
+
|
37
|
+
resource.ledger_id = customer.internal_id
|
38
|
+
|
39
|
+
success(
|
40
|
+
resource: resource,
|
41
|
+
response: customer
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ledger_sync/adaptors/ledger_serializer'
|
4
|
+
|
5
|
+
module LedgerSync
|
6
|
+
module Adaptors
|
7
|
+
module NetSuiteSOAP
|
8
|
+
class LedgerSerializer < Adaptors::LedgerSerializer
|
9
|
+
def netsuite_lib_class
|
10
|
+
self.class.netsuite_lib_class
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.ledger_serializer_for(resource_class:)
|
14
|
+
NetSuite.const_get("#{resource_class.name.split('LedgerSync::')[1..-1].join('LedgerSync::')}::LedgerSerializer")
|
15
|
+
end
|
16
|
+
|
17
|
+
# This is used to map our internal resources to the netsuite gem
|
18
|
+
# resource
|
19
|
+
def self.netsuite_lib_class(lib_class = nil)
|
20
|
+
@netsuite_lib_class ||= lib_class
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module Adaptors
|
5
|
+
module NetSuiteSOAP
|
6
|
+
module Operation
|
7
|
+
module Mixin
|
8
|
+
def self.included(base)
|
9
|
+
base.include Adaptors::Operation::Mixin
|
10
|
+
base.include InstanceMethods
|
11
|
+
end
|
12
|
+
|
13
|
+
module InstanceMethods
|
14
|
+
def netsuite_resource_class
|
15
|
+
@netsuite_resource_class ||= ledger_serializer.class::NETSUITE_RESOURCE_CLASS
|
16
|
+
end
|
17
|
+
|
18
|
+
def netsuite_error(netsuite_resource:)
|
19
|
+
Error::OperationError.new(
|
20
|
+
message: netsuite_resource.errors.first.message,
|
21
|
+
operation: self,
|
22
|
+
response: netsuite_resource
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def netsuite_failure(netsuite_resource:)
|
27
|
+
failure(netsuite_error(netsuite_resource: netsuite_resource))
|
28
|
+
end
|
29
|
+
|
30
|
+
def perform
|
31
|
+
adaptor.wrap_perform do
|
32
|
+
super
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../operation'
|
4
|
+
|
5
|
+
module LedgerSync
|
6
|
+
module Adaptors
|
7
|
+
module NetSuiteSOAP
|
8
|
+
module Operation
|
9
|
+
class Create
|
10
|
+
include NetSuiteSOAP::Operation::Mixin
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def operate
|
15
|
+
response = adaptor.post(
|
16
|
+
resource: netsuite_online_resource_type,
|
17
|
+
payload: ledger_serializer.to_ledger_hash
|
18
|
+
)
|
19
|
+
|
20
|
+
success(
|
21
|
+
resource: ledger_serializer.deserialize(hash: response),
|
22
|
+
response: response
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|