business-central 1.0.3 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +58 -15
- data/lib/business_central/client.rb +71 -41
- data/lib/business_central/exceptions.rb +19 -9
- data/lib/business_central/object/account.rb +4 -2
- data/lib/business_central/object/aged_account_payable.rb +4 -2
- data/lib/business_central/object/aged_account_receivable.rb +4 -2
- data/lib/business_central/object/argument_helper.rb +22 -0
- data/lib/business_central/object/attachment.rb +30 -0
- data/lib/business_central/object/balance_sheet.rb +4 -2
- data/lib/business_central/object/base.rb +90 -56
- data/lib/business_central/object/cash_flow_statement.rb +4 -2
- data/lib/business_central/object/company.rb +5 -3
- data/lib/business_central/object/company_information.rb +7 -5
- data/lib/business_central/object/country_region.rb +8 -6
- data/lib/business_central/object/currency.rb +8 -6
- data/lib/business_central/object/customer.rb +16 -9
- data/lib/business_central/object/customer_financial_detail.rb +3 -1
- data/lib/business_central/object/customer_payment.rb +8 -6
- data/lib/business_central/object/customer_payment_journal.rb +8 -6
- data/lib/business_central/object/customer_sale.rb +3 -1
- data/lib/business_central/object/default_dimension.rb +18 -21
- data/lib/business_central/object/dimension.rb +20 -0
- data/lib/business_central/object/dimension_line.rb +37 -0
- data/lib/business_central/object/dimension_value.rb +28 -0
- data/lib/business_central/object/employee.rb +21 -0
- data/lib/business_central/object/filter_query.rb +18 -0
- data/lib/business_central/object/general_ledger_entry.rb +13 -0
- data/lib/business_central/object/income_statement.rb +13 -0
- data/lib/business_central/object/irs1099_code.rb +16 -0
- data/lib/business_central/object/item.rb +17 -10
- data/lib/business_central/object/item_category.rb +16 -0
- data/lib/business_central/object/journal.rb +29 -0
- data/lib/business_central/object/journal_line.rb +48 -0
- data/lib/business_central/object/{helper.rb → object_helper.rb} +18 -10
- data/lib/business_central/object/payment_method.rb +16 -0
- data/lib/business_central/object/payment_term.rb +16 -0
- data/lib/business_central/object/picture.rb +53 -0
- data/lib/business_central/object/purchase_invoice.rb +8 -6
- data/lib/business_central/object/purchase_invoice_line.rb +10 -8
- data/lib/business_central/object/purchase_order.rb +16 -0
- data/lib/business_central/object/request.rb +60 -49
- data/lib/business_central/object/response.rb +31 -23
- data/lib/business_central/object/retained_earning_statement.rb +13 -0
- data/lib/business_central/object/sales_credit_memo.rb +20 -0
- data/lib/business_central/object/sales_credit_memo_line.rb +30 -0
- data/lib/business_central/object/sales_invoice.rb +62 -0
- data/lib/business_central/object/sales_invoice_line.rb +30 -0
- data/lib/business_central/object/sales_order.rb +20 -0
- data/lib/business_central/object/sales_order_line.rb +30 -0
- data/lib/business_central/object/sales_quote.rb +20 -0
- data/lib/business_central/object/sales_quote_line.rb +30 -0
- data/lib/business_central/object/shipment_method.rb +16 -0
- data/lib/business_central/object/subscription.rb +16 -0
- data/lib/business_central/object/tax_area.rb +16 -0
- data/lib/business_central/object/tax_group.rb +16 -0
- data/lib/business_central/object/time_registration_entry.rb +16 -0
- data/lib/business_central/object/trial_balance.rb +13 -0
- data/lib/business_central/object/units_of_measure.rb +16 -0
- data/lib/business_central/object/url_builder.rb +59 -0
- data/lib/business_central/object/url_helper.rb +44 -0
- data/lib/business_central/object/validation.rb +10 -7
- data/lib/business_central/object/vendor.rb +10 -7
- data/lib/business_central/object/vendor_purchase.rb +13 -0
- data/lib/business_central/version.rb +4 -2
- data/lib/business_central/web_service.rb +78 -0
- data/lib/business_central.rb +40 -2
- data/lib/core_ext/string.rb +18 -12
- data/test/business_central/client_test.rb +18 -11
- data/test/business_central/object/account_test.rb +6 -5
- data/test/business_central/object/aged_account_payable_test.rb +6 -5
- data/test/business_central/object/aged_account_receivable_test.rb +6 -5
- data/test/business_central/object/attachment_test.rb +117 -0
- data/test/business_central/object/balance_sheet_test.rb +6 -5
- data/test/business_central/object/base_test.rb +4 -2
- data/test/business_central/object/cash_flow_statement_test.rb +6 -5
- data/test/business_central/object/company_information_test.rb +9 -10
- data/test/business_central/object/company_test.rb +6 -5
- data/test/business_central/object/country_region_test.rb +16 -17
- data/test/business_central/object/currency_test.rb +17 -18
- data/test/business_central/object/customer_financial_detail_test.rb +8 -6
- data/test/business_central/object/customer_payment_journal_test.rb +14 -15
- data/test/business_central/object/customer_payment_test.rb +15 -16
- data/test/business_central/object/customer_sale_test.rb +8 -6
- data/test/business_central/object/customer_test.rb +59 -16
- data/test/business_central/object/default_dimension_test.rb +15 -16
- data/test/business_central/object/dimension_line_test.rb +165 -0
- data/test/business_central/object/dimension_test.rb +65 -0
- data/test/business_central/object/dimension_value_test.rb +68 -0
- data/test/business_central/object/employee_test.rb +141 -0
- data/test/business_central/object/filter_query_test.rb +36 -0
- data/test/business_central/object/general_ledger_entry_test.rb +82 -0
- data/test/business_central/object/income_statement_test.rb +82 -0
- data/test/business_central/object/irs1099_code_test.rb +124 -0
- data/test/business_central/object/item_category_test.rb +122 -0
- data/test/business_central/object/item_test.rb +16 -17
- data/test/business_central/object/journal_line_test.rb +152 -0
- data/test/business_central/object/journal_test.rb +144 -0
- data/test/business_central/object/payment_method_test.rb +134 -0
- data/test/business_central/object/payment_term_test.rb +134 -0
- data/test/business_central/object/picture_test.rb +74 -0
- data/test/business_central/object/purchase_invoice_line_test.rb +15 -15
- data/test/business_central/object/purchase_invoice_test.rb +15 -15
- data/test/business_central/object/request_test.rb +17 -9
- data/test/business_central/object/response_test.rb +14 -7
- data/test/business_central/object/retained_earning_statement_test.rb +52 -0
- data/test/business_central/object/sales_credit_memo_line_test.rb +134 -0
- data/test/business_central/object/sales_credit_memo_test.rb +146 -0
- data/test/business_central/object/sales_invoice_line_test.rb +164 -0
- data/test/business_central/object/sales_invoice_test.rb +156 -0
- data/test/business_central/object/sales_order_line_test.rb +134 -0
- data/test/business_central/object/sales_order_test.rb +146 -0
- data/test/business_central/object/sales_quote_line_test.rb +134 -0
- data/test/business_central/object/sales_quote_test.rb +146 -0
- data/test/business_central/object/shipment_method_test.rb +133 -0
- data/test/business_central/object/subscription_test.rb +126 -0
- data/test/business_central/object/tax_area_test.rb +126 -0
- data/test/business_central/object/tax_group_test.rb +126 -0
- data/test/business_central/object/time_registration_entry_test.rb +126 -0
- data/test/business_central/object/trial_balance_test.rb +82 -0
- data/test/business_central/object/units_of_measure_test.rb +126 -0
- data/test/business_central/object/validation_test.rb +5 -4
- data/test/business_central/object/vendor_purchase_test.rb +82 -0
- data/test/business_central/object/vendor_test.rb +16 -16
- data/test/business_central/web_service_test.rb +100 -0
- data/test/business_central_test.rb +3 -1
- data/test/test_helper.rb +12 -6
- metadata +153 -41
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
2
4
|
# rake test TEST=test/business_central/object/currency_test.rb
|
3
5
|
|
4
6
|
class BusinessCentral::Object::CurrencyTest < Minitest::Test
|
@@ -11,7 +13,7 @@ class BusinessCentral::Object::CurrencyTest < Minitest::Test
|
|
11
13
|
def test_find_all
|
12
14
|
stub_request(:get, /currencies/)
|
13
15
|
.to_return(
|
14
|
-
status: 200,
|
16
|
+
status: 200,
|
15
17
|
body: {
|
16
18
|
'value': [
|
17
19
|
{
|
@@ -23,7 +25,7 @@ class BusinessCentral::Object::CurrencyTest < Minitest::Test
|
|
23
25
|
amountRoundingPrecision: 0.01
|
24
26
|
}
|
25
27
|
]
|
26
|
-
}.to_json
|
28
|
+
}.to_json
|
27
29
|
)
|
28
30
|
|
29
31
|
response = @currency.find_all
|
@@ -34,7 +36,7 @@ class BusinessCentral::Object::CurrencyTest < Minitest::Test
|
|
34
36
|
test_id = '2'
|
35
37
|
stub_request(:get, /currencies\(#{test_id}\)/)
|
36
38
|
.to_return(
|
37
|
-
status: 200,
|
39
|
+
status: 200,
|
38
40
|
body: {
|
39
41
|
id: test_id,
|
40
42
|
code: 'C2',
|
@@ -53,7 +55,7 @@ class BusinessCentral::Object::CurrencyTest < Minitest::Test
|
|
53
55
|
test_filter = "displayName eq 'country3'"
|
54
56
|
stub_request(:get, /currencies\?\$filter=#{test_filter}/)
|
55
57
|
.to_return(
|
56
|
-
status: 200,
|
58
|
+
status: 200,
|
57
59
|
body: {
|
58
60
|
'value': [
|
59
61
|
{
|
@@ -75,7 +77,7 @@ class BusinessCentral::Object::CurrencyTest < Minitest::Test
|
|
75
77
|
def test_create
|
76
78
|
stub_request(:post, /currencies/)
|
77
79
|
.to_return(
|
78
|
-
status: 200,
|
80
|
+
status: 200,
|
79
81
|
body: {
|
80
82
|
code: 'C4',
|
81
83
|
displayName: 'currency4',
|
@@ -83,20 +85,19 @@ class BusinessCentral::Object::CurrencyTest < Minitest::Test
|
|
83
85
|
}.to_json
|
84
86
|
)
|
85
87
|
|
86
|
-
response = @currency.create(
|
88
|
+
response = @currency.create(
|
87
89
|
code: 'C4',
|
88
90
|
display_name: 'currency4',
|
89
91
|
symbol: '$'
|
90
|
-
|
92
|
+
)
|
91
93
|
assert_equal response[:display_name], 'currency4'
|
92
94
|
end
|
93
95
|
|
94
|
-
|
95
96
|
def test_update
|
96
97
|
test_id = '2'
|
97
98
|
stub_request(:get, /currencies\(#{test_id}\)/)
|
98
99
|
.to_return(
|
99
|
-
status: 200,
|
100
|
+
status: 200,
|
100
101
|
body: {
|
101
102
|
etag: '3333',
|
102
103
|
id: test_id,
|
@@ -110,7 +111,7 @@ class BusinessCentral::Object::CurrencyTest < Minitest::Test
|
|
110
111
|
|
111
112
|
stub_request(:patch, /currencies\(#{test_id}\)/)
|
112
113
|
.to_return(
|
113
|
-
status: 200,
|
114
|
+
status: 200,
|
114
115
|
body: {
|
115
116
|
etag: '4444',
|
116
117
|
code: 'C6',
|
@@ -121,11 +122,9 @@ class BusinessCentral::Object::CurrencyTest < Minitest::Test
|
|
121
122
|
|
122
123
|
response = @currency.update(
|
123
124
|
test_id,
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
symbol: '$'
|
128
|
-
}
|
125
|
+
code: 'C6',
|
126
|
+
display_name: 'currency6',
|
127
|
+
symbol: '$'
|
129
128
|
)
|
130
129
|
assert_equal response[:display_name], 'currency6'
|
131
130
|
end
|
@@ -134,7 +133,7 @@ class BusinessCentral::Object::CurrencyTest < Minitest::Test
|
|
134
133
|
test_id = '33333'
|
135
134
|
stub_request(:get, /currencies\(#{test_id}\)/)
|
136
135
|
.to_return(
|
137
|
-
status: 200,
|
136
|
+
status: 200,
|
138
137
|
body: {
|
139
138
|
etag: '5555',
|
140
139
|
code: 'C7',
|
@@ -148,4 +147,4 @@ class BusinessCentral::Object::CurrencyTest < Minitest::Test
|
|
148
147
|
|
149
148
|
assert @currency.destroy(test_id)
|
150
149
|
end
|
151
|
-
end
|
150
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
2
4
|
# rake test TEST=test/business_central/object/customer_financial_detail_test.rb
|
3
5
|
|
4
6
|
class BusinessCentral::Object::CustomerFinancialDetailTest < Minitest::Test
|
@@ -13,7 +15,7 @@ class BusinessCentral::Object::CustomerFinancialDetailTest < Minitest::Test
|
|
13
15
|
def test_find_all
|
14
16
|
stub_request(:get, /customerFinancialDetails/)
|
15
17
|
.to_return(
|
16
|
-
status: 200,
|
18
|
+
status: 200,
|
17
19
|
body: {
|
18
20
|
'value': [
|
19
21
|
{
|
@@ -22,7 +24,7 @@ class BusinessCentral::Object::CustomerFinancialDetailTest < Minitest::Test
|
|
22
24
|
balance: 0
|
23
25
|
}
|
24
26
|
]
|
25
|
-
}.to_json
|
27
|
+
}.to_json
|
26
28
|
)
|
27
29
|
|
28
30
|
response = @customer_financial_detail.find_all
|
@@ -33,7 +35,7 @@ class BusinessCentral::Object::CustomerFinancialDetailTest < Minitest::Test
|
|
33
35
|
test_id = '2'
|
34
36
|
stub_request(:get, /customerFinancialDetails\(#{test_id}\)/)
|
35
37
|
.to_return(
|
36
|
-
status: 200,
|
38
|
+
status: 200,
|
37
39
|
body: {
|
38
40
|
id: test_id,
|
39
41
|
number: 'N2',
|
@@ -49,7 +51,7 @@ class BusinessCentral::Object::CustomerFinancialDetailTest < Minitest::Test
|
|
49
51
|
test_filter = "number eq 'N3'"
|
50
52
|
stub_request(:get, /customerFinancialDetails\?\$filter=#{test_filter}/)
|
51
53
|
.to_return(
|
52
|
-
status: 200,
|
54
|
+
status: 200,
|
53
55
|
body: {
|
54
56
|
'value': [
|
55
57
|
{
|
@@ -63,4 +65,4 @@ class BusinessCentral::Object::CustomerFinancialDetailTest < Minitest::Test
|
|
63
65
|
response = @customer_financial_detail.where(test_filter)
|
64
66
|
assert_equal response.first[:number], 'N3'
|
65
67
|
end
|
66
|
-
end
|
68
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
2
4
|
# rake test TEST=test/business_central/object/customer_payment_journal_test.rb
|
3
5
|
|
4
6
|
class BusinessCentral::Object::CustomerPaymentJournalTest < Minitest::Test
|
@@ -11,7 +13,7 @@ class BusinessCentral::Object::CustomerPaymentJournalTest < Minitest::Test
|
|
11
13
|
def test_find_all
|
12
14
|
stub_request(:get, /customerPaymentJournals/)
|
13
15
|
.to_return(
|
14
|
-
status: 200,
|
16
|
+
status: 200,
|
15
17
|
body: {
|
16
18
|
'value': [
|
17
19
|
{
|
@@ -20,7 +22,7 @@ class BusinessCentral::Object::CustomerPaymentJournalTest < Minitest::Test
|
|
20
22
|
displayName: 'GENERAL 1'
|
21
23
|
}
|
22
24
|
]
|
23
|
-
}.to_json
|
25
|
+
}.to_json
|
24
26
|
)
|
25
27
|
|
26
28
|
response = @customer_payment_journal.find_all
|
@@ -31,7 +33,7 @@ class BusinessCentral::Object::CustomerPaymentJournalTest < Minitest::Test
|
|
31
33
|
test_id = 2
|
32
34
|
stub_request(:get, /customerPaymentJournals\(#{test_id}\)/)
|
33
35
|
.to_return(
|
34
|
-
status: 200,
|
36
|
+
status: 200,
|
35
37
|
body: {
|
36
38
|
id: test_id,
|
37
39
|
code: 'GENERAL',
|
@@ -66,7 +68,7 @@ class BusinessCentral::Object::CustomerPaymentJournalTest < Minitest::Test
|
|
66
68
|
def test_create
|
67
69
|
stub_request(:post, /customerPaymentJournals/)
|
68
70
|
.to_return(
|
69
|
-
status: 200,
|
71
|
+
status: 200,
|
70
72
|
body: {
|
71
73
|
id: 1,
|
72
74
|
code: 'GENERAL',
|
@@ -74,18 +76,17 @@ class BusinessCentral::Object::CustomerPaymentJournalTest < Minitest::Test
|
|
74
76
|
}.to_json
|
75
77
|
)
|
76
78
|
|
77
|
-
response = @customer_payment_journal.create(
|
79
|
+
response = @customer_payment_journal.create(
|
78
80
|
display_name: 'GENERAL 4'
|
79
|
-
|
81
|
+
)
|
80
82
|
assert_equal response[:display_name], 'GENERAL 4'
|
81
83
|
end
|
82
84
|
|
83
|
-
|
84
85
|
def test_update
|
85
86
|
test_id = 2
|
86
87
|
stub_request(:get, /customerPaymentJournals\(#{test_id}\)/)
|
87
88
|
.to_return(
|
88
|
-
status: 200,
|
89
|
+
status: 200,
|
89
90
|
body: {
|
90
91
|
etag: '3333',
|
91
92
|
id: test_id,
|
@@ -96,7 +97,7 @@ class BusinessCentral::Object::CustomerPaymentJournalTest < Minitest::Test
|
|
96
97
|
|
97
98
|
stub_request(:patch, /customerPaymentJournals\(#{test_id}\)/)
|
98
99
|
.to_return(
|
99
|
-
status: 200,
|
100
|
+
status: 200,
|
100
101
|
body: {
|
101
102
|
etag: '4444',
|
102
103
|
id: test_id,
|
@@ -107,9 +108,7 @@ class BusinessCentral::Object::CustomerPaymentJournalTest < Minitest::Test
|
|
107
108
|
|
108
109
|
response = @customer_payment_journal.update(
|
109
110
|
test_id,
|
110
|
-
|
111
|
-
display_name: 'GENERAL 5'
|
112
|
-
}
|
111
|
+
display_name: 'GENERAL 5'
|
113
112
|
)
|
114
113
|
assert_equal response[:display_name], 'GENERAL 5'
|
115
114
|
end
|
@@ -118,7 +117,7 @@ class BusinessCentral::Object::CustomerPaymentJournalTest < Minitest::Test
|
|
118
117
|
test_id = '33333'
|
119
118
|
stub_request(:get, /customerPaymentJournals\(#{test_id}\)/)
|
120
119
|
.to_return(
|
121
|
-
status: 200,
|
120
|
+
status: 200,
|
122
121
|
body: {
|
123
122
|
etag: '5555',
|
124
123
|
id: test_id,
|
@@ -132,4 +131,4 @@ class BusinessCentral::Object::CustomerPaymentJournalTest < Minitest::Test
|
|
132
131
|
|
133
132
|
assert @customer_payment_journal.destroy(test_id)
|
134
133
|
end
|
135
|
-
end
|
134
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
2
4
|
# rake test TEST=test/business_central/object/customer_payment_test.rb
|
3
5
|
|
4
6
|
class BusinessCentral::Object::CustomerPaymentTest < Minitest::Test
|
@@ -11,7 +13,7 @@ class BusinessCentral::Object::CustomerPaymentTest < Minitest::Test
|
|
11
13
|
def test_find_all
|
12
14
|
stub_request(:get, /customerPayments/)
|
13
15
|
.to_return(
|
14
|
-
status: 200,
|
16
|
+
status: 200,
|
15
17
|
body: {
|
16
18
|
'value': [
|
17
19
|
{
|
@@ -21,7 +23,7 @@ class BusinessCentral::Object::CustomerPaymentTest < Minitest::Test
|
|
21
23
|
customerNumber: '123'
|
22
24
|
}
|
23
25
|
]
|
24
|
-
}.to_json
|
26
|
+
}.to_json
|
25
27
|
)
|
26
28
|
|
27
29
|
response = @customer_payment.find_all
|
@@ -32,7 +34,7 @@ class BusinessCentral::Object::CustomerPaymentTest < Minitest::Test
|
|
32
34
|
test_id = '2'
|
33
35
|
stub_request(:get, /customerPayments\(#{test_id}\)/)
|
34
36
|
.to_return(
|
35
|
-
status: 200,
|
37
|
+
status: 200,
|
36
38
|
body: {
|
37
39
|
id: test_id,
|
38
40
|
lineNumber: 1,
|
@@ -49,7 +51,7 @@ class BusinessCentral::Object::CustomerPaymentTest < Minitest::Test
|
|
49
51
|
test_filter = "customerNumber eq '123'"
|
50
52
|
stub_request(:get, /customerPayments\?\$filter=#{test_filter}/)
|
51
53
|
.to_return(
|
52
|
-
status: 200,
|
54
|
+
status: 200,
|
53
55
|
body: {
|
54
56
|
'value': [
|
55
57
|
{
|
@@ -69,7 +71,7 @@ class BusinessCentral::Object::CustomerPaymentTest < Minitest::Test
|
|
69
71
|
def test_create
|
70
72
|
stub_request(:post, /customerPayments/)
|
71
73
|
.to_return(
|
72
|
-
status: 200,
|
74
|
+
status: 200,
|
73
75
|
body: {
|
74
76
|
id: 1,
|
75
77
|
lineNumber: 1,
|
@@ -78,18 +80,17 @@ class BusinessCentral::Object::CustomerPaymentTest < Minitest::Test
|
|
78
80
|
}.to_json
|
79
81
|
)
|
80
82
|
|
81
|
-
response = @customer_payment.create(
|
83
|
+
response = @customer_payment.create(
|
82
84
|
customer_number: '789'
|
83
|
-
|
85
|
+
)
|
84
86
|
assert_equal response[:customer_number], '789'
|
85
87
|
end
|
86
88
|
|
87
|
-
|
88
89
|
def test_update
|
89
90
|
test_id = '2'
|
90
91
|
stub_request(:get, /customerPayments\(#{test_id}\)/)
|
91
92
|
.to_return(
|
92
|
-
status: 200,
|
93
|
+
status: 200,
|
93
94
|
body: {
|
94
95
|
etag: '3333',
|
95
96
|
id: test_id,
|
@@ -101,7 +102,7 @@ class BusinessCentral::Object::CustomerPaymentTest < Minitest::Test
|
|
101
102
|
|
102
103
|
stub_request(:patch, /customerPayments\(#{test_id}\)/)
|
103
104
|
.to_return(
|
104
|
-
status: 200,
|
105
|
+
status: 200,
|
105
106
|
body: {
|
106
107
|
etag: '4444',
|
107
108
|
id: test_id,
|
@@ -113,9 +114,7 @@ class BusinessCentral::Object::CustomerPaymentTest < Minitest::Test
|
|
113
114
|
|
114
115
|
response = @customer_payment.update(
|
115
116
|
test_id,
|
116
|
-
|
117
|
-
customer_number: '1011'
|
118
|
-
}
|
117
|
+
customer_number: '1011'
|
119
118
|
)
|
120
119
|
assert_equal response[:customer_number], '1011'
|
121
120
|
end
|
@@ -124,7 +123,7 @@ class BusinessCentral::Object::CustomerPaymentTest < Minitest::Test
|
|
124
123
|
test_id = '33333'
|
125
124
|
stub_request(:get, /customerPayments\(#{test_id}\)/)
|
126
125
|
.to_return(
|
127
|
-
status: 200,
|
126
|
+
status: 200,
|
128
127
|
body: {
|
129
128
|
etag: '5555',
|
130
129
|
id: test_id,
|
@@ -139,4 +138,4 @@ class BusinessCentral::Object::CustomerPaymentTest < Minitest::Test
|
|
139
138
|
|
140
139
|
assert @customer_payment.destroy(test_id)
|
141
140
|
end
|
142
|
-
end
|
141
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
2
4
|
# rake test TEST=test/business_central/object/customer_sale_test.rb
|
3
5
|
|
4
6
|
class BusinessCentral::Object::CustomerSaleTest < Minitest::Test
|
@@ -13,7 +15,7 @@ class BusinessCentral::Object::CustomerSaleTest < Minitest::Test
|
|
13
15
|
def test_find_all
|
14
16
|
stub_request(:get, /customerSales/)
|
15
17
|
.to_return(
|
16
|
-
status: 200,
|
18
|
+
status: 200,
|
17
19
|
body: {
|
18
20
|
'value': [
|
19
21
|
{
|
@@ -23,7 +25,7 @@ class BusinessCentral::Object::CustomerSaleTest < Minitest::Test
|
|
23
25
|
totalSalesAmount: 0
|
24
26
|
}
|
25
27
|
]
|
26
|
-
}.to_json
|
28
|
+
}.to_json
|
27
29
|
)
|
28
30
|
|
29
31
|
response = @customer_sale.find_all
|
@@ -34,7 +36,7 @@ class BusinessCentral::Object::CustomerSaleTest < Minitest::Test
|
|
34
36
|
test_id = 2
|
35
37
|
stub_request(:get, /customerSales\(#{test_id}\)/)
|
36
38
|
.to_return(
|
37
|
-
status: 200,
|
39
|
+
status: 200,
|
38
40
|
body: {
|
39
41
|
customerId: 2,
|
40
42
|
customerNumber: 'C2',
|
@@ -51,7 +53,7 @@ class BusinessCentral::Object::CustomerSaleTest < Minitest::Test
|
|
51
53
|
test_filter = "customerNumber eq 'C3'"
|
52
54
|
stub_request(:get, /customerSales\?\$filter=#{test_filter}/)
|
53
55
|
.to_return(
|
54
|
-
status: 200,
|
56
|
+
status: 200,
|
55
57
|
body: {
|
56
58
|
'value': [
|
57
59
|
{
|
@@ -67,4 +69,4 @@ class BusinessCentral::Object::CustomerSaleTest < Minitest::Test
|
|
67
69
|
response = @customer_sale.where(test_filter)
|
68
70
|
assert_equal response.first[:customer_number], 'C3'
|
69
71
|
end
|
70
|
-
end
|
72
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
2
4
|
# rake test TEST=test/business_central/object/customer_test.rb
|
3
5
|
|
4
6
|
class BusinessCentral::Object::CustomerTest < Minitest::Test
|
@@ -11,7 +13,7 @@ class BusinessCentral::Object::CustomerTest < Minitest::Test
|
|
11
13
|
def test_find_all
|
12
14
|
stub_request(:get, /customers/)
|
13
15
|
.to_return(
|
14
|
-
status: 200,
|
16
|
+
status: 200,
|
15
17
|
body: {
|
16
18
|
'value': [
|
17
19
|
{
|
@@ -19,7 +21,7 @@ class BusinessCentral::Object::CustomerTest < Minitest::Test
|
|
19
21
|
displayName: 'customer1'
|
20
22
|
}
|
21
23
|
]
|
22
|
-
}.to_json
|
24
|
+
}.to_json
|
23
25
|
)
|
24
26
|
|
25
27
|
response = @customer.find_all
|
@@ -30,7 +32,7 @@ class BusinessCentral::Object::CustomerTest < Minitest::Test
|
|
30
32
|
test_id = '2'
|
31
33
|
stub_request(:get, /customers\(#{test_id}\)/)
|
32
34
|
.to_return(
|
33
|
-
status: 200,
|
35
|
+
status: 200,
|
34
36
|
body: {
|
35
37
|
id: test_id,
|
36
38
|
displayName: 'customer2'
|
@@ -45,7 +47,7 @@ class BusinessCentral::Object::CustomerTest < Minitest::Test
|
|
45
47
|
test_filter = "displayName eq 'customer3'"
|
46
48
|
stub_request(:get, /customers\?\$filter=#{test_filter}/)
|
47
49
|
.to_return(
|
48
|
-
status: 200,
|
50
|
+
status: 200,
|
49
51
|
body: {
|
50
52
|
'value': [
|
51
53
|
{
|
@@ -63,24 +65,23 @@ class BusinessCentral::Object::CustomerTest < Minitest::Test
|
|
63
65
|
def test_create
|
64
66
|
stub_request(:post, /customers/)
|
65
67
|
.to_return(
|
66
|
-
status: 200,
|
68
|
+
status: 200,
|
67
69
|
body: {
|
68
70
|
displayName: 'customer4'
|
69
71
|
}.to_json
|
70
72
|
)
|
71
73
|
|
72
|
-
response = @customer.create(
|
74
|
+
response = @customer.create(
|
73
75
|
display_name: 'customer4'
|
74
|
-
|
76
|
+
)
|
75
77
|
assert_equal response[:display_name], 'customer4'
|
76
78
|
end
|
77
79
|
|
78
|
-
|
79
80
|
def test_update
|
80
81
|
test_id = '2'
|
81
82
|
stub_request(:get, /customers\(#{test_id}\)/)
|
82
83
|
.to_return(
|
83
|
-
status: 200,
|
84
|
+
status: 200,
|
84
85
|
body: {
|
85
86
|
etag: '3333',
|
86
87
|
id: test_id,
|
@@ -90,7 +91,7 @@ class BusinessCentral::Object::CustomerTest < Minitest::Test
|
|
90
91
|
|
91
92
|
stub_request(:patch, /customers\(#{test_id}\)/)
|
92
93
|
.to_return(
|
93
|
-
status: 200,
|
94
|
+
status: 200,
|
94
95
|
body: {
|
95
96
|
etag: '4444',
|
96
97
|
displayName: 'customer6'
|
@@ -99,9 +100,7 @@ class BusinessCentral::Object::CustomerTest < Minitest::Test
|
|
99
100
|
|
100
101
|
response = @customer.update(
|
101
102
|
test_id,
|
102
|
-
|
103
|
-
display_name: 'customer6'
|
104
|
-
}
|
103
|
+
display_name: 'customer6'
|
105
104
|
)
|
106
105
|
assert_equal response[:display_name], 'customer6'
|
107
106
|
end
|
@@ -110,7 +109,7 @@ class BusinessCentral::Object::CustomerTest < Minitest::Test
|
|
110
109
|
test_id = '33333'
|
111
110
|
stub_request(:get, /customers\(#{test_id}\)/)
|
112
111
|
.to_return(
|
113
|
-
status: 200,
|
112
|
+
status: 200,
|
114
113
|
body: {
|
115
114
|
etag: '5555',
|
116
115
|
displayName: 'customer7'
|
@@ -122,4 +121,48 @@ class BusinessCentral::Object::CustomerTest < Minitest::Test
|
|
122
121
|
|
123
122
|
assert @customer.destroy(test_id)
|
124
123
|
end
|
125
|
-
|
124
|
+
|
125
|
+
def test_default_dimension_navigation
|
126
|
+
stub_request(:get, %r{customers\(\d+\)\/defaultDimensions})
|
127
|
+
.to_return(
|
128
|
+
status: 200,
|
129
|
+
body: {
|
130
|
+
'value': [
|
131
|
+
{
|
132
|
+
id: 1,
|
133
|
+
parentId: '123',
|
134
|
+
dimensionId: '123',
|
135
|
+
dimensionCode: 'ABC',
|
136
|
+
dimensionValueId: 1,
|
137
|
+
dimensionValueCode: 'DEF'
|
138
|
+
}
|
139
|
+
]
|
140
|
+
}.to_json
|
141
|
+
)
|
142
|
+
|
143
|
+
response = @client.customer(company_id: @company_id, id: '123')
|
144
|
+
.default_dimension.find_all
|
145
|
+
assert_equal response.first[:parent_id], '123'
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_picture_navigation
|
149
|
+
stub_request(:get, %r{customers\(\d+\)\/picture})
|
150
|
+
.to_return(
|
151
|
+
status: 200,
|
152
|
+
body: {
|
153
|
+
'value': [
|
154
|
+
{
|
155
|
+
id: 1,
|
156
|
+
width: 500,
|
157
|
+
height: 496,
|
158
|
+
contentType: 'image\jpeg'
|
159
|
+
}
|
160
|
+
]
|
161
|
+
}.to_json
|
162
|
+
)
|
163
|
+
|
164
|
+
response = @client.customer(company_id: @company_id, id: '123')
|
165
|
+
.picture.find_all
|
166
|
+
assert_equal response.first[:width], 500
|
167
|
+
end
|
168
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
2
4
|
# rake test TEST=test/business_central/object/default_dimension_test.rb
|
3
5
|
|
4
6
|
class BusinessCentral::Object::DefaultDimensionTest < Minitest::Test
|
@@ -25,7 +27,7 @@ class BusinessCentral::Object::DefaultDimensionTest < Minitest::Test
|
|
25
27
|
def test_find_all
|
26
28
|
stub_request(:get, /defaultDimensions/)
|
27
29
|
.to_return(
|
28
|
-
status: 200,
|
30
|
+
status: 200,
|
29
31
|
body: {
|
30
32
|
'value': [
|
31
33
|
{
|
@@ -37,7 +39,7 @@ class BusinessCentral::Object::DefaultDimensionTest < Minitest::Test
|
|
37
39
|
dimensionValueCode: 'DEF'
|
38
40
|
}
|
39
41
|
]
|
40
|
-
}.to_json
|
42
|
+
}.to_json
|
41
43
|
)
|
42
44
|
|
43
45
|
response = @default_dimension.find_all
|
@@ -48,7 +50,7 @@ class BusinessCentral::Object::DefaultDimensionTest < Minitest::Test
|
|
48
50
|
test_id = '2'
|
49
51
|
stub_request(:get, /defaultDimensions\(#{test_id}\)/)
|
50
52
|
.to_return(
|
51
|
-
status: 200,
|
53
|
+
status: 200,
|
52
54
|
body: {
|
53
55
|
id: test_id,
|
54
56
|
parentId: '123',
|
@@ -67,7 +69,7 @@ class BusinessCentral::Object::DefaultDimensionTest < Minitest::Test
|
|
67
69
|
test_filter = "dimensionCode eq 'ABC'"
|
68
70
|
stub_request(:get, /defaultDimensions\?\$filter=#{test_filter}/)
|
69
71
|
.to_return(
|
70
|
-
status: 200,
|
72
|
+
status: 200,
|
71
73
|
body: {
|
72
74
|
'value': [
|
73
75
|
{
|
@@ -89,7 +91,7 @@ class BusinessCentral::Object::DefaultDimensionTest < Minitest::Test
|
|
89
91
|
def test_create
|
90
92
|
stub_request(:post, /defaultDimensions/)
|
91
93
|
.to_return(
|
92
|
-
status: 200,
|
94
|
+
status: 200,
|
93
95
|
body: {
|
94
96
|
id: 4,
|
95
97
|
parentId: '123',
|
@@ -100,19 +102,18 @@ class BusinessCentral::Object::DefaultDimensionTest < Minitest::Test
|
|
100
102
|
}.to_json
|
101
103
|
)
|
102
104
|
|
103
|
-
response = @default_dimension.create(
|
105
|
+
response = @default_dimension.create(
|
104
106
|
dimension_code: 'DEF',
|
105
107
|
dimension_value_code: 'GHI'
|
106
|
-
|
108
|
+
)
|
107
109
|
assert_equal response[:id], 4
|
108
110
|
end
|
109
111
|
|
110
|
-
|
111
112
|
def test_update
|
112
113
|
test_id = '2'
|
113
114
|
stub_request(:get, /defaultDimensions\(#{test_id}\)/)
|
114
115
|
.to_return(
|
115
|
-
status: 200,
|
116
|
+
status: 200,
|
116
117
|
body: {
|
117
118
|
etag: '3333',
|
118
119
|
id: test_id,
|
@@ -126,7 +127,7 @@ class BusinessCentral::Object::DefaultDimensionTest < Minitest::Test
|
|
126
127
|
|
127
128
|
stub_request(:patch, /defaultDimensions\(#{test_id}\)/)
|
128
129
|
.to_return(
|
129
|
-
status: 200,
|
130
|
+
status: 200,
|
130
131
|
body: {
|
131
132
|
etag: '4444',
|
132
133
|
id: test_id,
|
@@ -140,9 +141,7 @@ class BusinessCentral::Object::DefaultDimensionTest < Minitest::Test
|
|
140
141
|
|
141
142
|
response = @default_dimension.update(
|
142
143
|
test_id,
|
143
|
-
|
144
|
-
dimension_code: 'ZYX'
|
145
|
-
}
|
144
|
+
dimension_code: 'ZYX'
|
146
145
|
)
|
147
146
|
assert_equal response[:dimension_code], 'ZYX'
|
148
147
|
end
|
@@ -151,7 +150,7 @@ class BusinessCentral::Object::DefaultDimensionTest < Minitest::Test
|
|
151
150
|
test_id = '33333'
|
152
151
|
stub_request(:get, /defaultDimensions\(#{test_id}\)/)
|
153
152
|
.to_return(
|
154
|
-
status: 200,
|
153
|
+
status: 200,
|
155
154
|
body: {
|
156
155
|
etag: '5555',
|
157
156
|
id: test_id,
|
@@ -168,4 +167,4 @@ class BusinessCentral::Object::DefaultDimensionTest < Minitest::Test
|
|
168
167
|
|
169
168
|
assert @default_dimension.destroy(test_id)
|
170
169
|
end
|
171
|
-
end
|
170
|
+
end
|