business-central 1.0.7 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +45 -32
  3. data/lib/business_central/client.rb +7 -53
  4. data/lib/business_central/exceptions.rb +11 -29
  5. data/lib/business_central/object/{attachment.rb → attachments.rb} +9 -11
  6. data/lib/business_central/object/base.rb +42 -114
  7. data/lib/business_central/object/companies.rb +19 -0
  8. data/lib/business_central/object/filter_query.rb +2 -0
  9. data/lib/business_central/object/object_helper.rb +9 -36
  10. data/lib/business_central/object/picture.rb +4 -40
  11. data/lib/business_central/object/request.rb +14 -15
  12. data/lib/business_central/object/response.rb +2 -0
  13. data/lib/business_central/object/url_builder.rb +16 -12
  14. data/lib/business_central/object/url_helper.rb +2 -0
  15. data/lib/business_central/version.rb +1 -1
  16. data/lib/business_central/web_service.rb +2 -0
  17. data/lib/business_central.rb +4 -56
  18. data/lib/refinements/strings.rb +42 -0
  19. data/test/business_central/client_test.rb +24 -0
  20. data/test/business_central/exceptions_test.rb +40 -0
  21. data/test/business_central/object/{attachment_test.rb → attachments_test.rb} +5 -6
  22. data/test/business_central/object/base_test.rb +59 -22
  23. data/test/business_central/object/{company_test.rb → companies_test.rb} +3 -21
  24. data/test/business_central/object/picture_test.rb +7 -16
  25. metadata +25 -155
  26. data/lib/business_central/object/account.rb +0 -13
  27. data/lib/business_central/object/aged_account_payable.rb +0 -13
  28. data/lib/business_central/object/aged_account_receivable.rb +0 -13
  29. data/lib/business_central/object/argument_helper.rb +0 -22
  30. data/lib/business_central/object/balance_sheet.rb +0 -13
  31. data/lib/business_central/object/cash_flow_statement.rb +0 -13
  32. data/lib/business_central/object/company.rb +0 -18
  33. data/lib/business_central/object/company_information.rb +0 -14
  34. data/lib/business_central/object/country_region.rb +0 -26
  35. data/lib/business_central/object/currency.rb +0 -29
  36. data/lib/business_central/object/customer.rb +0 -34
  37. data/lib/business_central/object/customer_financial_detail.rb +0 -13
  38. data/lib/business_central/object/customer_payment.rb +0 -43
  39. data/lib/business_central/object/customer_payment_journal.rb +0 -25
  40. data/lib/business_central/object/customer_sale.rb +0 -13
  41. data/lib/business_central/object/default_dimension.rb +0 -51
  42. data/lib/business_central/object/dimension.rb +0 -20
  43. data/lib/business_central/object/dimension_line.rb +0 -37
  44. data/lib/business_central/object/dimension_value.rb +0 -28
  45. data/lib/business_central/object/employee.rb +0 -21
  46. data/lib/business_central/object/general_ledger_entry.rb +0 -13
  47. data/lib/business_central/object/income_statement.rb +0 -13
  48. data/lib/business_central/object/irs1099_code.rb +0 -16
  49. data/lib/business_central/object/item.rb +0 -47
  50. data/lib/business_central/object/item_category.rb +0 -16
  51. data/lib/business_central/object/journal.rb +0 -29
  52. data/lib/business_central/object/journal_line.rb +0 -48
  53. data/lib/business_central/object/payment_method.rb +0 -16
  54. data/lib/business_central/object/payment_term.rb +0 -16
  55. data/lib/business_central/object/purchase_invoice.rb +0 -69
  56. data/lib/business_central/object/purchase_invoice_line.rb +0 -37
  57. data/lib/business_central/object/purchase_order.rb +0 -16
  58. data/lib/business_central/object/retained_earning_statement.rb +0 -13
  59. data/lib/business_central/object/sales_credit_memo.rb +0 -20
  60. data/lib/business_central/object/sales_credit_memo_line.rb +0 -30
  61. data/lib/business_central/object/sales_invoice.rb +0 -62
  62. data/lib/business_central/object/sales_invoice_line.rb +0 -30
  63. data/lib/business_central/object/sales_order.rb +0 -20
  64. data/lib/business_central/object/sales_order_line.rb +0 -30
  65. data/lib/business_central/object/sales_quote.rb +0 -20
  66. data/lib/business_central/object/sales_quote_line.rb +0 -30
  67. data/lib/business_central/object/shipment_method.rb +0 -16
  68. data/lib/business_central/object/subscription.rb +0 -16
  69. data/lib/business_central/object/tax_area.rb +0 -16
  70. data/lib/business_central/object/tax_group.rb +0 -16
  71. data/lib/business_central/object/time_registration_entry.rb +0 -16
  72. data/lib/business_central/object/trial_balance.rb +0 -13
  73. data/lib/business_central/object/units_of_measure.rb +0 -16
  74. data/lib/business_central/object/validation.rb +0 -57
  75. data/lib/business_central/object/vendor.rb +0 -42
  76. data/lib/business_central/object/vendor_purchase.rb +0 -13
  77. data/lib/core_ext/string.rb +0 -31
  78. data/test/business_central/object/account_test.rb +0 -67
  79. data/test/business_central/object/aged_account_payable_test.rb +0 -61
  80. data/test/business_central/object/aged_account_receivable_test.rb +0 -61
  81. data/test/business_central/object/balance_sheet_test.rb +0 -61
  82. data/test/business_central/object/cash_flow_statement_test.rb +0 -61
  83. data/test/business_central/object/company_information_test.rb +0 -81
  84. data/test/business_central/object/country_region_test.rb +0 -129
  85. data/test/business_central/object/currency_test.rb +0 -150
  86. data/test/business_central/object/customer_financial_detail_test.rb +0 -68
  87. data/test/business_central/object/customer_payment_journal_test.rb +0 -134
  88. data/test/business_central/object/customer_payment_test.rb +0 -141
  89. data/test/business_central/object/customer_sale_test.rb +0 -72
  90. data/test/business_central/object/customer_test.rb +0 -168
  91. data/test/business_central/object/default_dimension_test.rb +0 -170
  92. data/test/business_central/object/dimension_line_test.rb +0 -165
  93. data/test/business_central/object/dimension_test.rb +0 -65
  94. data/test/business_central/object/dimension_value_test.rb +0 -68
  95. data/test/business_central/object/employee_test.rb +0 -141
  96. data/test/business_central/object/general_ledger_entry_test.rb +0 -82
  97. data/test/business_central/object/income_statement_test.rb +0 -82
  98. data/test/business_central/object/irs1099_code_test.rb +0 -124
  99. data/test/business_central/object/item_category_test.rb +0 -122
  100. data/test/business_central/object/item_test.rb +0 -121
  101. data/test/business_central/object/journal_line_test.rb +0 -152
  102. data/test/business_central/object/journal_test.rb +0 -144
  103. data/test/business_central/object/payment_method_test.rb +0 -134
  104. data/test/business_central/object/payment_term_test.rb +0 -134
  105. data/test/business_central/object/purchase_invoice_line_test.rb +0 -123
  106. data/test/business_central/object/purchase_invoice_test.rb +0 -119
  107. data/test/business_central/object/retained_earning_statement_test.rb +0 -52
  108. data/test/business_central/object/sales_credit_memo_line_test.rb +0 -134
  109. data/test/business_central/object/sales_credit_memo_test.rb +0 -146
  110. data/test/business_central/object/sales_invoice_line_test.rb +0 -164
  111. data/test/business_central/object/sales_invoice_test.rb +0 -156
  112. data/test/business_central/object/sales_order_line_test.rb +0 -134
  113. data/test/business_central/object/sales_order_test.rb +0 -146
  114. data/test/business_central/object/sales_quote_line_test.rb +0 -134
  115. data/test/business_central/object/sales_quote_test.rb +0 -146
  116. data/test/business_central/object/shipment_method_test.rb +0 -133
  117. data/test/business_central/object/subscription_test.rb +0 -126
  118. data/test/business_central/object/tax_area_test.rb +0 -126
  119. data/test/business_central/object/tax_group_test.rb +0 -126
  120. data/test/business_central/object/time_registration_entry_test.rb +0 -126
  121. data/test/business_central/object/trial_balance_test.rb +0 -82
  122. data/test/business_central/object/units_of_measure_test.rb +0 -126
  123. data/test/business_central/object/validation_test.rb +0 -62
  124. data/test/business_central/object/vendor_purchase_test.rb +0 -82
  125. data/test/business_central/object/vendor_test.rb +0 -119
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class TaxArea < Base
6
- OBJECT = 'taxAreas'
7
-
8
- OBJECT_METHODS = %i[
9
- get
10
- post
11
- patch
12
- delete
13
- ].freeze
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class TaxGroup < Base
6
- OBJECT = 'taxGroups'
7
-
8
- OBJECT_METHODS = %i[
9
- get
10
- post
11
- patch
12
- delete
13
- ].freeze
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class TimeRegistrationEntry < Base
6
- OBJECT = 'timeRegistrationEntries'
7
-
8
- OBJECT_METHODS = %i[
9
- get
10
- post
11
- patch
12
- delete
13
- ].freeze
14
- end
15
- end
16
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class TrialBalance < Base
6
- OBJECT = 'trialBalance'
7
-
8
- OBJECT_METHODS = %i[
9
- get
10
- ].freeze
11
- end
12
- end
13
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class UnitsOfMeasure < Base
6
- OBJECT = 'unitsOfMeasure'
7
-
8
- OBJECT_METHODS = %i[
9
- get
10
- post
11
- patch
12
- delete
13
- ].freeze
14
- end
15
- end
16
- end
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class Validation
6
- def initialize(validation_rules = [], object_params = {})
7
- @validation_rules = validation_rules
8
- @object_params = object_params
9
- @errors = []
10
- end
11
-
12
- def valid?
13
- @validation_rules.each do |rules_key, rules_value|
14
- rules_value.each do |validation_key, validation_value|
15
- if required?(validation_key, validation_value, @object_params[rules_key].to_s)
16
- @errors << { field: rules_key, message: 'is a required field' }
17
- end
18
-
19
- if exceeds_maximum_length?(validation_key, validation_value, @object_params[rules_key].to_s)
20
- @errors << { field: rules_key, message: "has exceeded the maximum length #{validation_value}" }
21
- end
22
-
23
- if not_inclusive_of?(validation_key, validation_value, @object_params[rules_key].to_s)
24
- @errors << { field: rules_key, message: "is not one of #{validation_value.join(', ')}" }
25
- end
26
-
27
- if date_type?(validation_key, validation_value, @object_params[rules_key])
28
- @errors << { field: rules_key, message: 'is not a date' }
29
- end
30
- end
31
- end
32
-
33
- raise InvalidObjectException, @errors if @errors.any?
34
-
35
- true
36
- end
37
-
38
- private
39
-
40
- def required?(validation_rule, validation_value, value)
41
- validation_rule == :required && validation_value == true && value.blank?
42
- end
43
-
44
- def exceeds_maximum_length?(validation_rule, validation_value, value)
45
- validation_rule == :maximum_length && value.length > validation_value
46
- end
47
-
48
- def not_inclusive_of?(validation_rule, validation_value, value)
49
- validation_rule == :inclusion_of && !validation_value.include?(value) && !value.blank?
50
- end
51
-
52
- def date_type?(validation_rule, validation_value, value)
53
- validation_rule == :date && validation_value == true && !value.is_a?(Date) && !value.nil?
54
- end
55
- end
56
- end
57
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class Vendor < Base
6
- extend BusinessCentral::Object::ObjectHelper
7
-
8
- OBJECT = 'vendors'
9
-
10
- OBJECT_VALIDATION = {
11
- number: {
12
- maximum_length: 20
13
- },
14
- display_name: {
15
- maximum_length: 100
16
- },
17
- phone_number: {
18
- maximum_length: 30
19
- },
20
- email: {
21
- maximum_length: 80
22
- },
23
- website: {
24
- maximum_length: 80
25
- },
26
- tax_registration_number: {
27
- maximum_length: 20
28
- }
29
- }.freeze
30
-
31
- OBJECT_METHODS = %i[
32
- get
33
- post
34
- patch
35
- delete
36
- ].freeze
37
-
38
- navigation :default_dimension
39
- navigation :picture
40
- end
41
- end
42
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class VendorPurchase < Base
6
- OBJECT = 'vendorPurchases'
7
-
8
- OBJECT_METHODS = %i[
9
- get
10
- ].freeze
11
- end
12
- end
13
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class String
4
- def blank?
5
- empty? || /\A[[:space:]]*\z/.match?(self)
6
- end
7
-
8
- def present?
9
- !blank?
10
- end
11
-
12
- # Convert string to CamelCase
13
- def to_camel_case(uppercase_first_letter = false)
14
- string = self
15
- string = if uppercase_first_letter
16
- string.sub(/^[a-z\d]*/, &:capitalize)
17
- else
18
- string.sub(/^(?:(?=\b|[A-Z_])|\w)/, &:downcase)
19
- end
20
- string.gsub(%r{(?:_|(/))([a-z\d]*)}) { "#{Regexp.last_match(1)}#{Regexp.last_match(2).capitalize}" }.gsub('/', '::')
21
- end
22
-
23
- # Convert string to snake_case
24
- def to_snake_case
25
- gsub(/::/, '/')
26
- .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
27
- .gsub(/([a-z\d])([A-Z])/, '\1_\2')
28
- .tr('-', '_')
29
- .downcase
30
- end
31
- end
@@ -1,67 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- # rake test TEST=test/business_central/object/account_test.rb
5
-
6
- class BusinessCentral::Object::AccountTest < Minitest::Test
7
- def setup
8
- @company_id = '123456'
9
- @client = BusinessCentral::Client.new
10
- @client.authorize_from_token(
11
- token: '123',
12
- refresh_token: '456',
13
- expires_at: Time.now + 3600,
14
- expires_in: 3600
15
- )
16
- @account = @client.account(company_id: @company_id)
17
- end
18
-
19
- def test_find_all
20
- stub_request(:get, /accounts/)
21
- .to_return(
22
- status: 200,
23
- body: {
24
- 'value': [
25
- {
26
- displayName: 'account1'
27
- }
28
- ]
29
- }.to_json
30
- )
31
-
32
- response = @account.find_all
33
- assert_equal response.first[:display_name], 'account1'
34
- end
35
-
36
- def test_find_by_id
37
- test_account_id = '123'
38
- stub_request(:get, /accounts\(#{test_account_id}\)/)
39
- .to_return(
40
- status: 200,
41
- body: {
42
- displayName: 'account2'
43
- }.to_json
44
- )
45
-
46
- response = @account.find_by_id(test_account_id)
47
- assert_equal response[:display_name], 'account2'
48
- end
49
-
50
- def test_create
51
- assert_raises BusinessCentral::NoSupportedMethod do
52
- @account.create({})
53
- end
54
- end
55
-
56
- def test_update
57
- assert_raises BusinessCentral::NoSupportedMethod do
58
- @account.update('123', {})
59
- end
60
- end
61
-
62
- def test_delete
63
- assert_raises BusinessCentral::NoSupportedMethod do
64
- @account.destroy('123')
65
- end
66
- end
67
- end
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- # rake test TEST=test/business_central/object/aged_account_payable_test.rb
5
-
6
- class BusinessCentral::Object::AgedAccountPayableTest < Minitest::Test
7
- def setup
8
- @company_id = '123456'
9
- @client = BusinessCentral::Client.new
10
- @aged_account_payable = @client.aged_account_payable(company_id: @company_id)
11
- end
12
-
13
- def test_find_all
14
- stub_request(:get, /agedAccountsPayable/)
15
- .to_return(
16
- status: 200,
17
- body: {
18
- 'value': [
19
- {
20
- name: 'vendor1'
21
- }
22
- ]
23
- }.to_json
24
- )
25
-
26
- response = @aged_account_payable.find_all
27
- assert_equal response.first[:name], 'vendor1'
28
- end
29
-
30
- def test_find_by_id
31
- test_id = '123'
32
- stub_request(:get, /agedAccountsPayable\(#{test_id}\)/)
33
- .to_return(
34
- status: 200,
35
- body: {
36
- name: 'vendor2'
37
- }.to_json
38
- )
39
-
40
- response = @aged_account_payable.find_by_id(test_id)
41
- assert_equal response[:name], 'vendor2'
42
- end
43
-
44
- def test_create
45
- assert_raises BusinessCentral::NoSupportedMethod do
46
- @aged_account_payable.create({})
47
- end
48
- end
49
-
50
- def test_update
51
- assert_raises BusinessCentral::NoSupportedMethod do
52
- @aged_account_payable.update('123', {})
53
- end
54
- end
55
-
56
- def test_delete
57
- assert_raises BusinessCentral::NoSupportedMethod do
58
- @aged_account_payable.destroy('123')
59
- end
60
- end
61
- end
@@ -1,61 +0,0 @@
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
@@ -1,61 +0,0 @@
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
@@ -1,61 +0,0 @@
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
@@ -1,81 +0,0 @@
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