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
data/lib/ledger_sync/version.rb
CHANGED
data/qa/env_spec.rb
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe LedgerSync::Adaptors::NetSuite::Account, adaptor: :netsuite do
|
|
4
|
+
let(:adaptor) { netsuite_adaptor }
|
|
5
|
+
let(:attribute_updates) do
|
|
6
|
+
{
|
|
7
|
+
name: "QA UPDATE #{test_run_id}"
|
|
8
|
+
}
|
|
9
|
+
end
|
|
10
|
+
let(:record) { :customer }
|
|
11
|
+
let(:resource) do
|
|
12
|
+
LedgerSync::Account.new(
|
|
13
|
+
name: "Test Account #{test_run_id}"
|
|
14
|
+
)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# it_behaves_like 'a full netsuite resource'
|
|
18
|
+
it_behaves_like 'a record with metadata'
|
|
19
|
+
it_behaves_like 'a find'
|
|
20
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe LedgerSync::Adaptors::NetSuite::Currency, adaptor: :netsuite do
|
|
4
|
+
let(:adaptor) { netsuite_adaptor }
|
|
5
|
+
let(:attribute_updates) do
|
|
6
|
+
{
|
|
7
|
+
name: "QA UPDATE #{test_run_id}"
|
|
8
|
+
}
|
|
9
|
+
end
|
|
10
|
+
let(:record) { :currency }
|
|
11
|
+
let(:resource) do
|
|
12
|
+
FactoryBot.create(:currency)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it_behaves_like 'a full netsuite resource'
|
|
16
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module QA
|
|
4
|
+
module NetSuite
|
|
5
|
+
module Customer
|
|
6
|
+
def customer_create
|
|
7
|
+
perform(
|
|
8
|
+
LedgerSync::Adaptors::NetSuite::Customer::Operations::Create.new(
|
|
9
|
+
adaptor: adaptor,
|
|
10
|
+
resource: new_customer(
|
|
11
|
+
subsidiary: existing_netsuite_subsidiary
|
|
12
|
+
)
|
|
13
|
+
)
|
|
14
|
+
)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def customer_delete(customer:)
|
|
18
|
+
perform(
|
|
19
|
+
LedgerSync::Adaptors::NetSuite::Customer::Operations::Delete.new(
|
|
20
|
+
adaptor: adaptor,
|
|
21
|
+
resource: customer
|
|
22
|
+
)
|
|
23
|
+
)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def customer_delete_nonexisting(customer:)
|
|
27
|
+
result = LedgerSync::Adaptors::NetSuite::Customer::Operations::Delete.new(
|
|
28
|
+
adaptor: adaptor,
|
|
29
|
+
resource: customer
|
|
30
|
+
).perform
|
|
31
|
+
|
|
32
|
+
unless result.failure?
|
|
33
|
+
pdb 'Should be failure'
|
|
34
|
+
byebug
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
LedgerSync::Result.Success
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def customer_find(customer:)
|
|
41
|
+
perform(
|
|
42
|
+
LedgerSync::Adaptors::NetSuite::Customer::Operations::Find.new(
|
|
43
|
+
adaptor: adaptor,
|
|
44
|
+
resource: customer
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def customer_update(customer:)
|
|
50
|
+
name = "QA UPDATE #{test_run_id}"
|
|
51
|
+
customer.name = name
|
|
52
|
+
|
|
53
|
+
result = perform(
|
|
54
|
+
LedgerSync::Adaptors::NetSuite::Customer::Operations::Update.new(
|
|
55
|
+
adaptor: adaptor,
|
|
56
|
+
resource: customer
|
|
57
|
+
)
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
byebug if result.resource.name != name
|
|
61
|
+
result
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def schema_customer
|
|
65
|
+
schema = adaptor.base_module::Record::Metadata.new(
|
|
66
|
+
adaptor: adaptor,
|
|
67
|
+
record: :customer
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
# byebug unless schema['items'].count == 1
|
|
71
|
+
|
|
72
|
+
LedgerSync::Result.Success(schema)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe LedgerSync::Adaptors::NetSuite::Customer, adaptor: :netsuite do
|
|
4
|
+
let(:adaptor) { netsuite_adaptor }
|
|
5
|
+
let(:attribute_updates) do
|
|
6
|
+
{
|
|
7
|
+
name: "QA UPDATE #{test_run_id}"
|
|
8
|
+
}
|
|
9
|
+
end
|
|
10
|
+
let(:record) { :customer }
|
|
11
|
+
let(:resource) do
|
|
12
|
+
LedgerSync::Customer.new(
|
|
13
|
+
email: "#{test_run_id}@example.com",
|
|
14
|
+
name: "Test Customer #{test_run_id}",
|
|
15
|
+
phone_number: '1234567890',
|
|
16
|
+
subsidiary: existing_subsidiary_resource
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it_behaves_like 'a full netsuite resource'
|
|
21
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module QA
|
|
4
|
+
module NetSuite
|
|
5
|
+
module Vendor
|
|
6
|
+
def vendor_create
|
|
7
|
+
perform(
|
|
8
|
+
LedgerSync::Adaptors::NetSuite::Vendor::Operations::Create.new(
|
|
9
|
+
adaptor: adaptor,
|
|
10
|
+
resource: new_vendor(
|
|
11
|
+
subsidiary: existing_netsuite_subsidiary
|
|
12
|
+
)
|
|
13
|
+
)
|
|
14
|
+
)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def vendor_delete(vendor:)
|
|
18
|
+
perform(
|
|
19
|
+
LedgerSync::Adaptors::NetSuite::Vendor::Operations::Delete.new(
|
|
20
|
+
adaptor: adaptor,
|
|
21
|
+
resource: vendor
|
|
22
|
+
)
|
|
23
|
+
)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def vendor_delete_nonexisting(vendor:)
|
|
27
|
+
result = LedgerSync::Adaptors::NetSuite::Vendor::Operations::Delete.new(
|
|
28
|
+
adaptor: adaptor,
|
|
29
|
+
resource: vendor
|
|
30
|
+
).perform
|
|
31
|
+
|
|
32
|
+
unless result.failure?
|
|
33
|
+
pdb 'Should be failure'
|
|
34
|
+
byebug
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
LedgerSync::Result.Success
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def vendor_find(vendor:)
|
|
41
|
+
perform(
|
|
42
|
+
LedgerSync::Adaptors::NetSuite::Vendor::Operations::Find.new(
|
|
43
|
+
adaptor: adaptor,
|
|
44
|
+
resource: vendor
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def vendor_update(vendor:)
|
|
50
|
+
name = "QA UPDATE #{test_run_id}"
|
|
51
|
+
vendor.company_name = name
|
|
52
|
+
|
|
53
|
+
result = perform(
|
|
54
|
+
LedgerSync::Adaptors::NetSuite::Vendor::Operations::Update.new(
|
|
55
|
+
adaptor: adaptor,
|
|
56
|
+
resource: vendor
|
|
57
|
+
)
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
byebug if result.resource.company_name != name
|
|
61
|
+
result
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def schema_vendor
|
|
65
|
+
schema = adaptor.base_module::Record::Metadata.new(
|
|
66
|
+
adaptor: adaptor,
|
|
67
|
+
record: :vendor
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
# byebug unless schema['items'].count == 1
|
|
71
|
+
|
|
72
|
+
LedgerSync::Result.Success(schema)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe LedgerSync::Adaptors::NetSuite::Vendor, adaptor: :netsuite do
|
|
4
|
+
let(:adaptor) { netsuite_adaptor }
|
|
5
|
+
let(:attribute_updates) do
|
|
6
|
+
{
|
|
7
|
+
company_name: "QA UPDATE #{test_run_id}"
|
|
8
|
+
}
|
|
9
|
+
end
|
|
10
|
+
let(:record) { :vendor }
|
|
11
|
+
let(:resource) do
|
|
12
|
+
LedgerSync::Vendor.new(
|
|
13
|
+
company_name: "#{test_run_id} Company",
|
|
14
|
+
email: "test-#{test_run_id}-vendor@example.com",
|
|
15
|
+
first_name: "TestFirst#{test_run_id}",
|
|
16
|
+
last_name: "TestLast#{test_run_id}",
|
|
17
|
+
display_name: "Test #{test_run_id} Display Name",
|
|
18
|
+
subsidiary: existing_subsidiary_resource
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it_behaves_like 'a full netsuite resource'
|
|
23
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe LedgerSync::Adaptors::NetSuiteSOAP::Customer, adaptor: :netsuite_soap do
|
|
4
|
+
let(:adaptor) { netsuite_soap_adaptor }
|
|
5
|
+
let(:attribute_updates) do
|
|
6
|
+
{
|
|
7
|
+
name: "QA UPDATE #{rand_id}"
|
|
8
|
+
}
|
|
9
|
+
end
|
|
10
|
+
let(:record) { :customer }
|
|
11
|
+
let(:resource) do
|
|
12
|
+
LedgerSync::Customer.new(
|
|
13
|
+
email: "#{rand_id}@example.com",
|
|
14
|
+
name: "Test Customer #{rand_id}",
|
|
15
|
+
phone_number: '1234567890',
|
|
16
|
+
subsidiary: existing_subsidiary_resource
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it_behaves_like 'a full netsuite soap resource'
|
|
21
|
+
end
|
|
File without changes
|
data/qa/netsuite_test.rb
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'netsuite/customer'
|
|
4
|
+
require_relative 'netsuite/vendor'
|
|
5
|
+
module QA
|
|
6
|
+
class NetSuiteTest < QA::Test
|
|
7
|
+
include NetSuite::Customer
|
|
8
|
+
include NetSuite::Vendor
|
|
9
|
+
|
|
10
|
+
def adaptor
|
|
11
|
+
@adaptor ||= LedgerSync.adaptors.netsuite.new(
|
|
12
|
+
account_id: config['netsuite']['account_id'],
|
|
13
|
+
consumer_key: config['netsuite']['consumer_key'],
|
|
14
|
+
consumer_secret: config['netsuite']['consumer_secret'],
|
|
15
|
+
token_id: config['netsuite']['token_id'],
|
|
16
|
+
token_secret: config['netsuite']['token_secret']
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def run
|
|
21
|
+
puts 'Testing NetSuite REST API'
|
|
22
|
+
|
|
23
|
+
schema_customer
|
|
24
|
+
.and_then { customer_create }
|
|
25
|
+
.and_then { |result| customer_find(customer: result.resource) }
|
|
26
|
+
.and_then { |result| customer_update(customer: result.resource) }
|
|
27
|
+
.and_then { |result| customer_delete(customer: result.resource) }
|
|
28
|
+
.and_then { |result| customer_delete_nonexisting(customer: result.resource) }
|
|
29
|
+
.and_then { schema_vendor }
|
|
30
|
+
.and_then { vendor_create }
|
|
31
|
+
.and_then { vendor_create }
|
|
32
|
+
.and_then { |result| vendor_find(vendor: result.resource) }
|
|
33
|
+
.and_then { |result| vendor_update(vendor: result.resource) }
|
|
34
|
+
.and_then { |result| vendor_delete(vendor: result.resource) }
|
|
35
|
+
.and_then { |result| vendor_delete_nonexisting(vendor: result.resource) }
|
|
36
|
+
|
|
37
|
+
schema_customer
|
|
38
|
+
|
|
39
|
+
pdb 'Done'
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
data/qa/qa_helper.rb
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Set an environment variable to determine when we are running QA tests.
|
|
4
|
+
ENV['QA_ENV'] = 'true'
|
|
5
|
+
|
|
6
|
+
require 'bundler/setup'
|
|
7
|
+
require 'ap'
|
|
8
|
+
require 'byebug'
|
|
9
|
+
require 'ledger_sync'
|
|
10
|
+
|
|
11
|
+
#
|
|
12
|
+
# Helper method for requiring support files
|
|
13
|
+
#
|
|
14
|
+
# @param [String] *paths List of strings or symbols
|
|
15
|
+
#
|
|
16
|
+
# @return [Boolean]
|
|
17
|
+
#
|
|
18
|
+
def support(*paths)
|
|
19
|
+
paths.each do |path|
|
|
20
|
+
require File.join(LedgerSync.root, 'qa/support/', path.to_s)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
#
|
|
25
|
+
# Helper method for requiring support files from /spec/support dir
|
|
26
|
+
#
|
|
27
|
+
# @param [String] *paths List of strings or symbols
|
|
28
|
+
#
|
|
29
|
+
# @return [Boolean]
|
|
30
|
+
#
|
|
31
|
+
def spec_support(*paths)
|
|
32
|
+
paths.each do |path|
|
|
33
|
+
require File.join(LedgerSync.root, 'spec/support/', path.to_s)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
spec_support :factory_bot
|
|
38
|
+
|
|
39
|
+
support :adaptor_support_setup
|
|
40
|
+
|
|
41
|
+
setup_adaptor_support(
|
|
42
|
+
LedgerSync::Adaptors::NetSuite::Adaptor,
|
|
43
|
+
LedgerSync::Adaptors::NetSuiteSOAP::Adaptor,
|
|
44
|
+
LedgerSync::Adaptors::QuickBooksOnline::Adaptor,
|
|
45
|
+
LedgerSync::Adaptors::Stripe::Adaptor
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
RSpec.configure do |config|
|
|
49
|
+
# Enable flags like --only-failures and --next-failure
|
|
50
|
+
config.example_status_persistence_file_path = 'tmp/qa_history.txt'
|
|
51
|
+
|
|
52
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
|
53
|
+
config.disable_monkey_patching!
|
|
54
|
+
|
|
55
|
+
config.expect_with :rspec do |c|
|
|
56
|
+
c.syntax = :expect
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe LedgerSync::Adaptors::QuickBooksOnline::Account, adaptor: :quickbooks_online do
|
|
4
|
+
let(:adaptor) { quickbooks_online_adaptor }
|
|
5
|
+
let(:attribute_updates) do
|
|
6
|
+
{
|
|
7
|
+
name: "QA UPDATE #{test_run_id}"
|
|
8
|
+
}
|
|
9
|
+
end
|
|
10
|
+
let(:record) { :account }
|
|
11
|
+
let(:resource) { FactoryBot.create(:account) }
|
|
12
|
+
|
|
13
|
+
it_behaves_like 'a standard quickbooks_online resource'
|
|
14
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe LedgerSync::Adaptors::QuickBooksOnline::Customer, adaptor: :quickbooks_online do
|
|
4
|
+
let(:adaptor) { quickbooks_online_adaptor }
|
|
5
|
+
let(:attribute_updates) do
|
|
6
|
+
{
|
|
7
|
+
name: "QA UPDATE #{rand_id}"
|
|
8
|
+
}
|
|
9
|
+
end
|
|
10
|
+
let(:resource) { FactoryBot.create(:customer) }
|
|
11
|
+
|
|
12
|
+
it_behaves_like 'a standard quickbooks_online resource'
|
|
13
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe LedgerSync::Adaptors::QuickBooksOnline::Expense, adaptor: :quickbooks_online do
|
|
4
|
+
let(:adaptor) { quickbooks_online_adaptor }
|
|
5
|
+
let(:attribute_updates) do
|
|
6
|
+
{
|
|
7
|
+
memo: "QA UPDATE #{rand_id}"
|
|
8
|
+
}
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
let(:account) do
|
|
12
|
+
create_resource_for(
|
|
13
|
+
adaptor: adaptor,
|
|
14
|
+
resource: FactoryBot.create(:account)
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
let(:resource) do
|
|
19
|
+
FactoryBot.create(
|
|
20
|
+
:expense,
|
|
21
|
+
account: account,
|
|
22
|
+
line_items: FactoryBot.create_list(
|
|
23
|
+
:expense_line_item,
|
|
24
|
+
2,
|
|
25
|
+
account: account
|
|
26
|
+
)
|
|
27
|
+
)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it_behaves_like 'a standard quickbooks_online resource'
|
|
31
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe LedgerSync::Adaptors::QuickBooksOnline::Vendor, adaptor: :quickbooks_online do
|
|
4
|
+
let(:adaptor) { quickbooks_online_adaptor }
|
|
5
|
+
let(:attribute_updates) do
|
|
6
|
+
{
|
|
7
|
+
display_name: "QA UPDATE #{rand_id}"
|
|
8
|
+
}
|
|
9
|
+
end
|
|
10
|
+
let(:resource) { FactoryBot.create(:vendor) }
|
|
11
|
+
|
|
12
|
+
it_behaves_like 'a standard quickbooks_online resource'
|
|
13
|
+
end
|