business-central 1.0.0 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
# rake test TEST=test/business_central/object/aged_account_receivable_test.rb
|
5
|
+
|
6
|
+
class BusinessCentral::Object::AgedAccountReceivableTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
@company_id = '123456'
|
9
|
+
@client = BusinessCentral::Client.new
|
10
|
+
@aged_account_receivable = @client.aged_account_receivable(company_id: @company_id)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_find_all
|
14
|
+
stub_request(:get, /agedAccountsReceivable/)
|
15
|
+
.to_return(
|
16
|
+
status: 200,
|
17
|
+
body: {
|
18
|
+
'value': [
|
19
|
+
{
|
20
|
+
name: 'customer1'
|
21
|
+
}
|
22
|
+
]
|
23
|
+
}.to_json
|
24
|
+
)
|
25
|
+
|
26
|
+
response = @aged_account_receivable.find_all
|
27
|
+
assert_equal response.first[:name], 'customer1'
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_find_by_id
|
31
|
+
test_id = '123'
|
32
|
+
stub_request(:get, /agedAccountsReceivable\(#{test_id}\)/)
|
33
|
+
.to_return(
|
34
|
+
status: 200,
|
35
|
+
body: {
|
36
|
+
name: 'customer2'
|
37
|
+
}.to_json
|
38
|
+
)
|
39
|
+
|
40
|
+
response = @aged_account_receivable.find_by_id(test_id)
|
41
|
+
assert_equal response[:name], 'customer2'
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_create
|
45
|
+
assert_raises BusinessCentral::NoSupportedMethod do
|
46
|
+
@aged_account_receivable.create({})
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_update
|
51
|
+
assert_raises BusinessCentral::NoSupportedMethod do
|
52
|
+
@aged_account_receivable.update('123', {})
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_delete
|
57
|
+
assert_raises BusinessCentral::NoSupportedMethod do
|
58
|
+
@aged_account_receivable.destroy('123')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
# rake test TEST=test/business_central/object/attachment_test.rb
|
5
|
+
|
6
|
+
class BusinessCentral::Object::AttachmentTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
@company_id = '123456'
|
9
|
+
@client = BusinessCentral::Client.new
|
10
|
+
@attachment = @client.attachment(company_id: @company_id)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_find_all
|
14
|
+
stub_request(:get, /attachments/)
|
15
|
+
.to_return(
|
16
|
+
status: 200,
|
17
|
+
body: {
|
18
|
+
'value': [
|
19
|
+
{
|
20
|
+
id: '111',
|
21
|
+
fileName: 'attachment1.pdf'
|
22
|
+
}
|
23
|
+
]
|
24
|
+
}.to_json
|
25
|
+
)
|
26
|
+
|
27
|
+
response = @attachment.find_all
|
28
|
+
assert_equal response.first[:file_name], 'attachment1.pdf'
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_find_by_id
|
32
|
+
test_id = '09876'
|
33
|
+
stub_request(:get, /attachments\(#{test_id}\)/)
|
34
|
+
.to_return(
|
35
|
+
status: 200,
|
36
|
+
body: {
|
37
|
+
id: '222',
|
38
|
+
fileName: 'attachment2.jpg'
|
39
|
+
}.to_json
|
40
|
+
)
|
41
|
+
|
42
|
+
response = @attachment.find_by_id(test_id)
|
43
|
+
assert_equal response[:file_name], 'attachment2.jpg'
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_where
|
47
|
+
test_filter = "fileName eq 'attachment3.png'"
|
48
|
+
stub_request(:get, /attachments\?\$filter=#{test_filter}/)
|
49
|
+
.to_return(
|
50
|
+
status: 200,
|
51
|
+
body: {
|
52
|
+
'value': [
|
53
|
+
{
|
54
|
+
id: '333',
|
55
|
+
fileName: 'attachment3.png'
|
56
|
+
}
|
57
|
+
]
|
58
|
+
}.to_json
|
59
|
+
)
|
60
|
+
|
61
|
+
response = @attachment.where(test_filter)
|
62
|
+
assert_equal response.first[:file_name], 'attachment3.png'
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_create
|
66
|
+
stub_request(:post, /attachments/)
|
67
|
+
.to_return(
|
68
|
+
status: 200,
|
69
|
+
body: {
|
70
|
+
fileName: 'attachment4.gif'
|
71
|
+
}.to_json
|
72
|
+
)
|
73
|
+
|
74
|
+
response = @attachment.create(
|
75
|
+
file_name: 'attachment4.gif'
|
76
|
+
)
|
77
|
+
assert_equal response[:file_name], 'attachment4.gif'
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_update
|
81
|
+
test_parent_id = '011123'
|
82
|
+
test_attachment_id = '11123'
|
83
|
+
stub_request(:get, /attachments\(parentId=#{test_parent_id},id=#{test_attachment_id}\)/)
|
84
|
+
.to_return(
|
85
|
+
status: 200,
|
86
|
+
body: {
|
87
|
+
etag: '112',
|
88
|
+
fileName: 'attachment5.pdf'
|
89
|
+
}.to_json
|
90
|
+
)
|
91
|
+
|
92
|
+
stub_request(:patch, /attachments\(parentId=#{test_parent_id},id=#{test_attachment_id}\)/)
|
93
|
+
.to_return(
|
94
|
+
status: 200,
|
95
|
+
body: {
|
96
|
+
fileName: 'attachment6.pdf'
|
97
|
+
}.to_json
|
98
|
+
)
|
99
|
+
|
100
|
+
response = @attachment.update(
|
101
|
+
parent_id: test_parent_id,
|
102
|
+
attachment_id: test_attachment_id,
|
103
|
+
file_name: 'attachment6.pdf'
|
104
|
+
)
|
105
|
+
assert_equal response[:file_name], 'attachment6.pdf'
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_delete
|
109
|
+
test_parent_id = '011124'
|
110
|
+
test_attachment_id = '11124'
|
111
|
+
|
112
|
+
stub_request(:delete, /attachments\(#{test_parent_id},#{test_attachment_id}\)/)
|
113
|
+
.to_return(status: 204)
|
114
|
+
|
115
|
+
assert @attachment.destroy(parent_id: test_parent_id, attachment_id: test_attachment_id)
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
# rake test TEST=test/business_central/object/balance_sheet_test.rb
|
5
|
+
|
6
|
+
class BusinessCentral::Object::BalanceSheetTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
@company_id = '123456'
|
9
|
+
@client = BusinessCentral::Client.new
|
10
|
+
@balance_sheet = @client.balance_sheet(company_id: @company_id)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_find_all
|
14
|
+
stub_request(:get, /balanceSheet/)
|
15
|
+
.to_return(
|
16
|
+
status: 200,
|
17
|
+
body: {
|
18
|
+
'value': [
|
19
|
+
{
|
20
|
+
display: 'balance item 1'
|
21
|
+
}
|
22
|
+
]
|
23
|
+
}.to_json
|
24
|
+
)
|
25
|
+
|
26
|
+
response = @balance_sheet.find_all
|
27
|
+
assert_equal response.first[:display], 'balance item 1'
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_find_by_id
|
31
|
+
test_id = '123'
|
32
|
+
stub_request(:get, /balanceSheet\(#{test_id}\)/)
|
33
|
+
.to_return(
|
34
|
+
status: 200,
|
35
|
+
body: {
|
36
|
+
display: 'balance item 2'
|
37
|
+
}.to_json
|
38
|
+
)
|
39
|
+
|
40
|
+
response = @balance_sheet.find_by_id(test_id)
|
41
|
+
assert_equal response[:display], 'balance item 2'
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_create
|
45
|
+
assert_raises BusinessCentral::NoSupportedMethod do
|
46
|
+
@balance_sheet.create({})
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_update
|
51
|
+
assert_raises BusinessCentral::NoSupportedMethod do
|
52
|
+
@balance_sheet.update('123', {})
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_delete
|
57
|
+
assert_raises BusinessCentral::NoSupportedMethod do
|
58
|
+
@balance_sheet.destroy('123')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
# rake test TEST=test/business_central/object/base_test.rb
|
5
|
+
|
6
|
+
class BusinessCentral::Object::BaseTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
@company_id = '123456'
|
9
|
+
@client = BusinessCentral::Client.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_no_method_supported_for_find_all
|
13
|
+
base = BusinessCentral::Object::Base.new(@client, {})
|
14
|
+
set_object_method(base, [])
|
15
|
+
assert_raises(BusinessCentral::NoSupportedMethod) do
|
16
|
+
base.find_all
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_no_method_supported_for_find_by_id
|
21
|
+
base = BusinessCentral::Object::Base.new(@client, {})
|
22
|
+
set_object_method(base, [])
|
23
|
+
assert_raises(BusinessCentral::NoSupportedMethod) do
|
24
|
+
base.find_by_id('123')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_no_method_supported_for_where_query
|
29
|
+
base = BusinessCentral::Object::Base.new(@client, {})
|
30
|
+
set_object_method(base, [])
|
31
|
+
assert_raises(BusinessCentral::NoSupportedMethod) do
|
32
|
+
base.where("displayName eq '123'")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def set_object_method(base, value)
|
39
|
+
base.class.const_set('OBJECT_METHODS', value) if !base.class.const_defined?('OBJECT_METHODS')
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
# rake test TEST=test/business_central/object/cash_flow_statement_test.rb
|
5
|
+
|
6
|
+
class BusinessCentral::Object::CashFlowStatementTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
@company_id = '123456'
|
9
|
+
@client = BusinessCentral::Client.new
|
10
|
+
@cash_flow_statement = @client.cash_flow_statement(company_id: @company_id)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_find_all
|
14
|
+
stub_request(:get, /cashFlowStatement/)
|
15
|
+
.to_return(
|
16
|
+
status: 200,
|
17
|
+
body: {
|
18
|
+
'value': [
|
19
|
+
{
|
20
|
+
display: 'assets 1'
|
21
|
+
}
|
22
|
+
]
|
23
|
+
}.to_json
|
24
|
+
)
|
25
|
+
|
26
|
+
response = @cash_flow_statement.find_all
|
27
|
+
assert_equal response.first[:display], 'assets 1'
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_find_by_id
|
31
|
+
test_id = '123'
|
32
|
+
stub_request(:get, /cashFlowStatement\(#{test_id}\)/)
|
33
|
+
.to_return(
|
34
|
+
status: 200,
|
35
|
+
body: {
|
36
|
+
display: 'assets 2'
|
37
|
+
}.to_json
|
38
|
+
)
|
39
|
+
|
40
|
+
response = @cash_flow_statement.find_by_id(test_id)
|
41
|
+
assert_equal response[:display], 'assets 2'
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_create
|
45
|
+
assert_raises BusinessCentral::NoSupportedMethod do
|
46
|
+
@cash_flow_statement.create({})
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_update
|
51
|
+
assert_raises BusinessCentral::NoSupportedMethod do
|
52
|
+
@cash_flow_statement.update('123', {})
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_delete
|
57
|
+
assert_raises BusinessCentral::NoSupportedMethod do
|
58
|
+
@cash_flow_statement.destroy('123')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
# rake test TEST=test/business_central/object/company_information_test.rb
|
5
|
+
|
6
|
+
class BusinessCentral::Object::CompanyInformationTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
@company_id = '123456'
|
9
|
+
@client = BusinessCentral::Client.new
|
10
|
+
@company_information = @client.company_information(company_id: @company_id)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_find_all
|
14
|
+
stub_request(:get, /companyInformation/)
|
15
|
+
.to_return(
|
16
|
+
status: 200,
|
17
|
+
body: {
|
18
|
+
'value': [
|
19
|
+
{
|
20
|
+
displayName: 'business1'
|
21
|
+
}
|
22
|
+
]
|
23
|
+
}.to_json
|
24
|
+
)
|
25
|
+
|
26
|
+
response = @company_information.find_all
|
27
|
+
assert_equal response.first[:display_name], 'business1'
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_find_by_id
|
31
|
+
test_company_id = '123'
|
32
|
+
stub_request(:get, /companyInformation\(#{test_company_id}\)/)
|
33
|
+
.to_return(
|
34
|
+
status: 200,
|
35
|
+
body: {
|
36
|
+
displayName: 'business2'
|
37
|
+
}.to_json
|
38
|
+
)
|
39
|
+
|
40
|
+
response = @company_information.find_by_id(test_company_id)
|
41
|
+
assert_equal response[:display_name], 'business2'
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_create
|
45
|
+
assert_raises BusinessCentral::NoSupportedMethod do
|
46
|
+
@company_information.create({})
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_update
|
51
|
+
test_company_id = '123'
|
52
|
+
stub_request(:get, /companyInformation\(#{test_company_id}\)/)
|
53
|
+
.to_return(
|
54
|
+
status: 200,
|
55
|
+
body: {
|
56
|
+
etag: '112',
|
57
|
+
displayName: 'business3'
|
58
|
+
}.to_json
|
59
|
+
)
|
60
|
+
|
61
|
+
stub_request(:patch, /companyInformation\(#{test_company_id}\)/)
|
62
|
+
.to_return(
|
63
|
+
status: 200,
|
64
|
+
body: {
|
65
|
+
displayName: 'business4'
|
66
|
+
}.to_json
|
67
|
+
)
|
68
|
+
|
69
|
+
response = @company_information.update(
|
70
|
+
test_company_id,
|
71
|
+
display_name: 'business4'
|
72
|
+
)
|
73
|
+
assert_equal response[:display_name], 'business4'
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_delete
|
77
|
+
assert_raises BusinessCentral::NoSupportedMethod do
|
78
|
+
@company_information.destroy('123')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -1,22 +1,18 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
2
4
|
# rake test TEST=test/business_central/object/company_test.rb
|
3
5
|
|
4
6
|
class BusinessCentral::Object::CompanyTest < Minitest::Test
|
5
7
|
def setup
|
6
8
|
@client = BusinessCentral::Client.new
|
7
|
-
@client.authorize_from_token(
|
8
|
-
token: '123',
|
9
|
-
refresh_token: '456',
|
10
|
-
expires_at: Time.now + 3600,
|
11
|
-
expires_in: 3600
|
12
|
-
)
|
13
9
|
@company = @client.company
|
14
10
|
end
|
15
11
|
|
16
12
|
def test_find_all
|
17
13
|
stub_request(:get, /companies/)
|
18
14
|
.to_return(
|
19
|
-
status: 200,
|
15
|
+
status: 200,
|
20
16
|
body: {
|
21
17
|
'value': [
|
22
18
|
{
|
@@ -26,7 +22,6 @@ class BusinessCentral::Object::CompanyTest < Minitest::Test
|
|
26
22
|
}.to_json
|
27
23
|
)
|
28
24
|
|
29
|
-
|
30
25
|
response = @company.find_all
|
31
26
|
assert_equal response.first[:display_name], 'business1'
|
32
27
|
end
|
@@ -35,7 +30,7 @@ class BusinessCentral::Object::CompanyTest < Minitest::Test
|
|
35
30
|
test_company_id = '123'
|
36
31
|
stub_request(:get, /companies\(#{test_company_id}\)/)
|
37
32
|
.to_return(
|
38
|
-
status: 200,
|
33
|
+
status: 200,
|
39
34
|
body: {
|
40
35
|
displayName: 'business2'
|
41
36
|
}.to_json
|
@@ -44,4 +39,22 @@ class BusinessCentral::Object::CompanyTest < Minitest::Test
|
|
44
39
|
response = @company.find_by_id(test_company_id)
|
45
40
|
assert_equal response[:display_name], 'business2'
|
46
41
|
end
|
47
|
-
|
42
|
+
|
43
|
+
def test_create
|
44
|
+
assert_raises BusinessCentral::NoSupportedMethod do
|
45
|
+
@company.create({})
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_update
|
50
|
+
assert_raises BusinessCentral::NoSupportedMethod do
|
51
|
+
@company.update('123', {})
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_delete
|
56
|
+
assert_raises BusinessCentral::NoSupportedMethod do
|
57
|
+
@company.destroy('123')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|