business-central 1.0.3 → 1.0.7

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.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +58 -15
  3. data/lib/business_central/client.rb +71 -41
  4. data/lib/business_central/exceptions.rb +19 -9
  5. data/lib/business_central/object/account.rb +4 -2
  6. data/lib/business_central/object/aged_account_payable.rb +4 -2
  7. data/lib/business_central/object/aged_account_receivable.rb +4 -2
  8. data/lib/business_central/object/argument_helper.rb +22 -0
  9. data/lib/business_central/object/attachment.rb +30 -0
  10. data/lib/business_central/object/balance_sheet.rb +4 -2
  11. data/lib/business_central/object/base.rb +90 -56
  12. data/lib/business_central/object/cash_flow_statement.rb +4 -2
  13. data/lib/business_central/object/company.rb +5 -3
  14. data/lib/business_central/object/company_information.rb +7 -5
  15. data/lib/business_central/object/country_region.rb +8 -6
  16. data/lib/business_central/object/currency.rb +8 -6
  17. data/lib/business_central/object/customer.rb +16 -9
  18. data/lib/business_central/object/customer_financial_detail.rb +3 -1
  19. data/lib/business_central/object/customer_payment.rb +8 -6
  20. data/lib/business_central/object/customer_payment_journal.rb +8 -6
  21. data/lib/business_central/object/customer_sale.rb +3 -1
  22. data/lib/business_central/object/default_dimension.rb +18 -21
  23. data/lib/business_central/object/dimension.rb +20 -0
  24. data/lib/business_central/object/dimension_line.rb +37 -0
  25. data/lib/business_central/object/dimension_value.rb +28 -0
  26. data/lib/business_central/object/employee.rb +21 -0
  27. data/lib/business_central/object/filter_query.rb +18 -0
  28. data/lib/business_central/object/general_ledger_entry.rb +13 -0
  29. data/lib/business_central/object/income_statement.rb +13 -0
  30. data/lib/business_central/object/irs1099_code.rb +16 -0
  31. data/lib/business_central/object/item.rb +17 -10
  32. data/lib/business_central/object/item_category.rb +16 -0
  33. data/lib/business_central/object/journal.rb +29 -0
  34. data/lib/business_central/object/journal_line.rb +48 -0
  35. data/lib/business_central/object/{helper.rb → object_helper.rb} +18 -10
  36. data/lib/business_central/object/payment_method.rb +16 -0
  37. data/lib/business_central/object/payment_term.rb +16 -0
  38. data/lib/business_central/object/picture.rb +53 -0
  39. data/lib/business_central/object/purchase_invoice.rb +8 -6
  40. data/lib/business_central/object/purchase_invoice_line.rb +10 -8
  41. data/lib/business_central/object/purchase_order.rb +16 -0
  42. data/lib/business_central/object/request.rb +60 -49
  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 +10 -7
  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/business_central.rb +40 -2
  68. data/lib/core_ext/string.rb +18 -12
  69. data/test/business_central/client_test.rb +18 -11
  70. data/test/business_central/object/account_test.rb +6 -5
  71. data/test/business_central/object/aged_account_payable_test.rb +6 -5
  72. data/test/business_central/object/aged_account_receivable_test.rb +6 -5
  73. data/test/business_central/object/attachment_test.rb +117 -0
  74. data/test/business_central/object/balance_sheet_test.rb +6 -5
  75. data/test/business_central/object/base_test.rb +4 -2
  76. data/test/business_central/object/cash_flow_statement_test.rb +6 -5
  77. data/test/business_central/object/company_information_test.rb +9 -10
  78. data/test/business_central/object/company_test.rb +6 -5
  79. data/test/business_central/object/country_region_test.rb +16 -17
  80. data/test/business_central/object/currency_test.rb +17 -18
  81. data/test/business_central/object/customer_financial_detail_test.rb +8 -6
  82. data/test/business_central/object/customer_payment_journal_test.rb +14 -15
  83. data/test/business_central/object/customer_payment_test.rb +15 -16
  84. data/test/business_central/object/customer_sale_test.rb +8 -6
  85. data/test/business_central/object/customer_test.rb +59 -16
  86. data/test/business_central/object/default_dimension_test.rb +15 -16
  87. data/test/business_central/object/dimension_line_test.rb +165 -0
  88. data/test/business_central/object/dimension_test.rb +65 -0
  89. data/test/business_central/object/dimension_value_test.rb +68 -0
  90. data/test/business_central/object/employee_test.rb +141 -0
  91. data/test/business_central/object/filter_query_test.rb +36 -0
  92. data/test/business_central/object/general_ledger_entry_test.rb +82 -0
  93. data/test/business_central/object/income_statement_test.rb +82 -0
  94. data/test/business_central/object/irs1099_code_test.rb +124 -0
  95. data/test/business_central/object/item_category_test.rb +122 -0
  96. data/test/business_central/object/item_test.rb +16 -17
  97. data/test/business_central/object/journal_line_test.rb +152 -0
  98. data/test/business_central/object/journal_test.rb +144 -0
  99. data/test/business_central/object/payment_method_test.rb +134 -0
  100. data/test/business_central/object/payment_term_test.rb +134 -0
  101. data/test/business_central/object/picture_test.rb +74 -0
  102. data/test/business_central/object/purchase_invoice_line_test.rb +15 -15
  103. data/test/business_central/object/purchase_invoice_test.rb +15 -15
  104. data/test/business_central/object/request_test.rb +17 -9
  105. data/test/business_central/object/response_test.rb +14 -7
  106. data/test/business_central/object/retained_earning_statement_test.rb +52 -0
  107. data/test/business_central/object/sales_credit_memo_line_test.rb +134 -0
  108. data/test/business_central/object/sales_credit_memo_test.rb +146 -0
  109. data/test/business_central/object/sales_invoice_line_test.rb +164 -0
  110. data/test/business_central/object/sales_invoice_test.rb +156 -0
  111. data/test/business_central/object/sales_order_line_test.rb +134 -0
  112. data/test/business_central/object/sales_order_test.rb +146 -0
  113. data/test/business_central/object/sales_quote_line_test.rb +134 -0
  114. data/test/business_central/object/sales_quote_test.rb +146 -0
  115. data/test/business_central/object/shipment_method_test.rb +133 -0
  116. data/test/business_central/object/subscription_test.rb +126 -0
  117. data/test/business_central/object/tax_area_test.rb +126 -0
  118. data/test/business_central/object/tax_group_test.rb +126 -0
  119. data/test/business_central/object/time_registration_entry_test.rb +126 -0
  120. data/test/business_central/object/trial_balance_test.rb +82 -0
  121. data/test/business_central/object/units_of_measure_test.rb +126 -0
  122. data/test/business_central/object/validation_test.rb +5 -4
  123. data/test/business_central/object/vendor_purchase_test.rb +82 -0
  124. data/test/business_central/object/vendor_test.rb +16 -16
  125. data/test/business_central/web_service_test.rb +100 -0
  126. data/test/business_central_test.rb +3 -1
  127. data/test/test_helper.rb +12 -6
  128. metadata +153 -41
