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.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +58 -15
  3. data/lib/business_central.rb +47 -2
  4. data/lib/business_central/client.rb +82 -39
  5. data/lib/business_central/exceptions.rb +30 -10
  6. data/lib/business_central/object/account.rb +4 -12
  7. data/lib/business_central/object/aged_account_payable.rb +4 -12
  8. data/lib/business_central/object/aged_account_receivable.rb +4 -12
  9. data/lib/business_central/object/argument_helper.rb +22 -0
  10. data/lib/business_central/object/attachment.rb +30 -0
  11. data/lib/business_central/object/balance_sheet.rb +4 -12
  12. data/lib/business_central/object/base.rb +100 -49
  13. data/lib/business_central/object/cash_flow_statement.rb +4 -12
  14. data/lib/business_central/object/company.rb +9 -2
  15. data/lib/business_central/object/company_information.rb +7 -15
  16. data/lib/business_central/object/country_region.rb +26 -0
  17. data/lib/business_central/object/currency.rb +29 -0
  18. data/lib/business_central/object/customer.rb +34 -0
  19. data/lib/business_central/object/customer_financial_detail.rb +13 -0
  20. data/lib/business_central/object/customer_payment.rb +43 -0
  21. data/lib/business_central/object/customer_payment_journal.rb +25 -0
  22. data/lib/business_central/object/customer_sale.rb +13 -0
  23. data/lib/business_central/object/default_dimension.rb +51 -0
  24. data/lib/business_central/object/dimension.rb +20 -0
  25. data/lib/business_central/object/dimension_line.rb +37 -0
  26. data/lib/business_central/object/dimension_value.rb +28 -0
  27. data/lib/business_central/object/employee.rb +21 -0
  28. data/lib/business_central/object/filter_query.rb +18 -0
  29. data/lib/business_central/object/general_ledger_entry.rb +13 -0
  30. data/lib/business_central/object/income_statement.rb +13 -0
  31. data/lib/business_central/object/irs1099_code.rb +16 -0
  32. data/lib/business_central/object/item.rb +16 -19
  33. data/lib/business_central/object/item_category.rb +16 -0
  34. data/lib/business_central/object/journal.rb +29 -0
  35. data/lib/business_central/object/journal_line.rb +48 -0
  36. data/lib/business_central/object/object_helper.rb +49 -0
  37. data/lib/business_central/object/payment_method.rb +16 -0
  38. data/lib/business_central/object/payment_term.rb +16 -0
  39. data/lib/business_central/object/picture.rb +53 -0
  40. data/lib/business_central/object/purchase_invoice.rb +8 -16
  41. data/lib/business_central/object/purchase_invoice_line.rb +14 -18
  42. data/lib/business_central/object/request.rb +61 -50
  43. data/lib/business_central/object/response.rb +31 -23
  44. data/lib/business_central/object/retained_earning_statement.rb +13 -0
  45. data/lib/business_central/object/sales_credit_memo.rb +20 -0
  46. data/lib/business_central/object/sales_credit_memo_line.rb +30 -0
  47. data/lib/business_central/object/sales_invoice.rb +62 -0
  48. data/lib/business_central/object/sales_invoice_line.rb +30 -0
  49. data/lib/business_central/object/sales_order.rb +20 -0
  50. data/lib/business_central/object/sales_order_line.rb +30 -0
  51. data/lib/business_central/object/sales_quote.rb +20 -0
  52. data/lib/business_central/object/sales_quote_line.rb +30 -0
  53. data/lib/business_central/object/shipment_method.rb +16 -0
  54. data/lib/business_central/object/subscription.rb +16 -0
  55. data/lib/business_central/object/tax_area.rb +16 -0
  56. data/lib/business_central/object/tax_group.rb +16 -0
  57. data/lib/business_central/object/time_registration_entry.rb +16 -0
  58. data/lib/business_central/object/trial_balance.rb +13 -0
  59. data/lib/business_central/object/units_of_measure.rb +16 -0
  60. data/lib/business_central/object/url_builder.rb +59 -0
  61. data/lib/business_central/object/url_helper.rb +44 -0
  62. data/lib/business_central/object/validation.rb +10 -7
  63. data/lib/business_central/object/vendor.rb +12 -15
  64. data/lib/business_central/object/vendor_purchase.rb +13 -0
  65. data/lib/business_central/version.rb +4 -2
  66. data/lib/business_central/web_service.rb +78 -0
  67. data/lib/core_ext/string.rb +18 -12
  68. data/test/business_central/client_test.rb +49 -7
  69. data/test/business_central/object/account_test.rb +6 -5
  70. data/test/business_central/object/aged_account_payable_test.rb +6 -5
  71. data/test/business_central/object/aged_account_receivable_test.rb +6 -5
  72. data/test/business_central/object/attachment_test.rb +117 -0
  73. data/test/business_central/object/balance_sheet_test.rb +6 -5
  74. data/test/business_central/object/base_test.rb +41 -0
  75. data/test/business_central/object/cash_flow_statement_test.rb +6 -5
  76. data/test/business_central/object/company_information_test.rb +9 -10
  77. data/test/business_central/object/company_test.rb +6 -5
  78. data/test/business_central/object/country_region_test.rb +129 -0
  79. data/test/business_central/object/currency_test.rb +150 -0
  80. data/test/business_central/object/customer_financial_detail_test.rb +68 -0
  81. data/test/business_central/object/customer_payment_journal_test.rb +134 -0
  82. data/test/business_central/object/customer_payment_test.rb +141 -0
  83. data/test/business_central/object/customer_sale_test.rb +72 -0
  84. data/test/business_central/object/customer_test.rb +168 -0
  85. data/test/business_central/object/default_dimension_test.rb +170 -0
  86. data/test/business_central/object/dimension_line_test.rb +165 -0
  87. data/test/business_central/object/dimension_test.rb +65 -0
  88. data/test/business_central/object/dimension_value_test.rb +68 -0
  89. data/test/business_central/object/employee_test.rb +141 -0
  90. data/test/business_central/object/filter_query_test.rb +36 -0
  91. data/test/business_central/object/general_ledger_entry_test.rb +82 -0
  92. data/test/business_central/object/income_statement_test.rb +82 -0
  93. data/test/business_central/object/irs1099_code_test.rb +124 -0
  94. data/test/business_central/object/item_category_test.rb +122 -0
  95. data/test/business_central/object/item_test.rb +16 -17
  96. data/test/business_central/object/journal_line_test.rb +152 -0
  97. data/test/business_central/object/journal_test.rb +144 -0
  98. data/test/business_central/object/payment_method_test.rb +134 -0
  99. data/test/business_central/object/payment_term_test.rb +134 -0
  100. data/test/business_central/object/picture_test.rb +74 -0
  101. data/test/business_central/object/purchase_invoice_line_test.rb +15 -15
  102. data/test/business_central/object/purchase_invoice_test.rb +15 -15
  103. data/test/business_central/object/request_test.rb +75 -12
  104. data/test/business_central/object/response_test.rb +34 -9
  105. data/test/business_central/object/retained_earning_statement_test.rb +52 -0
  106. data/test/business_central/object/sales_credit_memo_line_test.rb +134 -0
  107. data/test/business_central/object/sales_credit_memo_test.rb +146 -0
  108. data/test/business_central/object/sales_invoice_line_test.rb +164 -0
  109. data/test/business_central/object/sales_invoice_test.rb +156 -0
  110. data/test/business_central/object/sales_order_line_test.rb +134 -0
  111. data/test/business_central/object/sales_order_test.rb +146 -0
  112. data/test/business_central/object/sales_quote_line_test.rb +134 -0
  113. data/test/business_central/object/sales_quote_test.rb +146 -0
  114. data/test/business_central/object/shipment_method_test.rb +133 -0
  115. data/test/business_central/object/subscription_test.rb +126 -0
  116. data/test/business_central/object/tax_area_test.rb +126 -0
  117. data/test/business_central/object/tax_group_test.rb +126 -0
  118. data/test/business_central/object/time_registration_entry_test.rb +126 -0
  119. data/test/business_central/object/trial_balance_test.rb +82 -0
  120. data/test/business_central/object/units_of_measure_test.rb +126 -0
  121. data/test/business_central/object/validation_test.rb +5 -4
  122. data/test/business_central/object/vendor_purchase_test.rb +82 -0
  123. data/test/business_central/object/vendor_test.rb +16 -16
  124. data/test/business_central/web_service_test.rb +100 -0
  125. data/test/business_central_test.rb +3 -1
  126. data/test/test_helper.rb +16 -6
  127. metadata +188 -37
  128. data/lib/business_central/object/helper.rb +0 -15
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+ # rake test TEST=test/business_central/object/picture_test.rb
5
+
6
+ class BusinessCentral::Object::PictureTest < Minitest::Test
7
+ def setup
8
+ @company_id = '123456'
9
+ @client = BusinessCentral::Client.new
10
+ @picture = @client.picture(parent: 'vendors', parent_id: '123', company_id: @company_id)
11
+ end
12
+
13
+ def test_find_all
14
+ stub_request(:get, /picture/)
15
+ .to_return(
16
+ status: 200,
17
+ body: {
18
+ 'value': [
19
+ {
20
+ id: 112,
21
+ width: 500,
22
+ height: 496,
23
+ contentType: 'image\jpeg'
24
+ }
25
+ ]
26
+ }.to_json
27
+ )
28
+
29
+ response = @picture.find_all
30
+ assert_equal response.first[:content_type], 'image\jpeg'
31
+ end
32
+
33
+ def test_create
34
+ stub_request(:patch, /picture/)
35
+ .to_return(status: 204)
36
+
37
+ response = @picture.create('ImageData')
38
+ assert response
39
+ end
40
+
41
+ def test_update
42
+ stub_request(:get, /picture/)
43
+ .to_return(
44
+ status: 200,
45
+ body: {
46
+ etag: '112',
47
+ contentType: 'image\jpeg'
48
+ }.to_json
49
+ )
50
+
51
+ stub_request(:patch, /picture/)
52
+ .to_return(status: 204)
53
+
54
+ response = @picture.update('ImageData')
55
+ assert response
56
+ end
57
+
58
+ def test_delete
59
+ test_id = 2
60
+ stub_request(:get, /picture/)
61
+ .to_return(
62
+ status: 200,
63
+ body: {
64
+ etag: '113',
65
+ contentType: 'image\jpeg'
66
+ }.to_json
67
+ )
68
+
69
+ stub_request(:delete, /picture/)
70
+ .to_return(status: 204)
71
+
72
+ assert @picture.destroy(test_id)
73
+ end
74
+ end
@@ -1,4 +1,6 @@
1
- require "test_helper"
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
2
4
  # rake test TEST=test/business_central/object/purchase_invoice_line_test.rb
