business-central 1.0.5 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +45 -32
- data/lib/business_central/client.rb +7 -52
- data/lib/business_central/exceptions.rb +11 -29
- data/lib/business_central/object/{attachment.rb → attachments.rb} +9 -11
- data/lib/business_central/object/base.rb +42 -114
- data/lib/business_central/object/companies.rb +19 -0
- data/lib/business_central/object/filter_query.rb +2 -0
- data/lib/business_central/object/object_helper.rb +10 -37
- data/lib/business_central/object/picture.rb +4 -40
- data/lib/business_central/object/request.rb +14 -15
- data/lib/business_central/object/response.rb +5 -1
- data/lib/business_central/object/url_builder.rb +16 -12
- data/lib/business_central/object/url_helper.rb +16 -2
- data/lib/business_central/version.rb +1 -1
- data/lib/business_central/web_service.rb +2 -0
- data/lib/business_central.rb +4 -55
- data/lib/refinements/strings.rb +42 -0
- data/test/business_central/client_test.rb +24 -0
- data/test/business_central/exceptions_test.rb +40 -0
- data/test/business_central/object/{attachment_test.rb → attachments_test.rb} +5 -6
- data/test/business_central/object/base_test.rb +59 -22
- data/test/business_central/object/{company_test.rb → companies_test.rb} +3 -21
- data/test/business_central/object/picture_test.rb +7 -16
- data/test/business_central/object/response_test.rb +5 -0
- data/test/business_central/web_service_test.rb +7 -2
- metadata +38 -167
- data/lib/business_central/object/account.rb +0 -13
- data/lib/business_central/object/aged_account_payable.rb +0 -13
- data/lib/business_central/object/aged_account_receivable.rb +0 -13
- data/lib/business_central/object/argument_helper.rb +0 -22
- data/lib/business_central/object/balance_sheet.rb +0 -13
- data/lib/business_central/object/cash_flow_statement.rb +0 -13
- data/lib/business_central/object/company.rb +0 -18
- data/lib/business_central/object/company_information.rb +0 -14
- data/lib/business_central/object/country_region.rb +0 -26
- data/lib/business_central/object/currency.rb +0 -29
- data/lib/business_central/object/customer.rb +0 -34
- data/lib/business_central/object/customer_financial_detail.rb +0 -13
- data/lib/business_central/object/customer_payment.rb +0 -43
- data/lib/business_central/object/customer_payment_journal.rb +0 -25
- data/lib/business_central/object/customer_sale.rb +0 -13
- data/lib/business_central/object/default_dimension.rb +0 -51
- data/lib/business_central/object/dimension.rb +0 -20
- data/lib/business_central/object/dimension_line.rb +0 -37
- data/lib/business_central/object/dimension_value.rb +0 -28
- data/lib/business_central/object/employee.rb +0 -21
- data/lib/business_central/object/general_ledger_entry.rb +0 -13
- data/lib/business_central/object/income_statement.rb +0 -13
- data/lib/business_central/object/irs1099_code.rb +0 -16
- data/lib/business_central/object/item.rb +0 -47
- data/lib/business_central/object/item_category.rb +0 -16
- data/lib/business_central/object/journal.rb +0 -29
- data/lib/business_central/object/journal_line.rb +0 -48
- data/lib/business_central/object/payment_method.rb +0 -16
- data/lib/business_central/object/payment_term.rb +0 -16
- data/lib/business_central/object/purchase_invoice.rb +0 -69
- data/lib/business_central/object/purchase_invoice_line.rb +0 -37
- data/lib/business_central/object/retained_earning_statement.rb +0 -13
- data/lib/business_central/object/sales_credit_memo.rb +0 -20
- data/lib/business_central/object/sales_credit_memo_line.rb +0 -30
- data/lib/business_central/object/sales_invoice.rb +0 -62
- data/lib/business_central/object/sales_invoice_line.rb +0 -30
- data/lib/business_central/object/sales_order.rb +0 -20
- data/lib/business_central/object/sales_order_line.rb +0 -30
- data/lib/business_central/object/sales_quote.rb +0 -20
- data/lib/business_central/object/sales_quote_line.rb +0 -30
- data/lib/business_central/object/shipment_method.rb +0 -16
- data/lib/business_central/object/subscription.rb +0 -16
- data/lib/business_central/object/tax_area.rb +0 -16
- data/lib/business_central/object/tax_group.rb +0 -16
- data/lib/business_central/object/time_registration_entry.rb +0 -16
- data/lib/business_central/object/trial_balance.rb +0 -13
- data/lib/business_central/object/units_of_measure.rb +0 -16
- data/lib/business_central/object/validation.rb +0 -57
- data/lib/business_central/object/vendor.rb +0 -42
- data/lib/business_central/object/vendor_purchase.rb +0 -13
- data/lib/core_ext/string.rb +0 -31
- data/test/business_central/object/account_test.rb +0 -67
- data/test/business_central/object/aged_account_payable_test.rb +0 -61
- data/test/business_central/object/aged_account_receivable_test.rb +0 -61
- data/test/business_central/object/balance_sheet_test.rb +0 -61
- data/test/business_central/object/cash_flow_statement_test.rb +0 -61
- data/test/business_central/object/company_information_test.rb +0 -81
- data/test/business_central/object/country_region_test.rb +0 -129
- data/test/business_central/object/currency_test.rb +0 -150
- data/test/business_central/object/customer_financial_detail_test.rb +0 -68
- data/test/business_central/object/customer_payment_journal_test.rb +0 -134
- data/test/business_central/object/customer_payment_test.rb +0 -141
- data/test/business_central/object/customer_sale_test.rb +0 -72
- data/test/business_central/object/customer_test.rb +0 -168
- data/test/business_central/object/default_dimension_test.rb +0 -170
- data/test/business_central/object/dimension_line_test.rb +0 -165
- data/test/business_central/object/dimension_test.rb +0 -65
- data/test/business_central/object/dimension_value_test.rb +0 -68
- data/test/business_central/object/employee_test.rb +0 -141
- data/test/business_central/object/general_ledger_entry_test.rb +0 -82
- data/test/business_central/object/income_statement_test.rb +0 -82
- data/test/business_central/object/irs1099_code_test.rb +0 -124
- data/test/business_central/object/item_category_test.rb +0 -122
- data/test/business_central/object/item_test.rb +0 -121
- data/test/business_central/object/journal_line_test.rb +0 -152
- data/test/business_central/object/journal_test.rb +0 -144
- data/test/business_central/object/payment_method_test.rb +0 -134
- data/test/business_central/object/payment_term_test.rb +0 -134
- data/test/business_central/object/purchase_invoice_line_test.rb +0 -123
- data/test/business_central/object/purchase_invoice_test.rb +0 -119
- data/test/business_central/object/retained_earning_statement_test.rb +0 -52
- data/test/business_central/object/sales_credit_memo_line_test.rb +0 -134
- data/test/business_central/object/sales_credit_memo_test.rb +0 -146
- data/test/business_central/object/sales_invoice_line_test.rb +0 -164
- data/test/business_central/object/sales_invoice_test.rb +0 -156
- data/test/business_central/object/sales_order_line_test.rb +0 -134
- data/test/business_central/object/sales_order_test.rb +0 -146
- data/test/business_central/object/sales_quote_line_test.rb +0 -134
- data/test/business_central/object/sales_quote_test.rb +0 -146
- data/test/business_central/object/shipment_method_test.rb +0 -133
- data/test/business_central/object/subscription_test.rb +0 -126
- data/test/business_central/object/tax_area_test.rb +0 -126
- data/test/business_central/object/tax_group_test.rb +0 -126
- data/test/business_central/object/time_registration_entry_test.rb +0 -126
- data/test/business_central/object/trial_balance_test.rb +0 -82
- data/test/business_central/object/units_of_measure_test.rb +0 -126
- data/test/business_central/object/validation_test.rb +0 -62
- data/test/business_central/object/vendor_purchase_test.rb +0 -82
- data/test/business_central/object/vendor_test.rb +0 -119
@@ -1,156 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
# rake test TEST=test/business_central/object/sales_invoice_test.rb
|
5
|
-
|
6
|
-
class BusinessCentral::Object::SalesInvoiceTest < Minitest::Test
|
7
|
-
def setup
|
8
|
-
@company_id = '123456'
|
9
|
-
@client = BusinessCentral::Client.new
|
10
|
-
@sales_invoice = @client.sales_invoice(company_id: @company_id)
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_find_all
|
14
|
-
stub_request(:get, /salesInvoices/)
|
15
|
-
.to_return(
|
16
|
-
status: 200,
|
17
|
-
body: {
|
18
|
-
'value': [
|
19
|
-
{
|
20
|
-
id: '1234',
|
21
|
-
number: 1,
|
22
|
-
customerPurchaseOrderReference: 'C1'
|
23
|
-
}
|
24
|
-
]
|
25
|
-
}.to_json
|
26
|
-
)
|
27
|
-
|
28
|
-
response = @sales_invoice.find_all
|
29
|
-
assert_equal response.first[:customer_purchase_order_reference], 'C1'
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_find_by_id
|
33
|
-
test_id = '09876'
|
34
|
-
stub_request(:get, /salesInvoices\(#{test_id}\)/)
|
35
|
-
.to_return(
|
36
|
-
status: 200,
|
37
|
-
body: {
|
38
|
-
id: test_id,
|
39
|
-
number: 2,
|
40
|
-
customerPurchaseOrderReference: 'C2'
|
41
|
-
}.to_json
|
42
|
-
)
|
43
|
-
|
44
|
-
response = @sales_invoice.find_by_id(test_id)
|
45
|
-
assert_equal response[:customer_purchase_order_reference], 'C2'
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_where
|
49
|
-
test_filter = "customerPurchaseOrderReference eq 'C3'"
|
50
|
-
stub_request(:get, /salesInvoices\?\$filter=#{test_filter}/)
|
51
|
-
.to_return(
|
52
|
-
status: 200,
|
53
|
-
body: {
|
54
|
-
'value': [
|
55
|
-
{
|
56
|
-
id: '345',
|
57
|
-
number: 3,
|
58
|
-
customerPurchaseOrderReference: 'C3'
|
59
|
-
}
|
60
|
-
]
|
61
|
-
}.to_json
|
62
|
-
)
|
63
|
-
|
64
|
-
response = @sales_invoice.where(test_filter)
|
65
|
-
assert_equal response.first[:customer_purchase_order_reference], 'C3'
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_create
|
69
|
-
stub_request(:post, /salesInvoices/)
|
70
|
-
.to_return(
|
71
|
-
status: 200,
|
72
|
-
body: {
|
73
|
-
id: '678',
|
74
|
-
number: 4,
|
75
|
-
customerPurchaseOrderReference: 'C4'
|
76
|
-
}.to_json
|
77
|
-
)
|
78
|
-
|
79
|
-
response = @sales_invoice.create(
|
80
|
-
number: 4,
|
81
|
-
customer_purchase_order_reference: 'C4'
|
82
|
-
)
|
83
|
-
assert_equal response[:customer_purchase_order_reference], 'C4'
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_update
|
87
|
-
test_id = '011123'
|
88
|
-
stub_request(:get, /salesInvoices\(#{test_id}\)/)
|
89
|
-
.to_return(
|
90
|
-
status: 200,
|
91
|
-
body: {
|
92
|
-
etag: '112',
|
93
|
-
id: test_id,
|
94
|
-
number: 5,
|
95
|
-
customerPurchaseOrderReference: 'C5'
|
96
|
-
}.to_json
|
97
|
-
)
|
98
|
-
|
99
|
-
stub_request(:patch, /salesInvoices\(#{test_id}\)/)
|
100
|
-
.to_return(
|
101
|
-
status: 200,
|
102
|
-
body: {
|
103
|
-
id: test_id,
|
104
|
-
number: 5,
|
105
|
-
customerPurchaseOrderReference: 'C6'
|
106
|
-
}.to_json
|
107
|
-
)
|
108
|
-
|
109
|
-
response = @sales_invoice.update(
|
110
|
-
test_id,
|
111
|
-
customer_purchase_order_reference: 'C6'
|
112
|
-
)
|
113
|
-
assert_equal response[:customer_purchase_order_reference], 'C6'
|
114
|
-
end
|
115
|
-
|
116
|
-
def test_delete
|
117
|
-
test_id = '0111245'
|
118
|
-
stub_request(:get, /salesInvoices\(#{test_id}\)/)
|
119
|
-
.to_return(
|
120
|
-
status: 200,
|
121
|
-
body: {
|
122
|
-
etag: '113',
|
123
|
-
id: 7,
|
124
|
-
number: 7,
|
125
|
-
customerPurchaseOrderReference: 'C7'
|
126
|
-
}.to_json
|
127
|
-
)
|
128
|
-
|
129
|
-
stub_request(:delete, /salesInvoices\(#{test_id}\)/)
|
130
|
-
.to_return(status: 204)
|
131
|
-
|
132
|
-
assert @sales_invoice.destroy(test_id)
|
133
|
-
end
|
134
|
-
|
135
|
-
def test_line_navigation
|
136
|
-
stub_request(:get, %r{salesInvoices\(\d+\)\/salesInvoiceLines})
|
137
|
-
.to_return(
|
138
|
-
status: 200,
|
139
|
-
body: {
|
140
|
-
'value': [
|
141
|
-
{
|
142
|
-
id: '123',
|
143
|
-
documentId: 5,
|
144
|
-
sequence: 10_000,
|
145
|
-
itemId: 5,
|
146
|
-
description: 'salesInvoiceLine1'
|
147
|
-
}
|
148
|
-
]
|
149
|
-
}.to_json
|
150
|
-
)
|
151
|
-
|
152
|
-
response = @client.sales_invoice(company_id: @company_id, id: '123')
|
153
|
-
.sales_invoice_line.find_all
|
154
|
-
assert_equal response.first[:description], 'salesInvoiceLine1'
|
155
|
-
end
|
156
|
-
end
|
@@ -1,134 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
# rake test TEST=test/business_central/object/sales_order_line_test.rb
|
5
|
-
|
6
|
-
class BusinessCentral::Object::SalesOrderLineTest < Minitest::Test
|
7
|
-
def setup
|
8
|
-
@company_id = '123456'
|
9
|
-
@client = BusinessCentral::Client.new
|
10
|
-
@sales_order_line = @client.sales_order_line(
|
11
|
-
company_id: @company_id,
|
12
|
-
parent: 'salesOrders',
|
13
|
-
parent_id: '123'
|
14
|
-
)
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_find_all
|
18
|
-
stub_request(:get, %r{salesOrders\(\d+\)\/salesOrderLines})
|
19
|
-
.to_return(
|
20
|
-
status: 200,
|
21
|
-
body: {
|
22
|
-
'value': [
|
23
|
-
{
|
24
|
-
id: 1,
|
25
|
-
sequence: '1009',
|
26
|
-
lineType: 'Comment'
|
27
|
-
}
|
28
|
-
]
|
29
|
-
}.to_json
|
30
|
-
)
|
31
|
-
|
32
|
-
response = @sales_order_line.find_all
|
33
|
-
assert_equal response.first[:sequence], '1009'
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_find_by_id
|
37
|
-
test_id = '09876'
|
38
|
-
stub_request(:get, %r{salesOrders\(\d+\)\/salesOrderLines\(#{test_id}\)})
|
39
|
-
.to_return(
|
40
|
-
status: 200,
|
41
|
-
body: {
|
42
|
-
id: test_id,
|
43
|
-
sequence: '1010',
|
44
|
-
lineType: 'Comment'
|
45
|
-
}.to_json
|
46
|
-
)
|
47
|
-
|
48
|
-
response = @sales_order_line.find_by_id(test_id)
|
49
|
-
assert_equal response[:sequence], '1010'
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_where
|
53
|
-
test_filter = "sequence eq '1020'"
|
54
|
-
stub_request(:get, %r{salesOrders\(\d+\)\/salesOrderLines\?\$filter=#{test_filter}})
|
55
|
-
.to_return(
|
56
|
-
status: 200,
|
57
|
-
body: {
|
58
|
-
'value': [
|
59
|
-
{
|
60
|
-
id: '345',
|
61
|
-
sequence: '1011'
|
62
|
-
}
|
63
|
-
]
|
64
|
-
}.to_json
|
65
|
-
)
|
66
|
-
|
67
|
-
response = @sales_order_line.where(test_filter)
|
68
|
-
assert_equal response.first[:sequence], '1011'
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_create
|
72
|
-
stub_request(:post, %r{salesOrders\(\d+\)\/salesOrderLines})
|
73
|
-
.to_return(
|
74
|
-
status: 200,
|
75
|
-
body: {
|
76
|
-
id: '678',
|
77
|
-
sequence: '1012'
|
78
|
-
}.to_json
|
79
|
-
)
|
80
|
-
|
81
|
-
response = @sales_order_line.create(
|
82
|
-
sequence: '1012'
|
83
|
-
)
|
84
|
-
assert_equal response[:sequence], '1012'
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_update
|
88
|
-
test_id = '011123'
|
89
|
-
stub_request(:get, %r{salesOrders\(\d+\)\/salesOrderLines\(#{test_id}\)})
|
90
|
-
.to_return(
|
91
|
-
status: 200,
|
92
|
-
body: {
|
93
|
-
etag: '112',
|
94
|
-
id: test_id,
|
95
|
-
sequence: '1012',
|
96
|
-
lineType: 'Comment'
|
97
|
-
}.to_json
|
98
|
-
)
|
99
|
-
|
100
|
-
stub_request(:patch, %r{salesOrders\(\d+\)\/salesOrderLines\(#{test_id}\)})
|
101
|
-
.to_return(
|
102
|
-
status: 200,
|
103
|
-
body: {
|
104
|
-
id: test_id,
|
105
|
-
sequence: '1012',
|
106
|
-
lineType: 'Account'
|
107
|
-
}.to_json
|
108
|
-
)
|
109
|
-
|
110
|
-
response = @sales_order_line.update(
|
111
|
-
test_id,
|
112
|
-
line_type: 'Account'
|
113
|
-
)
|
114
|
-
assert_equal response[:line_type], 'Account'
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_delete
|
118
|
-
test_id = '0111245'
|
119
|
-
stub_request(:get, %r{salesOrders\(\d+\)\/salesOrderLines\(#{test_id}\)})
|
120
|
-
.to_return(
|
121
|
-
status: 200,
|
122
|
-
body: {
|
123
|
-
etag: '113',
|
124
|
-
id: 7,
|
125
|
-
sequence: '1013'
|
126
|
-
}.to_json
|
127
|
-
)
|
128
|
-
|
129
|
-
stub_request(:delete, %r{salesOrders\(\d+\)\/salesOrderLines\(#{test_id}\)})
|
130
|
-
.to_return(status: 204)
|
131
|
-
|
132
|
-
assert @sales_order_line.destroy(test_id)
|
133
|
-
end
|
134
|
-
end
|
@@ -1,146 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
# rake test TEST=test/business_central/object/sales_order_test.rb
|
5
|
-
|
6
|
-
class BusinessCentral::Object::SalesOrderTest < Minitest::Test
|
7
|
-
def setup
|
8
|
-
@company_id = '123456'
|
9
|
-
@client = BusinessCentral::Client.new
|
10
|
-
@sales_order = @client.sales_order(company_id: @company_id)
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_find_all
|
14
|
-
stub_request(:get, /salesOrders/)
|
15
|
-
.to_return(
|
16
|
-
status: 200,
|
17
|
-
body: {
|
18
|
-
'value': [
|
19
|
-
{
|
20
|
-
id: 1,
|
21
|
-
number: '1009'
|
22
|
-
}
|
23
|
-
]
|
24
|
-
}.to_json
|
25
|
-
)
|
26
|
-
|
27
|
-
response = @sales_order.find_all
|
28
|
-
assert_equal response.first[:number], '1009'
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_find_by_id
|
32
|
-
test_id = '09876'
|
33
|
-
stub_request(:get, /salesOrders\(#{test_id}\)/)
|
34
|
-
.to_return(
|
35
|
-
status: 200,
|
36
|
-
body: {
|
37
|
-
id: test_id,
|
38
|
-
number: '1010'
|
39
|
-
}.to_json
|
40
|
-
)
|
41
|
-
|
42
|
-
response = @sales_order.find_by_id(test_id)
|
43
|
-
assert_equal response[:number], '1010'
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_where
|
47
|
-
test_filter = "number eq '1020'"
|
48
|
-
stub_request(:get, /salesOrders\?\$filter=#{test_filter}/)
|
49
|
-
.to_return(
|
50
|
-
status: 200,
|
51
|
-
body: {
|
52
|
-
'value': [
|
53
|
-
{
|
54
|
-
id: '345',
|
55
|
-
number: '1011'
|
56
|
-
}
|
57
|
-
]
|
58
|
-
}.to_json
|
59
|
-
)
|
60
|
-
|
61
|
-
response = @sales_order.where(test_filter)
|
62
|
-
assert_equal response.first[:number], '1011'
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_create
|
66
|
-
stub_request(:post, /salesOrders/)
|
67
|
-
.to_return(
|
68
|
-
status: 200,
|
69
|
-
body: {
|
70
|
-
id: '678',
|
71
|
-
number: '1012'
|
72
|
-
}.to_json
|
73
|
-
)
|
74
|
-
|
75
|
-
response = @sales_order.create(
|
76
|
-
number: '1012'
|
77
|
-
)
|
78
|
-
assert_equal response[:number], '1012'
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_update
|
82
|
-
test_id = '011123'
|
83
|
-
stub_request(:get, /salesOrders\(#{test_id}\)/)
|
84
|
-
.to_return(
|
85
|
-
status: 200,
|
86
|
-
body: {
|
87
|
-
etag: '112',
|
88
|
-
id: test_id,
|
89
|
-
number: '1012'
|
90
|
-
}.to_json
|
91
|
-
)
|
92
|
-
|
93
|
-
stub_request(:patch, /salesOrders\(#{test_id}\)/)
|
94
|
-
.to_return(
|
95
|
-
status: 200,
|
96
|
-
body: {
|
97
|
-
id: test_id,
|
98
|
-
number: '1013'
|
99
|
-
}.to_json
|
100
|
-
)
|
101
|
-
|
102
|
-
response = @sales_order.update(
|
103
|
-
test_id,
|
104
|
-
number: '1013'
|
105
|
-
)
|
106
|
-
assert_equal response[:number], '1013'
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_delete
|
110
|
-
test_id = '0111245'
|
111
|
-
stub_request(:get, /salesOrders\(#{test_id}\)/)
|
112
|
-
.to_return(
|
113
|
-
status: 200,
|
114
|
-
body: {
|
115
|
-
etag: '113',
|
116
|
-
id: 7,
|
117
|
-
number: '1013'
|
118
|
-
}.to_json
|
119
|
-
)
|
120
|
-
|
121
|
-
stub_request(:delete, /salesOrders\(#{test_id}\)/)
|
122
|
-
.to_return(status: 204)
|
123
|
-
|
124
|
-
assert @sales_order.destroy(test_id)
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_line_navigation
|
128
|
-
stub_request(:get, %r{salesOrders\(\d+\)\/salesOrderLines})
|
129
|
-
.to_return(
|
130
|
-
status: 200,
|
131
|
-
body: {
|
132
|
-
'value': [
|
133
|
-
{
|
134
|
-
id: 1,
|
135
|
-
sequence: '1009',
|
136
|
-
lineType: 'Comment'
|
137
|
-
}
|
138
|
-
]
|
139
|
-
}.to_json
|
140
|
-
)
|
141
|
-
|
142
|
-
response = @client.sales_order(company_id: @company_id, id: '123')
|
143
|
-
.sales_order_line.find_all
|
144
|
-
assert_equal response.first[:sequence], '1009'
|
145
|
-
end
|
146
|
-
end
|
@@ -1,134 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
# rake test TEST=test/business_central/object/sales_quote_line_test.rb
|
5
|
-
|
6
|
-
class BusinessCentral::Object::SalesQuoteLineTest < Minitest::Test
|
7
|
-
def setup
|
8
|
-
@company_id = '123456'
|
9
|
-
@client = BusinessCentral::Client.new
|
10
|
-
@sales_quote_line = @client.sales_quote_line(
|
11
|
-
company_id: @company_id,
|
12
|
-
parent: 'salesQuotes',
|
13
|
-
parent_id: '123'
|
14
|
-
)
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_find_all
|
18
|
-
stub_request(:get, %r{salesQuotes\(\d+\)\/salesQuoteLines})
|
19
|
-
.to_return(
|
20
|
-
status: 200,
|
21
|
-
body: {
|
22
|
-
'value': [
|
23
|
-
{
|
24
|
-
id: 1,
|
25
|
-
sequence: '1009',
|
26
|
-
lineType: 'Comment'
|
27
|
-
}
|
28
|
-
]
|
29
|
-
}.to_json
|
30
|
-
)
|
31
|
-
|
32
|
-
response = @sales_quote_line.find_all
|
33
|
-
assert_equal response.first[:sequence], '1009'
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_find_by_id
|
37
|
-
test_id = '09876'
|
38
|
-
stub_request(:get, %r{salesQuotes\(\d+\)\/salesQuoteLines\(#{test_id}\)})
|
39
|
-
.to_return(
|
40
|
-
status: 200,
|
41
|
-
body: {
|
42
|
-
id: test_id,
|
43
|
-
sequence: '1010',
|
44
|
-
lineType: 'Comment'
|
45
|
-
}.to_json
|
46
|
-
)
|
47
|
-
|
48
|
-
response = @sales_quote_line.find_by_id(test_id)
|
49
|
-
assert_equal response[:sequence], '1010'
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_where
|
53
|
-
test_filter = "sequence eq '1020'"
|
54
|
-
stub_request(:get, %r{salesQuotes\(\d+\)\/salesQuoteLines\?\$filter=#{test_filter}})
|
55
|
-
.to_return(
|
56
|
-
status: 200,
|
57
|
-
body: {
|
58
|
-
'value': [
|
59
|
-
{
|
60
|
-
id: '345',
|
61
|
-
sequence: '1011'
|
62
|
-
}
|
63
|
-
]
|
64
|
-
}.to_json
|
65
|
-
)
|
66
|
-
|
67
|
-
response = @sales_quote_line.where(test_filter)
|
68
|
-
assert_equal response.first[:sequence], '1011'
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_create
|
72
|
-
stub_request(:post, %r{salesQuotes\(\d+\)\/salesQuoteLines})
|
73
|
-
.to_return(
|
74
|
-
status: 200,
|
75
|
-
body: {
|
76
|
-
id: '678',
|
77
|
-
sequence: '1012'
|
78
|
-
}.to_json
|
79
|
-
)
|
80
|
-
|
81
|
-
response = @sales_quote_line.create(
|
82
|
-
sequence: '1012'
|
83
|
-
)
|
84
|
-
assert_equal response[:sequence], '1012'
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_update
|
88
|
-
test_id = '011123'
|
89
|
-
stub_request(:get, %r{salesQuotes\(\d+\)\/salesQuoteLines\(#{test_id}\)})
|
90
|
-
.to_return(
|
91
|
-
status: 200,
|
92
|
-
body: {
|
93
|
-
etag: '112',
|
94
|
-
id: test_id,
|
95
|
-
sequence: '1012',
|
96
|
-
lineType: 'Comment'
|
97
|
-
}.to_json
|
98
|
-
)
|
99
|
-
|
100
|
-
stub_request(:patch, %r{salesQuotes\(\d+\)\/salesQuoteLines\(#{test_id}\)})
|
101
|
-
.to_return(
|
102
|
-
status: 200,
|
103
|
-
body: {
|
104
|
-
id: test_id,
|
105
|
-
sequence: '1012',
|
106
|
-
lineType: 'Account'
|
107
|
-
}.to_json
|
108
|
-
)
|
109
|
-
|
110
|
-
response = @sales_quote_line.update(
|
111
|
-
test_id,
|
112
|
-
line_type: 'Account'
|
113
|
-
)
|
114
|
-
assert_equal response[:line_type], 'Account'
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_delete
|
118
|
-
test_id = '0111245'
|
119
|
-
stub_request(:get, %r{salesQuotes\(\d+\)\/salesQuoteLines\(#{test_id}\)})
|
120
|
-
.to_return(
|
121
|
-
status: 200,
|
122
|
-
body: {
|
123
|
-
etag: '113',
|
124
|
-
id: 7,
|
125
|
-
sequence: '1013'
|
126
|
-
}.to_json
|
127
|
-
)
|
128
|
-
|
129
|
-
stub_request(:delete, %r{salesQuotes\(\d+\)\/salesQuoteLines\(#{test_id}\)})
|
130
|
-
.to_return(status: 204)
|
131
|
-
|
132
|
-
assert @sales_quote_line.destroy(test_id)
|
133
|
-
end
|
134
|
-
end
|
@@ -1,146 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
# rake test TEST=test/business_central/object/sales_quote_test.rb
|
5
|
-
|
6
|
-
class BusinessCentral::Object::SalesQuoteTest < Minitest::Test
|
7
|
-
def setup
|
8
|
-
@company_id = '123456'
|
9
|
-
@client = BusinessCentral::Client.new
|
10
|
-
@sales_quote = @client.sales_quote(company_id: @company_id)
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_find_all
|
14
|
-
stub_request(:get, /salesQuotes/)
|
15
|
-
.to_return(
|
16
|
-
status: 200,
|
17
|
-
body: {
|
18
|
-
'value': [
|
19
|
-
{
|
20
|
-
id: 1,
|
21
|
-
number: '1009'
|
22
|
-
}
|
23
|
-
]
|
24
|
-
}.to_json
|
25
|
-
)
|
26
|
-
|
27
|
-
response = @sales_quote.find_all
|
28
|
-
assert_equal response.first[:number], '1009'
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_find_by_id
|
32
|
-
test_id = '09876'
|
33
|
-
stub_request(:get, /salesQuotes\(#{test_id}\)/)
|
34
|
-
.to_return(
|
35
|
-
status: 200,
|
36
|
-
body: {
|
37
|
-
id: test_id,
|
38
|
-
number: '1010'
|
39
|
-
}.to_json
|
40
|
-
)
|
41
|
-
|
42
|
-
response = @sales_quote.find_by_id(test_id)
|
43
|
-
assert_equal response[:number], '1010'
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_where
|
47
|
-
test_filter = "number eq '1020'"
|
48
|
-
stub_request(:get, /salesQuotes\?\$filter=#{test_filter}/)
|
49
|
-
.to_return(
|
50
|
-
status: 200,
|
51
|
-
body: {
|
52
|
-
'value': [
|
53
|
-
{
|
54
|
-
id: '345',
|
55
|
-
number: '1011'
|
56
|
-
}
|
57
|
-
]
|
58
|
-
}.to_json
|
59
|
-
)
|
60
|
-
|
61
|
-
response = @sales_quote.where(test_filter)
|
62
|
-
assert_equal response.first[:number], '1011'
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_create
|
66
|
-
stub_request(:post, /salesQuotes/)
|
67
|
-
.to_return(
|
68
|
-
status: 200,
|
69
|
-
body: {
|
70
|
-
id: '678',
|
71
|
-
number: '1012'
|
72
|
-
}.to_json
|
73
|
-
)
|
74
|
-
|
75
|
-
response = @sales_quote.create(
|
76
|
-
number: '1012'
|
77
|
-
)
|
78
|
-
assert_equal response[:number], '1012'
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_update
|
82
|
-
test_id = '011123'
|
83
|
-
stub_request(:get, /salesQuotes\(#{test_id}\)/)
|
84
|
-
.to_return(
|
85
|
-
status: 200,
|
86
|
-
body: {
|
87
|
-
etag: '112',
|
88
|
-
id: test_id,
|
89
|
-
number: '1012'
|
90
|
-
}.to_json
|
91
|
-
)
|
92
|
-
|
93
|
-
stub_request(:patch, /salesQuotes\(#{test_id}\)/)
|
94
|
-
.to_return(
|
95
|
-
status: 200,
|
96
|
-
body: {
|
97
|
-
id: test_id,
|
98
|
-
number: '1013'
|
99
|
-
}.to_json
|
100
|
-
)
|
101
|
-
|
102
|
-
response = @sales_quote.update(
|
103
|
-
test_id,
|
104
|
-
number: '1013'
|
105
|
-
)
|
106
|
-
assert_equal response[:number], '1013'
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_delete
|
110
|
-
test_id = '0111245'
|
111
|
-
stub_request(:get, /salesQuotes\(#{test_id}\)/)
|
112
|
-
.to_return(
|
113
|
-
status: 200,
|
114
|
-
body: {
|
115
|
-
etag: '113',
|
116
|
-
id: 7,
|
117
|
-
number: '1013'
|
118
|
-
}.to_json
|
119
|
-
)
|
120
|
-
|
121
|
-
stub_request(:delete, /salesQuotes\(#{test_id}\)/)
|
122
|
-
.to_return(status: 204)
|
123
|
-
|
124
|
-
assert @sales_quote.destroy(test_id)
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_line_navigation
|
128
|
-
stub_request(:get, %r{salesQuotes\(\d+\)\/salesQuoteLines})
|
129
|
-
.to_return(
|
130
|
-
status: 200,
|
131
|
-
body: {
|
132
|
-
'value': [
|
133
|
-
{
|
134
|
-
id: 1,
|
135
|
-
sequence: '1009',
|
136
|
-
lineType: 'Comment'
|
137
|
-
}
|
138
|
-
]
|
139
|
-
}.to_json
|
140
|
-
)
|
141
|
-
|
142
|
-
response = @client.sales_quote(company_id: @company_id, id: '123')
|
143
|
-
.sales_quote_line.find_all
|
144
|
-
assert_equal response.first[:sequence], '1009'
|
145
|
-
end
|
146
|
-
end
|