@@ -1,25 +1,31 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class String
2
4
  def blank?
3
5
  empty? || /\A[[:space:]]*\z/.match?(self)
4
6
  end
5
7
 
8
+ def present?
9
+ !blank?
10
+ end
11
+
6
12
  # Convert string to CamelCase
7
13
  def to_camel_case(uppercase_first_letter = false)
8
14
  string = self
9
- if uppercase_first_letter
10
- string = string.sub(/^[a-z\d]*/) { |match| match.capitalize }
11
- else
12
- string = string.sub(/^(?:(?=\b|[A-Z_])|\w)/) { |match| match.downcase }
13
- end
14
- string.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" }.gsub("/", "::")
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('/', '::')
15
21
  end
16
22
 
17
23
  # Convert string to snake_case
18
24
  def to_snake_case
19
- self.gsub(/::/, '/').
20
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
21
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
22
- tr("-", "_").
23
- downcase
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
24
30
  end
25
- end
31
+ 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/client_test.rb
3
5
 
4
6
  class BusinessCentral::ClientTest < Minitest::Test
@@ -9,8 +11,8 @@ class BusinessCentral::ClientTest < Minitest::Test
9
11
  def test_authorize_client
10
12
  test_redirect_url = 'www.example.com'
11
13
  response = @client.authorize(oauth_authorize_callback: test_redirect_url)
