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,152 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
# rake test TEST=test/business_central/object/journal_line_test.rb
|
5
|
-
|
6
|
-
class BusinessCentral::Object::JournalLineTest < Minitest::Test
|
7
|
-
def setup
|
8
|
-
@company_id = '123456'
|
9
|
-
@client = BusinessCentral::Client.new
|
10
|
-
@journal_line = @client.journal_line(
|
11
|
-
company_id: @company_id,
|
12
|
-
parent: 'journals',
|
13
|
-
parent_id: '123'
|
14
|
-
)
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_invalid_journal_line_parent
|
18
|
-
assert_raises(BusinessCentral::InvalidArgumentException) do
|
19
|
-
@client.journal_line(
|
20
|
-
company_id: @company_id,
|
21
|
-
parent: 'something that doesnt exist',
|
22
|
-
parent_id: '1'
|
23
|
-
)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_find_all
|
28
|
-
stub_request(:get, %r{journals\(\d+\)\/journalLines})
|
29
|
-
.to_return(
|
30
|
-
status: 200,
|
31
|
-
body: {
|
32
|
-
'value': [
|
33
|
-
{
|
34
|
-
journalDisplayName: 'journal1',
|
35
|
-
lineNumber: 1000,
|
36
|
-
description: 'journalLine1'
|
37
|
-
}
|
38
|
-
]
|
39
|
-
}.to_json
|
40
|
-
)
|
41
|
-
|
42
|
-
response = @journal_line.find_all
|
43
|
-
assert_equal response.first[:description], 'journalLine1'
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_find_by_id
|
47
|
-
test_id = '2'
|
48
|
-
stub_request(:get, %r{journals\(\d+\)\/journalLines\(#{test_id}\)})
|
49
|
-
.to_return(
|
50
|
-
status: 200,
|
51
|
-
body: {
|
52
|
-
id: test_id,
|
53
|
-
journalDisplayName: 'journal1',
|
54
|
-
lineNumber: 2000,
|
55
|
-
description: 'journalLine2'
|
56
|
-
}.to_json
|
57
|
-
)
|
58
|
-
|
59
|
-
response = @journal_line.find_by_id(test_id)
|
60
|
-
assert_equal response[:description], 'journalLine2'
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_where
|
64
|
-
test_filter = "description eq 'journalLine3'"
|
65
|
-
stub_request(:get, %r{journals\(\d+\)\/journalLines\?\$filter=#{test_filter}})
|
66
|
-
.to_return(
|
67
|
-
status: 200,
|
68
|
-
body: {
|
69
|
-
'value': [
|
70
|
-
{
|
71
|
-
id: 3,
|
72
|
-
journalDisplayName: 'journal1',
|
73
|
-
lineNumber: 3000,
|
74
|
-
description: 'journalLine3'
|
75
|
-
}
|
76
|
-
]
|
77
|
-
}.to_json
|
78
|
-
)
|
79
|
-
|
80
|
-
response = @journal_line.where(test_filter)
|
81
|
-
assert_equal response.first[:description], 'journalLine3'
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_create
|
85
|
-
stub_request(:post, %r{journals\(\d+\)\/journalLines})
|
86
|
-
.to_return(
|
87
|
-
status: 200,
|
88
|
-
body: {
|
89
|
-
id: 4,
|
90
|
-
journalDisplayName: 'journal1',
|
91
|
-
lineNumber: 4000,
|
92
|
-
description: 'journalLine4'
|
93
|
-
}.to_json
|
94
|
-
)
|
95
|
-
|
96
|
-
response = @journal_line.create(
|
97
|
-
description: 'journalLine4'
|
98
|
-
)
|
99
|
-
assert_equal response[:id], 4
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_update
|
103
|
-
test_id = '2'
|
104
|
-
stub_request(:get, %r{journals\(\d+\)\/journalLines\(#{test_id}\)})
|
105
|
-
.to_return(
|
106
|
-
status: 200,
|
107
|
-
body: {
|
108
|
-
etag: '3333',
|
109
|
-
id: test_id,
|
110
|
-
journalDisplayName: 'journal1',
|
111
|
-
lineNumber: 4000,
|
112
|
-
description: 'journalLine4'
|
113
|
-
}.to_json
|
114
|
-
)
|
115
|
-
|
116
|
-
stub_request(:patch, %r{journals\(\d+\)\/journalLines\(#{test_id}\)})
|
117
|
-
.to_return(
|
118
|
-
status: 200,
|
119
|
-
body: {
|
120
|
-
etag: '4444',
|
121
|
-
id: test_id,
|
122
|
-
lineNumber: 4000,
|
123
|
-
description: 'journalLine5'
|
124
|
-
}.to_json
|
125
|
-
)
|
126
|
-
|
127
|
-
response = @journal_line.update(
|
128
|
-
test_id,
|
129
|
-
description: 'journalLine5'
|
130
|
-
)
|
131
|
-
assert_equal response[:description], 'journalLine5'
|
132
|
-
end
|
133
|
-
|
134
|
-
def test_delete
|
135
|
-
test_id = '33333'
|
136
|
-
stub_request(:get, %r{journals\(\d+\)\/journalLines\(#{test_id}\)})
|
137
|
-
.to_return(
|
138
|
-
status: 200,
|
139
|
-
body: {
|
140
|
-
etag: '5555',
|
141
|
-
id: test_id,
|
142
|
-
lineNumber: 5000,
|
143
|
-
description: 'journalLine5'
|
144
|
-
}.to_json
|
145
|
-
)
|
146
|
-
|
147
|
-
stub_request(:delete, %r{journals\(\d+\)\/journalLines\(#{test_id}\)})
|
148
|
-
.to_return(status: 204)
|
149
|
-
|
150
|
-
assert @journal_line.destroy(test_id)
|
151
|
-
end
|
152
|
-
end
|
@@ -1,144 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
# rake test TEST=test/business_central/object/journal_test.rb
|
5
|
-
|
6
|
-
class BusinessCentral::Object::JournalTest < Minitest::Test
|
7
|
-
def setup
|
8
|
-
@company_id = '123456'
|
9
|
-
@client = BusinessCentral::Client.new
|
10
|
-
@journal = @client.journal(company_id: @company_id)
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_find_all
|
14
|
-
stub_request(:get, /journals/)
|
15
|
-
.to_return(
|
16
|
-
status: 200,
|
17
|
-
body: {
|
18
|
-
'value': [
|
19
|
-
{
|
20
|
-
code: '123',
|
21
|
-
displayName: 'journal1'
|
22
|
-
}
|
23
|
-
]
|
24
|
-
}.to_json
|
25
|
-
)
|
26
|
-
|
27
|
-
response = @journal.find_all
|
28
|
-
assert_equal response.first[:display_name], 'journal1'
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_find_by_id
|
32
|
-
test_journal_id = '09876'
|
33
|
-
stub_request(:get, /journals\(#{test_journal_id}\)/)
|
34
|
-
.to_return(
|
35
|
-
status: 200,
|
36
|
-
body: {
|
37
|
-
code: '123',
|
38
|
-
displayName: 'journal1'
|
39
|
-
}.to_json
|
40
|
-
)
|
41
|
-
|
42
|
-
response = @journal.find_by_id(test_journal_id)
|
43
|
-
assert_equal response[:display_name], 'journal1'
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_where
|
47
|
-
test_filter = "displayName eq 'journal2'"
|
48
|
-
stub_request(:get, /journals\?\$filter=#{test_filter}/)
|
49
|
-
.to_return(
|
50
|
-
status: 200,
|
51
|
-
body: {
|
52
|
-
'value': [
|
53
|
-
{
|
54
|
-
code: '456',
|
55
|
-
displayName: 'journal2'
|
56
|
-
}
|
57
|
-
]
|
58
|
-
}.to_json
|
59
|
-
)
|
60
|
-
|
61
|
-
response = @journal.where(test_filter)
|
62
|
-
assert_equal response.first[:display_name], 'journal2'
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_create
|
66
|
-
stub_request(:post, /journals/)
|
67
|
-
.to_return(
|
68
|
-
status: 200,
|
69
|
-
body: {
|
70
|
-
code: '789',
|
71
|
-
displayName: 'journal3'
|
72
|
-
}.to_json
|
73
|
-
)
|
74
|
-
|
75
|
-
response = @journal.create(
|
76
|
-
code: '789',
|
77
|
-
display_name: 'journal3'
|
78
|
-
)
|
79
|
-
assert_equal response[:display_name], 'journal3'
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_update
|
83
|
-
test_journal_id = '011123'
|
84
|
-
stub_request(:get, /journals\(#{test_journal_id}\)/)
|
85
|
-
.to_return(
|
86
|
-
status: 200,
|
87
|
-
body: {
|
88
|
-
etag: '112',
|
89
|
-
displayName: 'journal4'
|
90
|
-
}.to_json
|
91
|
-
)
|
92
|
-
|
93
|
-
stub_request(:patch, /journals\(#{test_journal_id}\)/)
|
94
|
-
.to_return(
|
95
|
-
status: 200,
|
96
|
-
body: {
|
97
|
-
displayName: 'journal5'
|
98
|
-
}.to_json
|
99
|
-
)
|
100
|
-
|
101
|
-
response = @journal.update(
|
102
|
-
test_journal_id,
|
103
|
-
display_name: 'journal5'
|
104
|
-
)
|
105
|
-
assert_equal response[:display_name], 'journal5'
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_delete
|
109
|
-
test_journal_id = '0111245'
|
110
|
-
stub_request(:get, /journals\(#{test_journal_id}\)/)
|
111
|
-
.to_return(
|
112
|
-
status: 200,
|
113
|
-
body: {
|
114
|
-
etag: '113',
|
115
|
-
displayName: 'journal6'
|
116
|
-
}.to_json
|
117
|
-
)
|
118
|
-
|
119
|
-
stub_request(:delete, /journals\(#{test_journal_id}\)/)
|
120
|
-
.to_return(status: 204)
|
121
|
-
|
122
|
-
assert @journal.destroy(test_journal_id)
|
123
|
-
end
|
124
|
-
|
125
|
-
def test_line_navigation
|
126
|
-
stub_request(:get, %r{journals\(\d+\)\/journalLines})
|
127
|
-
.to_return(
|
128
|
-
status: 200,
|
129
|
-
body: {
|
130
|
-
'value': [
|
131
|
-
{
|
132
|
-
journalDisplayName: 'journal1',
|
133
|
-
lineNumber: 1000,
|
134
|
-
description: 'journalLine1'
|
135
|
-
}
|
136
|
-
]
|
137
|
-
}.to_json
|
138
|
-
)
|
139
|
-
|
140
|
-
response = @client.journal(company_id: @company_id, id: '123')
|
141
|
-
.journal_line.find_all
|
142
|
-
assert_equal response.first[:line_number], 1000
|
143
|
-
end
|
144
|
-
end
|
@@ -1,134 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
# rake test TEST=test/business_central/object/payment_method_test.rb
|
5
|
-
|
6
|
-
class BusinessCentral::Object::PaymentMethodTest < Minitest::Test
|
7
|
-
def setup
|
8
|
-
@company_id = '123456'
|
9
|
-
@client = BusinessCentral::Client.new
|
10
|
-
@payment_method = @client.payment_method(company_id: @company_id)
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_find_all
|
14
|
-
stub_request(:get, /paymentMethods/)
|
15
|
-
.to_return(
|
16
|
-
status: 200,
|
17
|
-
body: {
|
18
|
-
'value': [
|
19
|
-
{
|
20
|
-
id: 1,
|
21
|
-
code: 'PM1',
|
22
|
-
displayName: 'paymentMethod1'
|
23
|
-
}
|
24
|
-
]
|
25
|
-
}.to_json
|
26
|
-
)
|
27
|
-
|
28
|
-
response = @payment_method.find_all
|
29
|
-
assert_equal response.first[:display_name], 'paymentMethod1'
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_find_by_id
|
33
|
-
test_id = '09876'
|
34
|
-
stub_request(:get, /paymentMethods\(#{test_id}\)/)
|
35
|
-
.to_return(
|
36
|
-
status: 200,
|
37
|
-
body: {
|
38
|
-
id: test_id,
|
39
|
-
code: 'PM2',
|
40
|
-
displayName: 'paymentMethod2'
|
41
|
-
}.to_json
|
42
|
-
)
|
43
|
-
|
44
|
-
response = @payment_method.find_by_id(test_id)
|
45
|
-
assert_equal response[:display_name], 'paymentMethod2'
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_where
|
49
|
-
test_filter = "displayName eq 'paymentMethod3'"
|
50
|
-
stub_request(:get, /paymentMethods\?\$filter=#{test_filter}/)
|
51
|
-
.to_return(
|
52
|
-
status: 200,
|
53
|
-
body: {
|
54
|
-
'value': [
|
55
|
-
{
|
56
|
-
id: 3,
|
57
|
-
code: 'PM3',
|
58
|
-
displayName: 'paymentMethod3'
|
59
|
-
}
|
60
|
-
]
|
61
|
-
}.to_json
|
62
|
-
)
|
63
|
-
|
64
|
-
response = @payment_method.where(test_filter)
|
65
|
-
assert_equal response.first[:display_name], 'paymentMethod3'
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_create
|
69
|
-
stub_request(:post, /paymentMethods/)
|
70
|
-
.to_return(
|
71
|
-
status: 200,
|
72
|
-
body: {
|
73
|
-
id: 4,
|
74
|
-
code: 'PM4',
|
75
|
-
displayName: 'paymentMethod4'
|
76
|
-
}.to_json
|
77
|
-
)
|
78
|
-
|
79
|
-
response = @payment_method.create(
|
80
|
-
code: 'PM4',
|
81
|
-
display_name: 'paymentMethod4'
|
82
|
-
)
|
83
|
-
assert_equal response[:display_name], 'paymentMethod4'
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_update
|
87
|
-
test_id = '011123'
|
88
|
-
stub_request(:get, /paymentMethods\(#{test_id}\)/)
|
89
|
-
.to_return(
|
90
|
-
status: 200,
|
91
|
-
body: {
|
92
|
-
etag: '112',
|
93
|
-
id: test_id,
|
94
|
-
code: 'PM5',
|
95
|
-
displayName: 'paymentMethod5'
|
96
|
-
}.to_json
|
97
|
-
)
|
98
|
-
|
99
|
-
stub_request(:patch, /paymentMethods\(#{test_id}\)/)
|
100
|
-
.to_return(
|
101
|
-
status: 200,
|
102
|
-
body: {
|
103
|
-
id: test_id,
|
104
|
-
code: 'PM6',
|
105
|
-
displayName: 'paymentMethod6'
|
106
|
-
}.to_json
|
107
|
-
)
|
108
|
-
|
109
|
-
response = @payment_method.update(
|
110
|
-
test_id,
|
111
|
-
code: 'PM6',
|
112
|
-
display_name: 'paymentMethod6'
|
113
|
-
)
|
114
|
-
assert_equal response[:display_name], 'paymentMethod6'
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_delete
|
118
|
-
test_id = '0111245'
|
119
|
-
stub_request(:get, /paymentMethods\(#{test_id}\)/)
|
120
|
-
.to_return(
|
121
|
-
status: 200,
|
122
|
-
body: {
|
123
|
-
etag: '113',
|
124
|
-
code: 'PM7',
|
125
|
-
displayName: 'paymentMethod7'
|
126
|
-
}.to_json
|
127
|
-
)
|
128
|
-
|
129
|
-
stub_request(:delete, /paymentMethods\(#{test_id}\)/)
|
130
|
-
.to_return(status: 204)
|
131
|
-
|
132
|
-
assert @payment_method.destroy(test_id)
|
133
|
-
end
|
134
|
-
end
|
@@ -1,134 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
# rake test TEST=test/business_central/object/payment_term_test.rb
|
5
|
-
|
6
|
-
class BusinessCentral::Object::PaymentTermTest < Minitest::Test
|
7
|
-
def setup
|
8
|
-
@company_id = '123456'
|
9
|
-
@client = BusinessCentral::Client.new
|
10
|
-
@payment_term = @client.payment_term(company_id: @company_id)
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_find_all
|
14
|
-
stub_request(:get, /paymentTerms/)
|
15
|
-
.to_return(
|
16
|
-
status: 200,
|
17
|
-
body: {
|
18
|
-
'value': [
|
19
|
-
{
|
20
|
-
id: 1,
|
21
|
-
code: 'PM1',
|
22
|
-
displayName: 'paymentTerm1'
|
23
|
-
}
|
24
|
-
]
|
25
|
-
}.to_json
|
26
|
-
)
|
27
|
-
|
28
|
-
response = @payment_term.find_all
|
29
|
-
assert_equal response.first[:display_name], 'paymentTerm1'
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_find_by_id
|
33
|
-
test_id = '09876'
|
34
|
-
stub_request(:get, /paymentTerms\(#{test_id}\)/)
|
35
|
-
.to_return(
|
36
|
-
status: 200,
|
37
|
-
body: {
|
38
|
-
id: test_id,
|
39
|
-
code: 'PM2',
|
40
|
-
displayName: 'paymentTerm2'
|
41
|
-
}.to_json
|
42
|
-
)
|
43
|
-
|
44
|
-
response = @payment_term.find_by_id(test_id)
|
45
|
-
assert_equal response[:display_name], 'paymentTerm2'
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_where
|
49
|
-
test_filter = "displayName eq 'paymentTerm3'"
|
50
|
-
stub_request(:get, /paymentTerms\?\$filter=#{test_filter}/)
|
51
|
-
.to_return(
|
52
|
-
status: 200,
|
53
|
-
body: {
|
54
|
-
'value': [
|
55
|
-
{
|
56
|
-
id: 3,
|
57
|
-
code: 'PM3',
|
58
|
-
displayName: 'paymentTerm3'
|
59
|
-
}
|
60
|
-
]
|
61
|
-
}.to_json
|
62
|
-
)
|
63
|
-
|
64
|
-
response = @payment_term.where(test_filter)
|
65
|
-
assert_equal response.first[:display_name], 'paymentTerm3'
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_create
|
69
|
-
stub_request(:post, /paymentTerms/)
|
70
|
-
.to_return(
|
71
|
-
status: 200,
|
72
|
-
body: {
|
73
|
-
id: 4,
|
74
|
-
code: 'PM4',
|
75
|
-
displayName: 'paymentTerm4'
|
76
|
-
}.to_json
|
77
|
-
)
|
78
|
-
|
79
|
-
response = @payment_term.create(
|
80
|
-
code: 'PM4',
|
81
|
-
display_name: 'paymentTerm4'
|
82
|
-
)
|
83
|
-
assert_equal response[:display_name], 'paymentTerm4'
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_update
|
87
|
-
test_id = '011123'
|
88
|
-
stub_request(:get, /paymentTerms\(#{test_id}\)/)
|
89
|
-
.to_return(
|
90
|
-
status: 200,
|
91
|
-
body: {
|
92
|
-
etag: '112',
|
93
|
-
id: test_id,
|
94
|
-
code: 'PM5',
|
95
|
-
displayName: 'paymentTerm5'
|
96
|
-
}.to_json
|
97
|
-
)
|
98
|
-
|
99
|
-
stub_request(:patch, /paymentTerms\(#{test_id}\)/)
|
100
|
-
.to_return(
|
101
|
-
status: 200,
|
102
|
-
body: {
|
103
|
-
id: test_id,
|
104
|
-
code: 'PM6',
|
105
|
-
displayName: 'paymentTerm6'
|
106
|
-
}.to_json
|
107
|
-
)
|
108
|
-
|
109
|
-
response = @payment_term.update(
|
110
|
-
test_id,
|
111
|
-
code: 'PM6',
|
112
|
-
display_name: 'paymentTerm6'
|
113
|
-
)
|
114
|
-
assert_equal response[:display_name], 'paymentTerm6'
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_delete
|
118
|
-
test_id = '0111245'
|
119
|
-
stub_request(:get, /paymentTerms\(#{test_id}\)/)
|
120
|
-
.to_return(
|
121
|
-
status: 200,
|
122
|
-
body: {
|
123
|
-
etag: '113',
|
124
|
-
code: 'PM7',
|
125
|
-
displayName: 'paymentTerm6'
|
126
|
-
}.to_json
|
127
|
-
)
|
128
|
-
|
129
|
-
stub_request(:delete, /paymentTerms\(#{test_id}\)/)
|
130
|
-
.to_return(status: 204)
|
131
|
-
|
132
|
-
assert @payment_term.destroy(test_id)
|
133
|
-
end
|
134
|
-
end
|
@@ -1,123 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
# rake test TEST=test/business_central/object/purchase_invoice_line_test.rb
|
5
|
-
|
6
|
-
class BusinessCentral::Object::PurchaseInvoiceLineTest < Minitest::Test
|
7
|
-
def setup
|
8
|
-
@company_id = '123456'
|
9
|
-
@purchase_invoice_id = '789456'
|
10
|
-
@client = BusinessCentral::Client.new
|
11
|
-
@purchase_invoice_line = @client.purchase_invoice_line(
|
12
|
-
company_id: @company_id,
|
13
|
-
purchase_invoice_id: @purchase_invoice_id
|
14
|
-
)
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_find_all
|
18
|
-
stub_request(:get, /purchaseInvoiceLines/)
|
19
|
-
.to_return(
|
20
|
-
status: 200,
|
21
|
-
body: {
|
22
|
-
'value': [
|
23
|
-
{
|
24
|
-
description: 'po line 1'
|
25
|
-
}
|
26
|
-
]
|
27
|
-
}.to_json
|
28
|
-
)
|
29
|
-
|
30
|
-
response = @purchase_invoice_line.find_all
|
31
|
-
assert_equal response.first[:description], 'po line 1'
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_find_by_id
|
35
|
-
test_purchase_invoice_line_id = '09876'
|
36
|
-
stub_request(:get, /purchaseInvoiceLines\(#{test_purchase_invoice_line_id}\)/)
|
37
|
-
.to_return(
|
38
|
-
status: 200,
|
39
|
-
body: {
|
40
|
-
description: 'po line 2'
|
41
|
-
}.to_json
|
42
|
-
)
|
43
|
-
|
44
|
-
response = @purchase_invoice_line.find_by_id(test_purchase_invoice_line_id)
|
45
|
-
assert_equal response[:description], 'po line 2'
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_where
|
49
|
-
test_filter = "description eq 'po line 3'"
|
50
|
-
stub_request(:get, /purchaseInvoiceLines\?\$filter=#{test_filter}/)
|
51
|
-
.to_return(
|
52
|
-
status: 200,
|
53
|
-
body: {
|
54
|
-
'value': [
|
55
|
-
{
|
56
|
-
description: 'po line 3'
|
57
|
-
}
|
58
|
-
]
|
59
|
-
}.to_json
|
60
|
-
)
|
61
|
-
|
62
|
-
response = @purchase_invoice_line.where(test_filter)
|
63
|
-
assert_equal response.first[:description], 'po line 3'
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_create
|
67
|
-
stub_request(:post, /purchaseInvoiceLines/)
|
68
|
-
.to_return(
|
69
|
-
status: 200,
|
70
|
-
body: {
|
71
|
-
description: 'po line 4'
|
72
|
-
}.to_json
|
73
|
-
)
|
74
|
-
|
75
|
-
response = @purchase_invoice_line.create(
|
76
|
-
description: 'po line 4'
|
77
|
-
)
|
78
|
-
assert_equal response[:description], 'po line 4'
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_update
|
82
|
-
test_purchase_invoice_line_id = '011123'
|
83
|
-
stub_request(:get, /purchaseInvoiceLines\(#{test_purchase_invoice_line_id}\)/)
|
84
|
-
.to_return(
|
85
|
-
status: 200,
|
86
|
-
body: {
|
87
|
-
etag: '112',
|
88
|
-
description: 'po line 5'
|
89
|
-
}.to_json
|
90
|
-
)
|
91
|
-
|
92
|
-
stub_request(:patch, /purchaseInvoiceLines\(#{test_purchase_invoice_line_id}\)/)
|
93
|
-
.to_return(
|
94
|
-
status: 200,
|
95
|
-
body: {
|
96
|
-
description: 'po line 6'
|
97
|
-
}.to_json
|
98
|
-
)
|
99
|
-
|
100
|
-
response = @purchase_invoice_line.update(
|
101
|
-
test_purchase_invoice_line_id,
|
102
|
-
description: 'po line 6'
|
103
|
-
)
|
104
|
-
assert_equal response[:description], 'po line 6'
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_delete
|
108
|
-
test_purchase_invoice_line_id = '0111245'
|
109
|
-
stub_request(:get, /purchaseInvoiceLines\(#{test_purchase_invoice_line_id}\)/)
|
110
|
-
.to_return(
|
111
|
-
status: 200,
|
112
|
-
body: {
|
113
|
-
etag: '113',
|
114
|
-
description: 'po line 6'
|
115
|
-
}.to_json
|
116
|
-
)
|
117
|
-
|
118
|
-
stub_request(:delete, /purchaseInvoiceLines\(#{test_purchase_invoice_line_id}\)/)
|
119
|
-
.to_return(status: 204)
|
120
|
-
|
121
|
-
assert @purchase_invoice_line.destroy(test_purchase_invoice_line_id)
|
122
|
-
end
|
123
|
-
end
|