business-central 1.0.1 → 1.0.6
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 +47 -2
- data/lib/business_central/client.rb +82 -39
- data/lib/business_central/exceptions.rb +30 -10
- data/lib/business_central/object/account.rb +4 -12
- data/lib/business_central/object/aged_account_payable.rb +4 -12
- data/lib/business_central/object/aged_account_receivable.rb +4 -12
- data/lib/business_central/object/argument_helper.rb +22 -0
- data/lib/business_central/object/attachment.rb +30 -0
- data/lib/business_central/object/balance_sheet.rb +4 -12
- data/lib/business_central/object/base.rb +100 -49
- data/lib/business_central/object/cash_flow_statement.rb +4 -12
- data/lib/business_central/object/company.rb +9 -2
- data/lib/business_central/object/company_information.rb +7 -15
- 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 +31 -23
- data/lib/business_central/object/retained_earning_statement.rb +13 -0
- data/lib/business_central/object/sales_credit_memo.rb +20 -0
- data/lib/business_central/object/sales_credit_memo_line.rb +30 -0
- data/lib/business_central/object/sales_invoice.rb +62 -0
- data/lib/business_central/object/sales_invoice_line.rb +30 -0
- data/lib/business_central/object/sales_order.rb +20 -0
- data/lib/business_central/object/sales_order_line.rb +30 -0
- data/lib/business_central/object/sales_quote.rb +20 -0
- data/lib/business_central/object/sales_quote_line.rb +30 -0
- data/lib/business_central/object/shipment_method.rb +16 -0
- data/lib/business_central/object/subscription.rb +16 -0
- data/lib/business_central/object/tax_area.rb +16 -0
- data/lib/business_central/object/tax_group.rb +16 -0
- data/lib/business_central/object/time_registration_entry.rb +16 -0
- data/lib/business_central/object/trial_balance.rb +13 -0
- data/lib/business_central/object/units_of_measure.rb +16 -0
- data/lib/business_central/object/url_builder.rb +59 -0
- data/lib/business_central/object/url_helper.rb +44 -0
- data/lib/business_central/object/validation.rb +10 -7
- data/lib/business_central/object/vendor.rb +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 +6 -5
- data/test/business_central/object/aged_account_payable_test.rb +6 -5
- data/test/business_central/object/aged_account_receivable_test.rb +6 -5
- data/test/business_central/object/attachment_test.rb +117 -0
- data/test/business_central/object/balance_sheet_test.rb +6 -5
- data/test/business_central/object/base_test.rb +41 -0
- data/test/business_central/object/cash_flow_statement_test.rb +6 -5
- data/test/business_central/object/company_information_test.rb +9 -10
- data/test/business_central/object/company_test.rb +6 -5
- data/test/business_central/object/country_region_test.rb +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 -17
- data/test/business_central/object/journal_line_test.rb +152 -0
- data/test/business_central/object/journal_test.rb +144 -0
- data/test/business_central/object/payment_method_test.rb +134 -0
- data/test/business_central/object/payment_term_test.rb +134 -0
- data/test/business_central/object/picture_test.rb +74 -0
- data/test/business_central/object/purchase_invoice_line_test.rb +15 -15
- data/test/business_central/object/purchase_invoice_test.rb +15 -15
- data/test/business_central/object/request_test.rb +75 -12
- data/test/business_central/object/response_test.rb +34 -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 -16
- data/test/business_central/web_service_test.rb +100 -0
- data/test/business_central_test.rb +3 -1
- data/test/test_helper.rb +16 -6
- metadata +188 -37
- data/lib/business_central/object/helper.rb +0 -15
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
2
4
|
# rake test TEST=test/business_central/object/account_test.rb
|
3
5
|
|
4
6
|
class BusinessCentral::Object::AccountTest < Minitest::Test
|
@@ -17,7 +19,7 @@ class BusinessCentral::Object::AccountTest < Minitest::Test
|
|
17
19
|
def test_find_all
|
18
20
|
stub_request(:get, /accounts/)
|
19
21
|
.to_return(
|
20
|
-
status: 200,
|
22
|
+
status: 200,
|
21
23
|
body: {
|
22
24
|
'value': [
|
23
25
|
{
|
@@ -27,7 +29,6 @@ class BusinessCentral::Object::AccountTest < Minitest::Test
|
|
27
29
|
}.to_json
|
28
30
|
)
|
29
31
|
|
30
|
-
|
31
32
|
response = @account.find_all
|
32
33
|
assert_equal response.first[:display_name], 'account1'
|
33
34
|
end
|
@@ -36,7 +37,7 @@ class BusinessCentral::Object::AccountTest < Minitest::Test
|
|
36
37
|
test_account_id = '123'
|
37
38
|
stub_request(:get, /accounts\(#{test_account_id}\)/)
|
38
39
|
.to_return(
|
39
|
-
status: 200,
|
40
|
+
status: 200,
|
40
41
|
body: {
|
41
42
|
displayName: 'account2'
|
42
43
|
}.to_json
|
@@ -63,4 +64,4 @@ class BusinessCentral::Object::AccountTest < Minitest::Test
|
|
63
64
|
@account.destroy('123')
|
64
65
|
end
|
65
66
|
end
|
66
|
-
end
|
67
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
2
4
|
# rake test TEST=test/business_central/object/aged_account_payable_test.rb
|
3
5
|
|
4
6
|
class BusinessCentral::Object::AgedAccountPayableTest < Minitest::Test
|
@@ -11,7 +13,7 @@ class BusinessCentral::Object::AgedAccountPayableTest < Minitest::Test
|
|
11
13
|
def test_find_all
|
12
14
|
stub_request(:get, /agedAccountsPayable/)
|
13
15
|
.to_return(
|
14
|
-
status: 200,
|
16
|
+
status: 200,
|
15
17
|
body: {
|
16
18
|
'value': [
|
17
19
|
{
|
@@ -21,7 +23,6 @@ class BusinessCentral::Object::AgedAccountPayableTest < Minitest::Test
|
|
21
23
|
}.to_json
|
22
24
|
)
|
23
25
|
|
24
|
-
|
25
26
|
response = @aged_account_payable.find_all
|
26
27
|
assert_equal response.first[:name], 'vendor1'
|
27
28
|
end
|
@@ -30,7 +31,7 @@ class BusinessCentral::Object::AgedAccountPayableTest < Minitest::Test
|
|
30
31
|
test_id = '123'
|
31
32
|
stub_request(:get, /agedAccountsPayable\(#{test_id}\)/)
|
32
33
|
.to_return(
|
33
|
-
status: 200,
|
34
|
+
status: 200,
|
34
35
|
body: {
|
35
36
|
name: 'vendor2'
|
36
37
|
}.to_json
|
@@ -57,4 +58,4 @@ class BusinessCentral::Object::AgedAccountPayableTest < Minitest::Test
|
|
57
58
|
@aged_account_payable.destroy('123')
|
58
59
|
end
|
59
60
|
end
|
60
|
-
end
|
61
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
2
4
|
# rake test TEST=test/business_central/object/aged_account_receivable_test.rb
|
3
5
|
|
4
6
|
class BusinessCentral::Object::AgedAccountReceivableTest < Minitest::Test
|
@@ -11,7 +13,7 @@ class BusinessCentral::Object::AgedAccountReceivableTest < Minitest::Test
|
|
11
13
|
def test_find_all
|
12
14
|
stub_request(:get, /agedAccountsReceivable/)
|
13
15
|
.to_return(
|
14
|
-
status: 200,
|
16
|
+
status: 200,
|
15
17
|
body: {
|
16
18
|
'value': [
|
17
19
|
{
|
@@ -21,7 +23,6 @@ class BusinessCentral::Object::AgedAccountReceivableTest < Minitest::Test
|
|
21
23
|
}.to_json
|
22
24
|
)
|
23
25
|
|
24
|
-
|
25
26
|
response = @aged_account_receivable.find_all
|
26
27
|
assert_equal response.first[:name], 'customer1'
|
27
28
|
end
|
@@ -30,7 +31,7 @@ class BusinessCentral::Object::AgedAccountReceivableTest < Minitest::Test
|
|
30
31
|
test_id = '123'
|
31
32
|
stub_request(:get, /agedAccountsReceivable\(#{test_id}\)/)
|
32
33
|
.to_return(
|
33
|
-
status: 200,
|
34
|
+
status: 200,
|
34
35
|
body: {
|
35
36
|
name: 'customer2'
|
36
37
|
}.to_json
|
@@ -57,4 +58,4 @@ class BusinessCentral::Object::AgedAccountReceivableTest < Minitest::Test
|
|
57
58
|
@aged_account_receivable.destroy('123')
|
58
59
|
end
|
59
60
|
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
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
2
4
|
# rake test TEST=test/business_central/object/balance_sheet_test.rb
|
3
5
|
|
4
6
|
class BusinessCentral::Object::BalanceSheetTest < Minitest::Test
|
@@ -11,7 +13,7 @@ class BusinessCentral::Object::BalanceSheetTest < Minitest::Test
|
|
11
13
|
def test_find_all
|
12
14
|
stub_request(:get, /balanceSheet/)
|
13
15
|
.to_return(
|
14
|
-
status: 200,
|
16
|
+
status: 200,
|
15
17
|
body: {
|
16
18
|
'value': [
|
17
19
|
{
|
@@ -21,7 +23,6 @@ class BusinessCentral::Object::BalanceSheetTest < Minitest::Test
|
|
21
23
|
}.to_json
|
22
24
|
)
|
23
25
|
|
24
|
-
|
25
26
|
response = @balance_sheet.find_all
|
26
27
|
assert_equal response.first[:display], 'balance item 1'
|
27
28
|
end
|
@@ -30,7 +31,7 @@ class BusinessCentral::Object::BalanceSheetTest < Minitest::Test
|
|
30
31
|
test_id = '123'
|
31
32
|
stub_request(:get, /balanceSheet\(#{test_id}\)/)
|
32
33
|
.to_return(
|
33
|
-
status: 200,
|
34
|
+
status: 200,
|
34
35
|
body: {
|
35
36
|
display: 'balance item 2'
|
36
37
|
}.to_json
|
@@ -57,4 +58,4 @@ class BusinessCentral::Object::BalanceSheetTest < Minitest::Test
|
|
57
58
|
@balance_sheet.destroy('123')
|
58
59
|
end
|
59
60
|
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
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
2
4
|
# rake test TEST=test/business_central/object/cash_flow_statement_test.rb
|
3
5
|
|
4
6
|
class BusinessCentral::Object::CashFlowStatementTest < Minitest::Test
|
@@ -11,7 +13,7 @@ class BusinessCentral::Object::CashFlowStatementTest < Minitest::Test
|
|
11
13
|
def test_find_all
|
12
14
|
stub_request(:get, /cashFlowStatement/)
|
13
15
|
.to_return(
|
14
|
-
status: 200,
|
16
|
+
status: 200,
|
15
17
|
body: {
|
16
18
|
'value': [
|
17
19
|
{
|
@@ -21,7 +23,6 @@ class BusinessCentral::Object::CashFlowStatementTest < Minitest::Test
|
|
21
23
|
}.to_json
|
22
24
|
)
|
23
25
|
|
24
|
-
|
25
26
|
response = @cash_flow_statement.find_all
|
26
27
|
assert_equal response.first[:display], 'assets 1'
|
27
28
|
end
|
@@ -30,7 +31,7 @@ class BusinessCentral::Object::CashFlowStatementTest < Minitest::Test
|
|
30
31
|
test_id = '123'
|
31
32
|
stub_request(:get, /cashFlowStatement\(#{test_id}\)/)
|
32
33
|
.to_return(
|
33
|
-
status: 200,
|
34
|
+
status: 200,
|
34
35
|
body: {
|
35
36
|
display: 'assets 2'
|
36
37
|
}.to_json
|
@@ -57,4 +58,4 @@ class BusinessCentral::Object::CashFlowStatementTest < Minitest::Test
|
|
57
58
|
@cash_flow_statement.destroy('123')
|
58
59
|
end
|
59
60
|
end
|
60
|
-
end
|
61
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
2
4
|
# rake test TEST=test/business_central/object/company_information_test.rb
|
3
5
|
|
4
6
|
class BusinessCentral::Object::CompanyInformationTest < Minitest::Test
|
@@ -11,7 +13,7 @@ class BusinessCentral::Object::CompanyInformationTest < Minitest::Test
|
|
11
13
|
def test_find_all
|
12
14
|
stub_request(:get, /companyInformation/)
|
13
15
|
.to_return(
|
14
|
-
status: 200,
|
16
|
+
status: 200,
|
15
17
|
body: {
|
16
18
|
'value': [
|
17
19
|
{
|
@@ -21,7 +23,6 @@ class BusinessCentral::Object::CompanyInformationTest < Minitest::Test
|
|
21
23
|
}.to_json
|
22
24
|
)
|
23
25
|
|
24
|
-
|
25
26
|
response = @company_information.find_all
|
26
27
|
assert_equal response.first[:display_name], 'business1'
|
27
28
|
end
|
@@ -30,7 +31,7 @@ class BusinessCentral::Object::CompanyInformationTest < Minitest::Test
|
|
30
31
|
test_company_id = '123'
|
31
32
|
stub_request(:get, /companyInformation\(#{test_company_id}\)/)
|
32
33
|
.to_return(
|
33
|
-
status: 200,
|
34
|
+
status: 200,
|
34
35
|
body: {
|
35
36
|
displayName: 'business2'
|
36
37
|
}.to_json
|
@@ -50,7 +51,7 @@ class BusinessCentral::Object::CompanyInformationTest < Minitest::Test
|
|
50
51
|
test_company_id = '123'
|
51
52
|
stub_request(:get, /companyInformation\(#{test_company_id}\)/)
|
52
53
|
.to_return(
|
53
|
-
status: 200,
|
54
|
+
status: 200,
|
54
55
|
body: {
|
55
56
|
etag: '112',
|
56
57
|
displayName: 'business3'
|
@@ -59,7 +60,7 @@ class BusinessCentral::Object::CompanyInformationTest < Minitest::Test
|
|
59
60
|
|
60
61
|
stub_request(:patch, /companyInformation\(#{test_company_id}\)/)
|
61
62
|
.to_return(
|
62
|
-
status: 200,
|
63
|
+
status: 200,
|
63
64
|
body: {
|
64
65
|
displayName: 'business4'
|
65
66
|
}.to_json
|
@@ -67,9 +68,7 @@ class BusinessCentral::Object::CompanyInformationTest < Minitest::Test
|
|
67
68
|
|
68
69
|
response = @company_information.update(
|
69
70
|
test_company_id,
|
70
|
-
|
71
|
-
display_name: 'business4'
|
72
|
-
}
|
71
|
+
display_name: 'business4'
|
73
72
|
)
|
74
73
|
assert_equal response[:display_name], 'business4'
|
75
74
|
end
|
@@ -79,4 +78,4 @@ class BusinessCentral::Object::CompanyInformationTest < Minitest::Test
|
|
79
78
|
@company_information.destroy('123')
|
80
79
|
end
|
81
80
|
end
|
82
|
-
end
|
81
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
2
4
|
# rake test TEST=test/business_central/object/company_test.rb
|
3
5
|
|
4
6
|
class BusinessCentral::Object::CompanyTest < Minitest::Test
|
@@ -10,7 +12,7 @@ class BusinessCentral::Object::CompanyTest < Minitest::Test
|
|
10
12
|
def test_find_all
|
11
13
|
stub_request(:get, /companies/)
|
12
14
|
.to_return(
|
13
|
-
status: 200,
|
15
|
+
status: 200,
|
14
16
|
body: {
|
15
17
|
'value': [
|
16
18
|
{
|
@@ -20,7 +22,6 @@ class BusinessCentral::Object::CompanyTest < Minitest::Test
|
|
20
22
|
}.to_json
|
21
23
|
)
|
22
24
|
|
23
|
-
|
24
25
|
response = @company.find_all
|
25
26
|
assert_equal response.first[:display_name], 'business1'
|
26
27
|
end
|
@@ -29,7 +30,7 @@ class BusinessCentral::Object::CompanyTest < Minitest::Test
|
|
29
30
|
test_company_id = '123'
|
30
31
|
stub_request(:get, /companies\(#{test_company_id}\)/)
|
31
32
|
.to_return(
|
32
|
-
status: 200,
|
33
|
+
status: 200,
|
33
34
|
body: {
|
34
35
|
displayName: 'business2'
|
35
36
|
}.to_json
|
@@ -56,4 +57,4 @@ class BusinessCentral::Object::CompanyTest < Minitest::Test
|
|
56
57
|
@company.destroy('123')
|
57
58
|
end
|
58
59
|
end
|
59
|
-
end
|
60
|
+
end
|