12
- assert_match /oauth2\/authorize?/, response
13
- assert_match /redirect_uri=#{test_redirect_url}/, response
14
+ assert_match(%r{oauth2/authorize?}, response)
15
+ assert_match(/redirect_uri=#{test_redirect_url}/, response)
14
16
  end
15
17
 
16
18
  def test_request_client_token
@@ -32,7 +34,7 @@ class BusinessCentral::ClientTest < Minitest::Test
32
34
  )
33
35
 
34
36
  response = @client.request_token('code123', oauth_token_callback: test_redirect_url)
35
- assert_equal test_access_token,response.token
37
+ assert_equal test_access_token, response.token
36
38
  end
37
39
 
38
40
  def test_authorize_client_from_token
@@ -76,13 +78,13 @@ class BusinessCentral::ClientTest < Minitest::Test
76
78
 
77
79
  def test_authorize_throws_exception
78
80
  stub_request(:get, BusinessCentral::Client::DEFAULT_LOGIN_URL)
79
- .to_return(status: 200, body: "", headers: {})
81
+ .to_return(status: 200, body: '', headers: {})
80
82
 
81
83
  mock = MiniTest::Mock.new
82
- def mock.authorize_url(arguments)
84
+ def mock.authorize_url(_arguments)
83
85
  response = Faraday.get(BusinessCentral::Client::DEFAULT_LOGIN_URL)
84
86
  response = OAuth2::Response.new(response)
85
- raise OAuth2::Error.new(response)
87
+ raise OAuth2::Error, response
86
88
  end
87
89
 
88
90
  OAuth2::Strategy::AuthCode.stub(:new, mock) do
@@ -94,13 +96,13 @@ class BusinessCentral::ClientTest < Minitest::Test
94
96
 
95
97
  def test_request_token_throws_exception
96
98
  stub_request(:get, BusinessCentral::Client::DEFAULT_URL)
97
- .to_return(status: 200, body: "", headers: {})
99
+ .to_return(status: 200, body: '', headers: {})
98
100
 
99
101
  mock = MiniTest::Mock.new
100
- def mock.get_token(code, redirect_uri: '')
102
+ def mock.get_token(*_params)
101
103
  response = Faraday.get(BusinessCentral::Client::DEFAULT_URL)
102
104
  response = OAuth2::Response.new(response)
103
- raise OAuth2::Error.new(response)
105
+ raise OAuth2::Error, response
104
106
  end
105
107
 
106
108
  OAuth2::Strategy::AuthCode.stub(:new, mock) do
@@ -109,4 +111,9 @@ class BusinessCentral::ClientTest < Minitest::Test
109
111
  end
110
112
  end
111
113
  end
112
- end
114
+
115
+ def test_build_web_service_object
116
+ @client.web_service.object('Company/Vendors')
117
+ assert_equal @client.web_service.object_url, 'Company/Vendors'
118
+ 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/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
- require "test_helper"
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
- require "test_helper"
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
- require "test_helper"
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
@@ -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/base_test.rb
3
5
 
4
6
  class BusinessCentral::Object::BaseTest < Minitest::Test
@@ -36,4 +38,4 @@ class BusinessCentral::Object::BaseTest < Minitest::Test
36
38
  def set_object_method(base, value)
37
39
  base.class.const_set('OBJECT_METHODS', value) if !base.class.const_defined?('OBJECT_METHODS')
38
40
  end
39
- end
41
+ 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/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
- require "test_helper"
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
- require "test_helper"
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
@@ -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/country_region_test.rb
3
5
 
