ledger_sync 1.3.3 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/.rubocop_todo.yml +0 -3
- data/Gemfile.lock +47 -44
- data/ledger_sync.gemspec +1 -1
- data/lib/ledger_sync.rb +5 -0
- data/lib/ledger_sync/adaptors/adaptor.rb +28 -0
- data/lib/ledger_sync/adaptors/netsuite/account/operations/create.rb +1 -1
- data/lib/ledger_sync/adaptors/netsuite/account/searcher.rb +0 -16
- data/lib/ledger_sync/adaptors/netsuite/adaptor.rb +11 -3
- data/lib/ledger_sync/adaptors/netsuite/currency/operations/create.rb +1 -1
- data/lib/ledger_sync/adaptors/netsuite/customer/operations/create.rb +1 -1
- data/lib/ledger_sync/adaptors/netsuite/department/ledger_serializer.rb +17 -0
- data/lib/ledger_sync/adaptors/netsuite/department/operations/create.rb +25 -0
- data/lib/ledger_sync/adaptors/netsuite/department/operations/delete.rb +25 -0
- data/lib/ledger_sync/adaptors/netsuite/department/operations/find.rb +25 -0
- data/lib/ledger_sync/adaptors/netsuite/department/operations/update.rb +25 -0
- data/lib/ledger_sync/adaptors/netsuite/department/searcher.rb +12 -0
- data/lib/ledger_sync/adaptors/netsuite/ledger_serializer.rb +1 -1
- data/lib/ledger_sync/adaptors/netsuite/record/http_method.rb +14 -19
- data/lib/ledger_sync/adaptors/netsuite/record/metadata.rb +47 -21
- data/lib/ledger_sync/adaptors/netsuite/record/parameter.rb +20 -0
- data/lib/ledger_sync/adaptors/netsuite/record/property.rb +8 -31
- data/lib/ledger_sync/adaptors/netsuite/searcher.rb +19 -0
- data/lib/ledger_sync/adaptors/netsuite/vendor/operations/create.rb +1 -1
- data/lib/ledger_sync/adaptors/quickbooks_online/adaptor.rb +6 -11
- data/lib/ledger_sync/adaptors/quickbooks_online/bill_payment/ledger_serializer.rb +76 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/bill_payment/operations/create.rb +33 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/bill_payment/operations/find.rb +33 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/bill_payment/operations/update.rb +33 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/bill_payment_line_item/ledger_serializer.rb +19 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/operation.rb +1 -1
- data/lib/ledger_sync/adaptors/quickbooks_online/operation/find.rb +0 -6
- data/lib/ledger_sync/adaptors/quickbooks_online/preferences/ledger_serializer.rb +45 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/preferences/operations/find.rb +38 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/resources/preferences.rb +24 -0
- data/lib/ledger_sync/adaptors/searcher.rb +4 -0
- data/lib/ledger_sync/error/operation_errors.rb +0 -10
- data/lib/ledger_sync/resource.rb +1 -1
- data/lib/ledger_sync/resources/bill_payment.rb +32 -0
- data/lib/ledger_sync/resources/bill_payment_line_item.rb +15 -0
- data/lib/ledger_sync/type/hash.rb +34 -0
- data/lib/ledger_sync/util/read_only_object.rb +54 -0
- data/lib/ledger_sync/version.rb +1 -1
- metadata +23 -30
- data/qa/env_spec.rb +0 -5
- data/qa/netsuite/account_spec.rb +0 -20
- data/qa/netsuite/currency_spec.rb +0 -16
- data/qa/netsuite/customer.rb +0 -76
- data/qa/netsuite/customer_spec.rb +0 -21
- data/qa/netsuite/vendor.rb +0 -76
- data/qa/netsuite/vendor_spec.rb +0 -23
- data/qa/netsuite_soap/customer_spec.rb +0 -21
- data/qa/netsuite_soap/subsidiary_spec.rb +0 -0
- data/qa/qa_helper.rb +0 -58
- data/qa/quickbooks_online/account_spec.rb +0 -14
- data/qa/quickbooks_online/customer_spec.rb +0 -13
- data/qa/quickbooks_online/expense_spec.rb +0 -31
- data/qa/quickbooks_online/vendor_spec.rb +0 -13
- data/qa/stripe/customers_spec.rb +0 -15
- data/qa/support/adaptor_helpers.rb +0 -99
- data/qa/support/adaptor_support_setup.rb +0 -23
- data/qa/support/netsuite_helpers.rb +0 -33
- data/qa/support/netsuite_shared_examples.rb +0 -30
- data/qa/support/netsuite_soap_helpers.rb +0 -33
- data/qa/support/netsuite_soap_shared_examples.rb +0 -10
- data/qa/support/quickbooks_online_helpers.rb +0 -42
- data/qa/support/quickbooks_online_shared_examples.rb +0 -82
- data/qa/support/shared_examples.rb +0 -127
- data/qa/support/stripe_helpers.rb +0 -22
- data/qa/support/stripe_shared_examples.rb +0 -10
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
def setup_adaptor_support(*adaptors)
|
4
|
-
adaptors.each do |adaptor|
|
5
|
-
key = adaptor.config.root_key
|
6
|
-
|
7
|
-
support "#{key}_helpers"
|
8
|
-
helpers_module = Object.const_get("#{adaptor.base_module.name.split('::').last}Helpers")
|
9
|
-
env_key = "#{key}_qa".upcase
|
10
|
-
|
11
|
-
RSpec.configure do |config|
|
12
|
-
config.include helpers_module, adaptor: key
|
13
|
-
|
14
|
-
config.around(:each, adaptor: key) do |example|
|
15
|
-
if ENV.fetch(env_key, nil) == '1'
|
16
|
-
example.run
|
17
|
-
else
|
18
|
-
skip "Set #{env_key}=1 to run #{key} QA tests"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
support :adaptor_helpers,
|
4
|
-
:netsuite_shared_examples
|
5
|
-
|
6
|
-
module NetSuiteHelpers
|
7
|
-
include AdaptorHelpers
|
8
|
-
|
9
|
-
def adaptor_class
|
10
|
-
LedgerSync::Adaptors::NetSuite::Adaptor
|
11
|
-
end
|
12
|
-
|
13
|
-
def existing_subsidiary_resource
|
14
|
-
LedgerSync::Subsidiary.new(
|
15
|
-
ledger_id: 2,
|
16
|
-
name: "QA Subsidary #{test_run_id}"
|
17
|
-
)
|
18
|
-
end
|
19
|
-
|
20
|
-
def netsuite_adaptor
|
21
|
-
@netsuite_adaptor ||= LedgerSync.adaptors.netsuite.new(
|
22
|
-
account_id: ENV.fetch('NETSUITE_ACCOUNT_ID'),
|
23
|
-
consumer_key: ENV.fetch('NETSUITE_CONSUMER_KEY'),
|
24
|
-
consumer_secret: ENV.fetch('NETSUITE_CONSUMER_SECRET'),
|
25
|
-
token_id: ENV.fetch('NETSUITE_TOKEN_ID'),
|
26
|
-
token_secret: ENV.fetch('NETSUITE_TOKEN_SECRET')
|
27
|
-
)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
RSpec.configure do |config|
|
32
|
-
config.include NetSuiteHelpers, adaptor: :netsuite
|
33
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
support :shared_examples
|
4
|
-
|
5
|
-
RSpec.shared_examples 'a record with metadata' do
|
6
|
-
describe LedgerSync::Adaptors::NetSuite::Record::Metadata do
|
7
|
-
subject do
|
8
|
-
described_class.new(
|
9
|
-
adaptor: adaptor,
|
10
|
-
record: record
|
11
|
-
)
|
12
|
-
end
|
13
|
-
|
14
|
-
context '.http_methods' do
|
15
|
-
it { expect(subject.http_methods.count).not_to be_zero }
|
16
|
-
end
|
17
|
-
|
18
|
-
context '.properties' do
|
19
|
-
it { expect(subject.properties.count).not_to be_zero }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
RSpec.shared_examples 'a full netsuite resource' do
|
25
|
-
it_behaves_like 'a create'
|
26
|
-
it_behaves_like 'a delete'
|
27
|
-
it_behaves_like 'a find'
|
28
|
-
it_behaves_like 'an update'
|
29
|
-
it_behaves_like 'a record with metadata'
|
30
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
support :adaptor_helpers,
|
4
|
-
:netsuite_soap_shared_examples
|
5
|
-
|
6
|
-
module NetSuiteSOAPHelpers
|
7
|
-
include AdaptorHelpers
|
8
|
-
|
9
|
-
def adaptor_class
|
10
|
-
LedgerSync::Adaptors::NetSuiteSOAP::Adaptor
|
11
|
-
end
|
12
|
-
|
13
|
-
def existing_subsidiary_resource
|
14
|
-
LedgerSync::Subsidiary.new(
|
15
|
-
ledger_id: 2,
|
16
|
-
name: "QA Subsidary #{test_run_id}"
|
17
|
-
)
|
18
|
-
end
|
19
|
-
|
20
|
-
def netsuite_soap_adaptor
|
21
|
-
@netsuite_soap_adaptor ||= LedgerSync.adaptors.netsuite_soap.new(
|
22
|
-
account_id: ENV.fetch('NETSUITE_SOAP_ACCOUNT_ID'),
|
23
|
-
consumer_key: ENV.fetch('NETSUITE_SOAP_CONSUMER_KEY'),
|
24
|
-
consumer_secret: ENV.fetch('NETSUITE_SOAP_CONSUMER_SECRET'),
|
25
|
-
token_id: ENV.fetch('NETSUITE_SOAP_TOKEN_ID'),
|
26
|
-
token_secret: ENV.fetch('NETSUITE_SOAP_TOKEN_SECRET')
|
27
|
-
)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
RSpec.configure do |config|
|
32
|
-
config.include NetSuiteSOAPHelpers, adaptor: :netsuite_soap
|
33
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
support :shared_examples
|
4
|
-
|
5
|
-
RSpec.shared_examples 'a full netsuite soap resource' do
|
6
|
-
it_behaves_like 'a create', delete: false
|
7
|
-
# it_behaves_like 'a delete', delete: false
|
8
|
-
it_behaves_like 'a find', delete: false
|
9
|
-
# it_behaves_like 'an update', delete: false
|
10
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
support :adaptor_helpers,
|
4
|
-
:quickbooks_online_shared_examples
|
5
|
-
|
6
|
-
module QuickBooksOnlineHelpers
|
7
|
-
include AdaptorHelpers
|
8
|
-
|
9
|
-
def adaptor_class
|
10
|
-
LedgerSync::Adaptors::QuickBooksOnline::Adaptor
|
11
|
-
end
|
12
|
-
|
13
|
-
def find_or_create_in_ledger(factory, adaptor:)
|
14
|
-
resource_class = FactoryBot.factories[factory].build_class
|
15
|
-
searcher = adaptor.searcher_klass_for(resource_type: resource_class.resource_type)
|
16
|
-
resource = searcher.new(
|
17
|
-
adaptor: adaptor,
|
18
|
-
query: ''
|
19
|
-
).search.raise_if_error.resources.first
|
20
|
-
|
21
|
-
return resource if resource.present?
|
22
|
-
|
23
|
-
create_resource_for(
|
24
|
-
adaptor: adaptor,
|
25
|
-
resource: resource
|
26
|
-
)
|
27
|
-
end
|
28
|
-
|
29
|
-
def quickbooks_online_adaptor
|
30
|
-
@quickbooks_online_adaptor ||= LedgerSync.adaptors.quickbooks_online.new_from_env(test: true)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
RSpec.configure do |config|
|
35
|
-
config.include QuickBooksOnlineHelpers, adaptor: :quickbooks_online
|
36
|
-
# config.before { quickbooks_online_adaptor.refresh! }
|
37
|
-
config.around(:each, adaptor: :quickbooks_online) do |example|
|
38
|
-
example.run
|
39
|
-
ensure
|
40
|
-
quickbooks_online_adaptor.update_secrets_in_dotenv
|
41
|
-
end
|
42
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# RSpec.shared_examples 'a quickbooks_online create' do
|
4
|
-
# it do
|
5
|
-
# result = create_result_for(
|
6
|
-
# adaptor: adaptor,
|
7
|
-
# resource: resource
|
8
|
-
# )
|
9
|
-
|
10
|
-
# expect(result).to be_success
|
11
|
-
# end
|
12
|
-
# end
|
13
|
-
|
14
|
-
# RSpec.shared_examples 'a quickbooks_online find' do
|
15
|
-
# it do
|
16
|
-
# result = create_result_for(
|
17
|
-
# adaptor: adaptor,
|
18
|
-
# resource: resource
|
19
|
-
# ).raise_if_error
|
20
|
-
# expect(result).to be_success
|
21
|
-
# resource = result.resource
|
22
|
-
|
23
|
-
# result = find_result_for(
|
24
|
-
# adaptor: adaptor,
|
25
|
-
# resource: resource
|
26
|
-
# )
|
27
|
-
|
28
|
-
# expect(result).to be_success
|
29
|
-
# end
|
30
|
-
# end
|
31
|
-
|
32
|
-
# RSpec.shared_examples 'a quickbooks_online update' do
|
33
|
-
# it do
|
34
|
-
# result = create_result_for(
|
35
|
-
# adaptor: adaptor,
|
36
|
-
# resource: resource
|
37
|
-
# ).raise_if_error
|
38
|
-
|
39
|
-
# expect(result).to be_success
|
40
|
-
# resource = result.resource
|
41
|
-
|
42
|
-
# # Ensure values are currently not the same as the updates
|
43
|
-
# attribute_updates.each do |k, v|
|
44
|
-
# expect(resource.send(k)).not_to eq(v)
|
45
|
-
# end
|
46
|
-
|
47
|
-
# resource.assign_attributes(attribute_updates)
|
48
|
-
# result = update_result_for(
|
49
|
-
# adaptor: adaptor,
|
50
|
-
# resource: resource
|
51
|
-
# )
|
52
|
-
|
53
|
-
# expect(result).to be_success
|
54
|
-
# resource = result.resource
|
55
|
-
|
56
|
-
# # Ensure values are updated
|
57
|
-
# attribute_updates.each do |k, v|
|
58
|
-
# expect(resource.send(k)).to eq(v)
|
59
|
-
# end
|
60
|
-
|
61
|
-
# result = find_result_for(
|
62
|
-
# adaptor: adaptor,
|
63
|
-
# resource: resource.class.new(
|
64
|
-
# ledger_id: resource.ledger_id
|
65
|
-
# )
|
66
|
-
# ).raise_if_error
|
67
|
-
|
68
|
-
# expect(result).to be_success
|
69
|
-
# resource = result.resource
|
70
|
-
|
71
|
-
# # Ensure values are updated after raw find
|
72
|
-
# attribute_updates.each do |k, v|
|
73
|
-
# expect(resource.send(k)).to eq(v)
|
74
|
-
# end
|
75
|
-
# end
|
76
|
-
# end
|
77
|
-
|
78
|
-
RSpec.shared_examples 'a standard quickbooks_online resource' do
|
79
|
-
it_behaves_like 'a create', delete: false
|
80
|
-
it_behaves_like 'a find', delete: false
|
81
|
-
it_behaves_like 'an update', delete: false
|
82
|
-
end
|
@@ -1,127 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.shared_examples 'a create' do |delete: true|
|
4
|
-
it do
|
5
|
-
result = create_result_for(
|
6
|
-
adaptor: adaptor,
|
7
|
-
resource: resource
|
8
|
-
)
|
9
|
-
|
10
|
-
expect(result).to be_success
|
11
|
-
|
12
|
-
if delete
|
13
|
-
delete_result_for(
|
14
|
-
adaptor: adaptor,
|
15
|
-
resource: result.resource
|
16
|
-
).raise_if_error
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
RSpec.shared_examples 'a delete' do
|
22
|
-
it do
|
23
|
-
result = create_result_for(
|
24
|
-
adaptor: adaptor,
|
25
|
-
resource: resource
|
26
|
-
).raise_if_error
|
27
|
-
|
28
|
-
resource = result.resource
|
29
|
-
|
30
|
-
result = delete_result_for(
|
31
|
-
adaptor: adaptor,
|
32
|
-
resource: resource
|
33
|
-
)
|
34
|
-
|
35
|
-
expect(result).to be_success
|
36
|
-
|
37
|
-
result = delete_result_for(
|
38
|
-
adaptor: adaptor,
|
39
|
-
resource: resource
|
40
|
-
)
|
41
|
-
|
42
|
-
expect(result).to be_failure
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
RSpec.shared_examples 'a find' do |delete: true|
|
47
|
-
it do
|
48
|
-
result = create_result_for(
|
49
|
-
adaptor: adaptor,
|
50
|
-
resource: resource
|
51
|
-
).raise_if_error
|
52
|
-
expect(result).to be_success
|
53
|
-
resource = result.resource
|
54
|
-
|
55
|
-
begin
|
56
|
-
result = find_result_for(
|
57
|
-
adaptor: adaptor,
|
58
|
-
resource: resource
|
59
|
-
)
|
60
|
-
|
61
|
-
expect(result).to be_success
|
62
|
-
ensure
|
63
|
-
if delete
|
64
|
-
# Be sure to delete resource or raise an exception if this fails
|
65
|
-
delete_result_for(
|
66
|
-
adaptor: adaptor,
|
67
|
-
resource: resource
|
68
|
-
).raise_if_error
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
RSpec.shared_examples 'an update' do |delete: true|
|
75
|
-
it do
|
76
|
-
result = create_result_for(
|
77
|
-
adaptor: adaptor,
|
78
|
-
resource: resource
|
79
|
-
).raise_if_error
|
80
|
-
|
81
|
-
expect(result).to be_success
|
82
|
-
resource = result.resource
|
83
|
-
|
84
|
-
begin
|
85
|
-
# Ensure values are currently not the same as the updates
|
86
|
-
attribute_updates.each do |k, v|
|
87
|
-
expect(resource.send(k)).not_to eq(v)
|
88
|
-
end
|
89
|
-
|
90
|
-
resource.assign_attributes(attribute_updates)
|
91
|
-
result = update_result_for(
|
92
|
-
adaptor: adaptor,
|
93
|
-
resource: resource
|
94
|
-
)
|
95
|
-
|
96
|
-
expect(result).to be_success
|
97
|
-
resource = result.resource
|
98
|
-
|
99
|
-
# Ensure values are updated
|
100
|
-
attribute_updates.each do |k, v|
|
101
|
-
expect(resource.send(k)).to eq(v)
|
102
|
-
end
|
103
|
-
|
104
|
-
result = find_result_for(
|
105
|
-
adaptor: adaptor,
|
106
|
-
resource: resource.class.new(
|
107
|
-
ledger_id: resource.ledger_id
|
108
|
-
)
|
109
|
-
).raise_if_error
|
110
|
-
|
111
|
-
expect(result).to be_success
|
112
|
-
resource = result.resource
|
113
|
-
|
114
|
-
# Ensure values are updated after raw find
|
115
|
-
attribute_updates.each do |k, v|
|
116
|
-
expect(resource.send(k)).to eq(v)
|
117
|
-
end
|
118
|
-
ensure
|
119
|
-
if delete
|
120
|
-
delete_result_for(
|
121
|
-
adaptor: adaptor,
|
122
|
-
resource: resource
|
123
|
-
).raise_if_error
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
support :adaptor_helpers,
|
4
|
-
:stripe_shared_examples
|
5
|
-
|
6
|
-
module StripeHelpers
|
7
|
-
include AdaptorHelpers
|
8
|
-
|
9
|
-
def adaptor_class
|
10
|
-
LedgerSync::Adaptors::Stripe::Adaptor
|
11
|
-
end
|
12
|
-
|
13
|
-
def stripe_adaptor
|
14
|
-
@stripe_adaptor ||= LedgerSync.adaptors.stripe.new(
|
15
|
-
api_key: ENV.fetch('STRIPE_API_KEY')
|
16
|
-
)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
RSpec.configure do |config|
|
21
|
-
config.include StripeHelpers, adaptor: :stripe
|
22
|
-
end
|