business-central 1.0.0 → 1.0.5
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.rb +52 -2
- data/lib/business_central/client.rb +87 -39
- data/lib/business_central/exceptions.rb +30 -10
- data/lib/business_central/object/account.rb +4 -2
- data/lib/business_central/object/aged_account_payable.rb +13 -0
- data/lib/business_central/object/aged_account_receivable.rb +13 -0
- 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 +13 -0
- data/lib/business_central/object/base.rb +100 -49
- data/lib/business_central/object/cash_flow_statement.rb +13 -0
- data/lib/business_central/object/company.rb +9 -2
- data/lib/business_central/object/company_information.rb +14 -0
- data/lib/business_central/object/country_region.rb +26 -0
- data/lib/business_central/object/currency.rb +29 -0
- data/lib/business_central/object/customer.rb +34 -0
- data/lib/business_central/object/customer_financial_detail.rb +13 -0
- data/lib/business_central/object/customer_payment.rb +43 -0
- data/lib/business_central/object/customer_payment_journal.rb +25 -0
- data/lib/business_central/object/customer_sale.rb +13 -0
- data/lib/business_central/object/default_dimension.rb +51 -0
- 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 +16 -19
- 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/object_helper.rb +49 -0
- 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 -16
- data/lib/business_central/object/purchase_invoice_line.rb +14 -18
- data/lib/business_central/object/request.rb +61 -50
- data/lib/business_central/object/response.rb +28 -22
- 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 +32 -0
- data/lib/business_central/object/validation.rb +11 -8
- data/lib/business_central/object/vendor.rb +12 -15
- 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/core_ext/string.rb +18 -12
- data/test/business_central/client_test.rb +49 -7
- data/test/business_central/object/account_test.rb +24 -5
- data/test/business_central/object/aged_account_payable_test.rb +61 -0
- data/test/business_central/object/aged_account_receivable_test.rb +61 -0
- data/test/business_central/object/attachment_test.rb +117 -0
- data/test/business_central/object/balance_sheet_test.rb +61 -0
- data/test/business_central/object/base_test.rb +41 -0
- data/test/business_central/object/cash_flow_statement_test.rb +61 -0
- data/test/business_central/object/company_information_test.rb +81 -0
- data/test/business_central/object/company_test.rb +24 -11
- data/test/business_central/object/country_region_test.rb +129 -0
- data/test/business_central/object/currency_test.rb +150 -0
- data/test/business_central/object/customer_financial_detail_test.rb +68 -0
- data/test/business_central/object/customer_payment_journal_test.rb +134 -0
- data/test/business_central/object/customer_payment_test.rb +141 -0
- data/test/business_central/object/customer_sale_test.rb +72 -0
- data/test/business_central/object/customer_test.rb +168 -0
- data/test/business_central/object/default_dimension_test.rb +170 -0
- 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 -23
- 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 -21
- data/test/business_central/object/purchase_invoice_test.rb +15 -21
- data/test/business_central/object/request_test.rb +75 -18
- data/test/business_central/object/response_test.rb +29 -9
- 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 -22
- data/test/business_central/web_service_test.rb +95 -0
- data/test/business_central_test.rb +3 -1
- data/test/test_helper.rb +16 -6
- metadata +199 -33
- data/lib/business_central/object/helper.rb +0 -15
@@ -1,13 +1,9 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
2
4
|
# rake test TEST=test/business_central/object/response_test.rb
|
3
5
|
|
4
6
|
class BusinessCentral::Object::ResponseTest < Minitest::Test
|
5
|
-
def test_process_response
|
6
|
-
params = '{"newKey": "value"}'
|
7
|
-
request = BusinessCentral::Object::Response.new(params).results
|
8
|
-
assert request.has_key?(:new_key)
|
9
|
-
end
|
10
|
-
|
11
7
|
def test_success
|
12
8
|
assert BusinessCentral::Object::Response.success?(200)
|
13
9
|
end
|
@@ -21,6 +17,30 @@ class BusinessCentral::Object::ResponseTest < Minitest::Test
|
|
21
17
|
end
|
22
18
|
|
23
19
|
def test_no_response
|
24
|
-
BusinessCentral::Object::Response.new(
|
20
|
+
BusinessCentral::Object::Response.new('').results
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_process_response
|
24
|
+
params = '{"newKey": "value"}'
|
25
|
+
request = BusinessCentral::Object::Response.new(params).results
|
26
|
+
assert request.key?(:new_key)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_process_etag
|
30
|
+
params = '{"@odata.etag": "123"}'
|
31
|
+
request = BusinessCentral::Object::Response.new(params).results
|
32
|
+
assert request.key?(:etag)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_process_context
|
36
|
+
params = '{"@odata.context": "123"}'
|
37
|
+
request = BusinessCentral::Object::Response.new(params).results
|
38
|
+
assert request.key?(:context)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_process_inner_hash
|
42
|
+
params = '{"item": { "id": "123" }}'
|
43
|
+
request = BusinessCentral::Object::Response.new(params).results
|
44
|
+
assert request.key?(:item)
|
25
45
|
end
|
26
|
-
end
|
46
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
# rake test TEST=test/business_central/object/retained_earning_statement_test.rb
|
5
|
+
|
6
|
+
class BusinessCentral::Object::RetainedEarningStatementTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
@company_id = '123456'
|
9
|
+
@client = BusinessCentral::Client.new
|
10
|
+
@retained_earning_statement = @client.retained_earning_statement(company_id: @company_id)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_find_all
|
14
|
+
stub_request(:get, /retainedEarningsStatement/)
|
15
|
+
.to_return(
|
16
|
+
status: 200,
|
17
|
+
body: {
|
18
|
+
'value': [
|
19
|
+
{
|
20
|
+
lineNumber: 20_000,
|
21
|
+
display: 'Net Income',
|
22
|
+
netChange: 77_770.94,
|
23
|
+
lineType: 'detail',
|
24
|
+
indentation: 0,
|
25
|
+
dateFilter: '2016-12-31'
|
26
|
+
}
|
27
|
+
]
|
28
|
+
}.to_json
|
29
|
+
)
|
30
|
+
|
31
|
+
response = @retained_earning_statement.find_all
|
32
|
+
assert_equal response.first[:line_number], 20_000
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_create
|
36
|
+
assert_raises BusinessCentral::NoSupportedMethod do
|
37
|
+
@retained_earning_statement.create({})
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_update
|
42
|
+
assert_raises BusinessCentral::NoSupportedMethod do
|
43
|
+
@retained_earning_statement.update('123', {})
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_delete
|
48
|
+
assert_raises BusinessCentral::NoSupportedMethod do
|
49
|
+
@retained_earning_statement.destroy('123')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
# rake test TEST=test/business_central/object/sales_credit_memo_line_test.rb
|
5
|
+
|
6
|
+
class BusinessCentral::Object::SalesCreditMemoLineTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
@company_id = '123456'
|
9
|
+
@client = BusinessCentral::Client.new
|
10
|
+
@sales_credit_memo_line = @client.sales_credit_memo_line(
|
11
|
+
company_id: @company_id,
|
12
|
+
parent: 'salesCreditMemos',
|
13
|
+
parent_id: '123'
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_find_all
|
18
|
+
stub_request(:get, %r{salesCreditMemos\(\d+\)\/salesCreditMemoLines})
|
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_credit_memo_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{salesCreditMemos\(\d+\)\/salesCreditMemoLines\(#{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_credit_memo_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{salesCreditMemos\(\d+\)\/salesCreditMemoLines\?\$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_credit_memo_line.where(test_filter)
|
68
|
+
assert_equal response.first[:sequence], '1011'
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_create
|
72
|
+
stub_request(:post, %r{salesCreditMemos\(\d+\)\/salesCreditMemoLines})
|
73
|
+
.to_return(
|
74
|
+
status: 200,
|
75
|
+
body: {
|
76
|
+
id: '678',
|
77
|
+
sequence: '1012'
|
78
|
+
}.to_json
|
79
|
+
)
|
80
|
+
|
81
|
+
response = @sales_credit_memo_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{salesCreditMemos\(\d+\)\/salesCreditMemoLines\(#{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{salesCreditMemos\(\d+\)\/salesCreditMemoLines\(#{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_credit_memo_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{salesCreditMemos\(\d+\)\/salesCreditMemoLines\(#{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{salesCreditMemos\(\d+\)\/salesCreditMemoLines\(#{test_id}\)})
|
130
|
+
.to_return(status: 204)
|
131
|
+
|
132
|
+
assert @sales_credit_memo_line.destroy(test_id)
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
# rake test TEST=test/business_central/object/sales_credit_memo_test.rb
|
5
|
+
|
6
|
+
class BusinessCentral::Object::SalesCreditMemoTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
@company_id = '123456'
|
9
|
+
@client = BusinessCentral::Client.new
|
10
|
+
@sales_credit_memo = @client.sales_credit_memo(company_id: @company_id)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_find_all
|
14
|
+
stub_request(:get, /salesCreditMemos/)
|
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_credit_memo.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, /salesCreditMemos\(#{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_credit_memo.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, /salesCreditMemos\?\$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_credit_memo.where(test_filter)
|
62
|
+
assert_equal response.first[:number], '1011'
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_create
|
66
|
+
stub_request(:post, /salesCreditMemos/)
|
67
|
+
.to_return(
|
68
|
+
status: 200,
|
69
|
+
body: {
|
70
|
+
id: '678',
|
71
|
+
number: '1012'
|
72
|
+
}.to_json
|
73
|
+
)
|
74
|
+
|
75
|
+
response = @sales_credit_memo.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, /salesCreditMemos\(#{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, /salesCreditMemos\(#{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_credit_memo.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, /salesCreditMemos\(#{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, /salesCreditMemos\(#{test_id}\)/)
|
122
|
+
.to_return(status: 204)
|
123
|
+
|
124
|
+
assert @sales_credit_memo.destroy(test_id)
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_line_navigation
|
128
|
+
stub_request(:get, %r{salesCreditMemos\(\d+\)\/salesCreditMemoLine})
|
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_credit_memo(company_id: @company_id, id: '123')
|
143
|
+
.sales_credit_memo_line.find_all
|
144
|
+
assert_equal response.first[:sequence], '1009'
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,164 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
# rake test TEST=test/business_central/object/sales_invoice_line_test.rb
|
5
|
+
|
6
|
+
class BusinessCentral::Object::SalesInvoiceLineTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
@company_id = '123456'
|
9
|
+
@client = BusinessCentral::Client.new
|
10
|
+
@sales_invoice_line = @client.sales_invoice_line(
|
11
|
+
company_id: @company_id,
|
12
|
+
parent_id: '123'
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_invalid_sales_invoice_line_parent
|
17
|
+
assert_raises(BusinessCentral::InvalidArgumentException) do
|
18
|
+
@client.sales_invoice_line(
|
19
|
+
company_id: @company_id,
|
20
|
+
parent: 'something that doesnt exist',
|
21
|
+
parent_id: '1'
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_find_all
|
27
|
+
stub_request(:get, %r{salesInvoices\(\d+\)\/salesInvoiceLines})
|
28
|
+
.to_return(
|
29
|
+
status: 200,
|
30
|
+
body: {
|
31
|
+
'value': [
|
32
|
+
{
|
33
|
+
id: 1,
|
34
|
+
documentId: 1,
|
35
|
+
sequence: 10_000,
|
36
|
+
itemId: 1,
|
37
|
+
description: 'salesInvoiceLine1'
|
38
|
+
}
|
39
|
+
]
|
40
|
+
}.to_json
|
41
|
+
)
|
42
|
+
|
43
|
+
response = @sales_invoice_line.find_all
|
44
|
+
assert_equal response.first[:description], 'salesInvoiceLine1'
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_find_by_id
|
48
|
+
test_id = '2'
|
49
|
+
stub_request(:get, %r{salesInvoices\(\d+\)\/salesInvoiceLines\(#{test_id}\)})
|
50
|
+
.to_return(
|
51
|
+
status: 200,
|
52
|
+
body: {
|
53
|
+
id: test_id,
|
54
|
+
documentId: 2,
|
55
|
+
sequence: 10_000,
|
56
|
+
itemId: 2,
|
57
|
+
description: 'salesInvoiceLine2'
|
58
|
+
}.to_json
|
59
|
+
)
|
60
|
+
|
61
|
+
response = @sales_invoice_line.find_by_id(test_id)
|
62
|
+
assert_equal response[:description], 'salesInvoiceLine2'
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_where
|
66
|
+
test_filter = "description eq 'salesInvoiceLine3'"
|
67
|
+
stub_request(:get, %r{salesInvoices\(\d+\)\/salesInvoiceLines\?\$filter=#{test_filter}})
|
68
|
+
.to_return(
|
69
|
+
status: 200,
|
70
|
+
body: {
|
71
|
+
'value': [
|
72
|
+
{
|
73
|
+
id: 3,
|
74
|
+
documentId: 3,
|
75
|
+
sequence: 10_000,
|
76
|
+
itemId: 3,
|
77
|
+
description: 'salesInvoiceLine3'
|
78
|
+
}
|
79
|
+
]
|
80
|
+
}.to_json
|
81
|
+
)
|
82
|
+
|
83
|
+
response = @sales_invoice_line.where(test_filter)
|
84
|
+
assert_equal response.first[:description], 'salesInvoiceLine3'
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_create
|
88
|
+
stub_request(:post, %r{salesInvoices\(\d+\)\/salesInvoiceLines})
|
89
|
+
.to_return(
|
90
|
+
status: 200,
|
91
|
+
body: {
|
92
|
+
id: 4,
|
93
|
+
documentId: 4,
|
94
|
+
sequence: 20_000,
|
95
|
+
itemId: 4,
|
96
|
+
description: 'salesInvoiceLine4'
|
97
|
+
}.to_json
|
98
|
+
)
|
99
|
+
|
100
|
+
response = @sales_invoice_line.create(
|
101
|
+
document_id: 4,
|
102
|
+
item_id: 4,
|
103
|
+
description: 'salesInvoiceLine4'
|
104
|
+
)
|
105
|
+
assert_equal response[:id], 4
|
106
|
+
assert_equal response[:description], 'salesInvoiceLine4'
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_update
|
110
|
+
test_id = '2'
|
111
|
+
stub_request(:get, %r{salesInvoices\(\d+\)\/salesInvoiceLines\(#{test_id}\)})
|
112
|
+
.to_return(
|
113
|
+
status: 200,
|
114
|
+
body: {
|
115
|
+
etag: '3333',
|
116
|
+
id: test_id,
|
117
|
+
documentId: 5,
|
118
|
+
sequence: 10_000,
|
119
|
+
itemId: 5,
|
120
|
+
description: 'salesInvoiceLine5'
|
121
|
+
}.to_json
|
122
|
+
)
|
123
|
+
|
124
|
+
stub_request(:patch, %r{salesInvoices\(\d+\)\/salesInvoiceLines\(#{test_id}\)})
|
125
|
+
.to_return(
|
126
|
+
status: 200,
|
127
|
+
body: {
|
128
|
+
etag: '4444',
|
129
|
+
id: test_id,
|
130
|
+
documentId: 5,
|
131
|
+
sequence: 10_000,
|
132
|
+
itemId: 5,
|
133
|
+
description: 'salesInvoiceLine6'
|
134
|
+
}.to_json
|
135
|
+
)
|
136
|
+
|
137
|
+
response = @sales_invoice_line.update(
|
138
|
+
test_id,
|
139
|
+
description: 'salesInvoiceLine6'
|
140
|
+
)
|
141
|
+
assert_equal response[:description], 'salesInvoiceLine6'
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_delete
|
145
|
+
test_id = '33333'
|
146
|
+
stub_request(:get, %r{salesInvoices\(\d+\)\/salesInvoiceLines\(#{test_id}\)})
|
147
|
+
.to_return(
|
148
|
+
status: 200,
|
149
|
+
body: {
|
150
|
+
etag: '5555',
|
151
|
+
id: test_id,
|
152
|
+
documentId: 6,
|
153
|
+
sequence: 10_000,
|
154
|
+
itemId: 6,
|
155
|
+
description: 'salesInvoiceLine6'
|
156
|
+
}.to_json
|
157
|
+
)
|
158
|
+
|
159
|
+
stub_request(:delete, %r{salesInvoices\(\d+\)\/salesInvoiceLines\(#{test_id}\)})
|
160
|
+
.to_return(status: 204)
|
161
|
+
|
162
|
+
assert @sales_invoice_line.destroy(test_id)
|
163
|
+
end
|
164
|
+
end
|