3
5
 
4
6
  class BusinessCentral::Object::PurchaseInvoiceLineTest < Minitest::Test
@@ -15,14 +17,14 @@ class BusinessCentral::Object::PurchaseInvoiceLineTest < Minitest::Test
15
17
  def test_find_all
16
18
  stub_request(:get, /purchaseInvoiceLines/)
17
19
  .to_return(
18
- status: 200,
20
+ status: 200,
19
21
  body: {
20
22
  'value': [
21
23
  {
22
24
  description: 'po line 1'
23
25
  }
24
26
  ]
25
- }.to_json,
27
+ }.to_json
26
28
  )
27
29
 
28
30
  response = @purchase_invoice_line.find_all
@@ -33,7 +35,7 @@ class BusinessCentral::Object::PurchaseInvoiceLineTest < Minitest::Test
33
35
  test_purchase_invoice_line_id = '09876'
34
36
  stub_request(:get, /purchaseInvoiceLines\(#{test_purchase_invoice_line_id}\)/)
35
37
  .to_return(
36
- status: 200,
38
+ status: 200,
37
39
  body: {
38
40
  description: 'po line 2'
39
41
  }.to_json
@@ -47,7 +49,7 @@ class BusinessCentral::Object::PurchaseInvoiceLineTest < Minitest::Test
47
49
  test_filter = "description eq 'po line 3'"
48
50
  stub_request(:get, /purchaseInvoiceLines\?\$filter=#{test_filter}/)
49
51
  .to_return(
50
- status: 200,
52
+ status: 200,
51
53
  body: {
52
54
  'value': [
53
55
  {
@@ -64,15 +66,15 @@ class BusinessCentral::Object::PurchaseInvoiceLineTest < Minitest::Test
64
66
  def test_create
65
67
  stub_request(:post, /purchaseInvoiceLines/)
66
68
  .to_return(
67
- status: 200,
69
+ status: 200,
68
70
  body: {
69
71
  description: 'po line 4'
70
72
  }.to_json
71
73
  )
72
74
 
73
- response = @purchase_invoice_line.create({
75
+ response = @purchase_invoice_line.create(
74
76
  description: 'po line 4'
75
- })
77
+ )
76
78
  assert_equal response[:description], 'po line 4'
77
79
  end
78
80
 
@@ -80,7 +82,7 @@ class BusinessCentral::Object::PurchaseInvoiceLineTest < Minitest::Test
80
82
  test_purchase_invoice_line_id = '011123'
81
83
  stub_request(:get, /purchaseInvoiceLines\(#{test_purchase_invoice_line_id}\)/)
82
84
  .to_return(
83
- status: 200,
85
+ status: 200,
84
86
  body: {
85
87
  etag: '112',
86
88
  description: 'po line 5'
@@ -89,7 +91,7 @@ class BusinessCentral::Object::PurchaseInvoiceLineTest < Minitest::Test
89
91
 
90
92
  stub_request(:patch, /purchaseInvoiceLines\(#{test_purchase_invoice_line_id}\)/)
91
93
  .to_return(
92
- status: 200,
94
+ status: 200,
93
95
  body: {
94
96
  description: 'po line 6'
95
97
  }.to_json
@@ -97,9 +99,7 @@ class BusinessCentral::Object::PurchaseInvoiceLineTest < Minitest::Test
97
99
 
98
100
  response = @purchase_invoice_line.update(
99
101
  test_purchase_invoice_line_id,
100
- {
101
- description: 'po line 6'
102
- }
102
+ description: 'po line 6'
103
103
  )
104
104
  assert_equal response[:description], 'po line 6'
105
105
  end
@@ -108,7 +108,7 @@ class BusinessCentral::Object::PurchaseInvoiceLineTest < Minitest::Test
108
108
  test_purchase_invoice_line_id = '0111245'
109
109
  stub_request(:get, /purchaseInvoiceLines\(#{test_purchase_invoice_line_id}\)/)
110
110
  .to_return(
111
- status: 200,
111
+ status: 200,
112
112
  body: {
113
113
  etag: '113',
114
114
  description: 'po line 6'
@@ -120,4 +120,4 @@ class BusinessCentral::Object::PurchaseInvoiceLineTest < Minitest::Test
120
120
 
121
121
  assert @purchase_invoice_line.destroy(test_purchase_invoice_line_id)
122
122
  end
123
- end
123
+ end
@@ -1,4 +1,6 @@
1
- require "test_helper"
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
2
4
  # rake test TEST=test/business_central/object/purchase_invoice_test.rb
3
5
 
4
6
  class BusinessCentral::Object::PurchaseInvoiceTest < Minitest::Test
@@ -11,14 +13,14 @@ class BusinessCentral::Object::PurchaseInvoiceTest < Minitest::Test
11
13
  def test_find_all
12
14
  stub_request(:get, /purchaseInvoices/)
13
15
  .to_return(
14
- status: 200,
16
+ status: 200,
15
17
  body: {
16
18
  'value': [
17
19
  {
18
20
  displayName: 'po1'
19
21
  }
20
22
  ]
21
- }.to_json,
23
+ }.to_json
22
24
  )
23
25
 
24
26
  response = @purchase_invoice.find_all
@@ -29,7 +31,7 @@ class BusinessCentral::Object::PurchaseInvoiceTest < Minitest::Test
29
31
  test_purchase_invoice_id = '09876'
30
32
  stub_request(:get, /purchaseInvoices\(#{test_purchase_invoice_id}\)/)
31
33
  .to_return(
32
- status: 200,
34
+ status: 200,
33
35
  body: {
34
36
  displayName: 'po2'
35
37
  }.to_json
@@ -43,7 +45,7 @@ class BusinessCentral::Object::PurchaseInvoiceTest < Minitest::Test
43
45
  test_filter = "displayName eq 'po3'"
44
46
  stub_request(:get, /purchaseInvoices\?\$filter=#{test_filter}/)
45
47
  .to_return(
46
- status: 200,
48
+ status: 200,
47
49
  body: {
48
50
  'value': [
49
51
  {
@@ -60,15 +62,15 @@ class BusinessCentral::Object::PurchaseInvoiceTest < Minitest::Test
60
62
  def test_create
61
63
  stub_request(:post, /purchaseInvoices/)
62
64
  .to_return(
63
- status: 200,
65
+ status: 200,
64
66
  body: {
65
67
  displayName: 'po4'
66
68
  }.to_json
67
69
  )
68
70
 
69
- response = @purchase_invoice.create({
71
+ response = @purchase_invoice.create(
70
72
  display_name: 'po4'
71
- })
73
+ )
72
74
  assert_equal response[:display_name], 'po4'
73
75
  end
74
76
 
@@ -76,7 +78,7 @@ class BusinessCentral::Object::PurchaseInvoiceTest < Minitest::Test
76
78
  test_purchase_invoice_id = '011123'
77
79
  stub_request(:get, /purchaseInvoices\(#{test_purchase_invoice_id}\)/)
78
80
  .to_return(
79
- status: 200,
81
+ status: 200,
80
82
  body: {
81
83
  etag: '112',
82
84
  displayName: 'po5'
@@ -85,7 +87,7 @@ class BusinessCentral::Object::PurchaseInvoiceTest < Minitest::Test
85
87
 
86
88
  stub_request(:patch, /purchaseInvoices\(#{test_purchase_invoice_id}\)/)
87
89
  .to_return(
88
- status: 200,
90
+ status: 200,
89
91
  body: {
90
92
  displayName: 'po6'
91
93
  }.to_json
@@ -93,9 +95,7 @@ class BusinessCentral::Object::PurchaseInvoiceTest < Minitest::Test
93
95
 
94
96
  response = @purchase_invoice.update(
95
97
  test_purchase_invoice_id,
96
- {
97
- display_name: 'po6'
98
- }
98
+ display_name: 'po6'
99
99
  )
100
100
  assert_equal response[:display_name], 'po6'
101
101
  end
@@ -104,7 +104,7 @@ class BusinessCentral::Object::PurchaseInvoiceTest < Minitest::Test
104
104
  test_purchase_invoice_id = '0111245'
105
105
  stub_request(:get, /purchaseInvoices\(#{test_purchase_invoice_id}\)/)
106
106
  .to_return(
107
- status: 200,
107
+ status: 200,
108
108
  body: {
109
109
  etag: '113',
110
110
  displayName: 'po7'
@@ -116,4 +116,4 @@ class BusinessCentral::Object::PurchaseInvoiceTest < Minitest::Test
116
116
 
117
117
  assert @purchase_invoice.destroy(test_purchase_invoice_id)
118
118
  end
119
- end
119
+ end
@@ -1,4 +1,6 @@
1
- require "test_helper"
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
2
4
  # rake test TEST=test/business_central/object/request_test.rb
3
5
 
4
6
  class BusinessCentral::Object::RequestTest < Minitest::Test
@@ -10,14 +12,14 @@ class BusinessCentral::Object::RequestTest < Minitest::Test
10
12
  def test_get_request
11
13
  stub_request(:get, @url)
12
14
  .to_return(
13
- status: 200,
15
+ status: 200,
14
16
  body: {
15
17
  'value': [
16
18
  {
17
19
  displayName: 'value1'
18
20
  }
19
21
  ]
20
- }.to_json,
22
+ }.to_json
21
23
  )
22
24
 
23
25
  response = BusinessCentral::Object::Request.get(@client, @url)
@@ -28,17 +30,17 @@ class BusinessCentral::Object::RequestTest < Minitest::Test
28
30
  def test_post_request
29
31
  stub_request(:post, @url)
30
32
  .to_return(
31
- status: 200,
33
+ status: 200,
32
34
  body: {
33
35
  'value': [
34
36
  {
35
37
  displayName: 'value2'
36
38
  }
37
39
  ]
38
- }.to_json,
40
+ }.to_json
39
41
  )
40
42
 
41
- response = BusinessCentral::Object::Request.post(@client, @url, { display_name: 'value2' })
43
+ response = BusinessCentral::Object::Request.post(@client, @url, display_name: 'value2')
42
44
 
43
45
  assert_equal 'value2', response.first[:display_name]
44
46
  end
@@ -46,17 +48,17 @@ class BusinessCentral::Object::RequestTest < Minitest::Test
46
48
  def test_patch_request
47
49
  stub_request(:patch, @url)
48
50
  .to_return(
49
- status: 200,
51
+ status: 200,
50
52
  body: {
51
53
  'value': [
52
54
  {
53
55
  displayName: 'value3'
54
56
  }
55
57
  ]
56
- }.to_json,
58
+ }.to_json
57
59
  )
58
60
 
59
- response = BusinessCentral::Object::Request.patch(@client, @url, '1', { display_name: 'value3' })
61
+ response = BusinessCentral::Object::Request.patch(@client, @url, '1', display_name: 'value3')
60
62
 
61
63
  assert_equal 'value3', response.first[:display_name]
62
64
  end
@@ -68,9 +70,70 @@ class BusinessCentral::Object::RequestTest < Minitest::Test
68
70
  assert BusinessCentral::Object::Request.delete(@client, @url, '1')
69
71
  end
70
72
 
71
- def test_request_convert_parameters
73
+ def test_request_convert_symbol_parameters
72
74
  param = { new_key: 'value' }
73
75
  request = JSON.parse(BusinessCentral::Object::Request.convert(param))
74
- assert request.has_key?("newKey")
76
+ assert request.key?('newKey')
77
+ end
78
+
79
+ def test_skip_request_converting_string_parameters
80
+ param = { 'New_Key' => 'value' }
81
+ request = JSON.parse(BusinessCentral::Object::Request.convert(param))
82
+ assert request.key?('New_Key')
83
+ end
84
+
85
+ def test_get_request_returns_unathorized_error
86
+ stub_request(:get, @url)
87
+ .to_return(status: 401)
88
+
89
+ assert_raises(BusinessCentral::UnauthorizedException) do
90
+ BusinessCentral::Object::Request.get(@client, @url)
91
+ end
92
+ end
93
+
94
+ def test_get_request_returns_error_company_not_found
95
+ stub_request(:get, @url)
96
+ .to_return(
97
+ status: 400,
98
+ body: {
99
+ error: {
100
+ code: 'Internal_CompanyNotFound'
101
+ }
102
+ }.to_json
103
+ )
104
+
105
+ assert_raises(BusinessCentral::CompanyNotFoundException) do
106
+ BusinessCentral::Object::Request.get(@client, @url)
107
+ end
108
+ end
109
+
110
+ def test_get_request_returns_error_code
111
+ stub_request(:get, @url)
112
+ .to_return(
113
+ status: 400,
114
+ body: {
115
+ error: {
116
+ code: 'Not_Catered_For'
117
+ }
118
+ }.to_json
119
+ )
120
+
121
+ assert_raises(BusinessCentral::ApiException) do
122
+ BusinessCentral::Object::Request.get(@client, @url)
123
+ end
124
+ end
125
+
126
+ def test_get_request_returns_error_with_no_code
127
+ stub_request(:get, @url)
128
+ .to_return(
129
+ status: 400,
130
+ body: {
131
+ nope: 'wup wup'
132
+ }.to_json
133
+ )
134
+
135
+ assert_raises(BusinessCentral::ApiException) do
136
+ BusinessCentral::Object::Request.get(@client, @url)
137
+ end
75
138
  end
76
- end
139
+ end
@@ -1,13 +1,9 @@
1
- require "test_helper"
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
2
4
  # rake test TEST=test/business_central/object/response_test.rb
3
5
 
4
6
  class BusinessCentral::Object::ResponseTest < Minitest::Test
5
- def test_process_response
6
- params = '{"newKey": "value"}'
7
- request = BusinessCentral::Object::Response.new(params).results
8
- assert request.has_key?(:new_key)
9
- end
10
-
11
7
  def test_success
12
8
  assert BusinessCentral::Object::Response.success?(200)
13
9
  end
@@ -21,6 +17,35 @@ class BusinessCentral::Object::ResponseTest < Minitest::Test
21
17
  end
22
18
 
23
19
  def test_no_response
24
- BusinessCentral::Object::Response.new("").results
20
+ BusinessCentral::Object::Response.new('').results
21
+ end
22
+
23
+ def test_process_response
24
+ params = '{"newKey": "value"}'
25
+ request = BusinessCentral::Object::Response.new(params).results
26
+ assert request.key?(:new_key)
27
+ end
28
+
29
+ def test_process_etag
30
+ params = '{"@odata.etag": "123"}'
31
+ request = BusinessCentral::Object::Response.new(params).results
32
+ assert request.key?(:etag)
33
+ end
34
+
35
+ def test_process_context
36
+ params = '{"@odata.context": "123"}'
37
+ request = BusinessCentral::Object::Response.new(params).results
38
+ assert request.key?(:context)
39
+ end
40
+
41
+ def test_process_inner_hash
42
+ params = '{"item": { "id": "123" }}'
43
+ request = BusinessCentral::Object::Response.new(params).results
44
+ assert request.key?(:item)
45
+ end
46
+
47
+ def test_string_response
48
+ response = BusinessCentral::Object::Response.new('{ "value": "OK - Action was successful" }')
49
+ assert_equal 'OK - Action was successful', response.results
25
50
  end
26
- end
51
+ end