4
6
  class BusinessCentral::Object::CountryRegionTest < Minitest::Test
@@ -11,7 +13,7 @@ class BusinessCentral::Object::CountryRegionTest < Minitest::Test
11
13
  def test_find_all
12
14
  stub_request(:get, /countriesRegions/)
13
15
  .to_return(
14
- status: 200,
16
+ status: 200,
15
17
  body: {
16
18
  'value': [
17
19
  {
@@ -20,7 +22,7 @@ class BusinessCentral::Object::CountryRegionTest < Minitest::Test
20
22
  displayName: 'country1'
21
23
  }
22
24
  ]
23
- }.to_json,
25
+ }.to_json
24
26
  )
25
27
 
26
28
  response = @country_region.find_all
@@ -31,7 +33,7 @@ class BusinessCentral::Object::CountryRegionTest < Minitest::Test
31
33
  test_id = '1111'
32
34
  stub_request(:get, /countriesRegions\(#{test_id}\)/)
33
35
  .to_return(
34
- status: 200,
36
+ status: 200,
35
37
  body: {
36
38
  id: 2,
37
39
  code: 'C2',
@@ -47,7 +49,7 @@ class BusinessCentral::Object::CountryRegionTest < Minitest::Test
47
49
  test_filter = "displayName eq 'country3'"
48
50
  stub_request(:get, /countriesRegions\?\$filter=#{test_filter}/)
49
51
  .to_return(
50
- status: 200,
52
+ status: 200,
51
53
  body: {
52
54
  'value': [
53
55
  {
@@ -64,25 +66,24 @@ class BusinessCentral::Object::CountryRegionTest < Minitest::Test
64
66
  def test_create
65
67
  stub_request(:post, /countriesRegions/)
66
68
  .to_return(
67
- status: 200,
69
+ status: 200,
68
70
  body: {
69
71
  displayName: 'country4'
70
72
  }.to_json
71
73
  )
72
74
 
73
- response = @country_region.create({
75
+ response = @country_region.create(
74
76
  code: 'C4',
75
77
  display_name: 'country4'
76
- })
78
+ )
77
79
  assert_equal response[:display_name], 'country4'
78
80
  end
79
81
 
80
-
81
82
  def test_update
82
83
  test_id = '22222'
83
84
  stub_request(:get, /countriesRegions\(#{test_id}\)/)
84
85
  .to_return(
85
- status: 200,
86
+ status: 200,
86
87
  body: {
87
88
  etag: '2222',
88
89
  code: 'C5',
@@ -92,7 +93,7 @@ class BusinessCentral::Object::CountryRegionTest < Minitest::Test
92
93
 
93
94
  stub_request(:patch, /countriesRegions\(#{test_id}\)/)
94
95
  .to_return(
95
- status: 200,
96
+ status: 200,
96
97
  body: {
97
98
  etag: '2222',
98
99
  code: 'C6',
@@ -102,10 +103,8 @@ class BusinessCentral::Object::CountryRegionTest < Minitest::Test
102
103
 
103
104
  response = @country_region.update(
104
105
  test_id,
105
- {
106
- code: 'C6',
107
- display_name: 'country6'
108
- }
106
+ code: 'C6',
107
+ display_name: 'country6'
109
108
  )
110
109
  assert_equal response[:display_name], 'country6'
111
110
  end
@@ -114,7 +113,7 @@ class BusinessCentral::Object::CountryRegionTest < Minitest::Test
114
113
  test_id = '33333'
115
114
  stub_request(:get, /countriesRegions\(#{test_id}\)/)
116
115
  .to_return(
117
- status: 200,
116
+ status: 200,
118
117
  body: {
119
118
  etag: '3333',
120
119
  code: 'C7',
@@ -127,4 +126,4 @@ class BusinessCentral::Object::CountryRegionTest < Minitest::Test
127
126
 
128
127
  assert @country_region.destroy(test_id)
129
128
  end
130
- end
129
+ end