business-central 1.0.5 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +45 -32
  3. data/lib/business_central/client.rb +7 -52
  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 +10 -37
  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 +5 -1
  13. data/lib/business_central/object/url_builder.rb +16 -12
  14. data/lib/business_central/object/url_helper.rb +16 -2
  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 -55
  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. data/test/business_central/object/response_test.rb +5 -0
  26. data/test/business_central/web_service_test.rb +7 -2
  27. metadata +38 -167
  28. data/lib/business_central/object/account.rb +0 -13
  29. data/lib/business_central/object/aged_account_payable.rb +0 -13
  30. data/lib/business_central/object/aged_account_receivable.rb +0 -13
  31. data/lib/business_central/object/argument_helper.rb +0 -22
  32. data/lib/business_central/object/balance_sheet.rb +0 -13
  33. data/lib/business_central/object/cash_flow_statement.rb +0 -13
  34. data/lib/business_central/object/company.rb +0 -18
  35. data/lib/business_central/object/company_information.rb +0 -14
  36. data/lib/business_central/object/country_region.rb +0 -26
  37. data/lib/business_central/object/currency.rb +0 -29
  38. data/lib/business_central/object/customer.rb +0 -34
  39. data/lib/business_central/object/customer_financial_detail.rb +0 -13
  40. data/lib/business_central/object/customer_payment.rb +0 -43
  41. data/lib/business_central/object/customer_payment_journal.rb +0 -25
  42. data/lib/business_central/object/customer_sale.rb +0 -13
  43. data/lib/business_central/object/default_dimension.rb +0 -51
  44. data/lib/business_central/object/dimension.rb +0 -20
  45. data/lib/business_central/object/dimension_line.rb +0 -37
  46. data/lib/business_central/object/dimension_value.rb +0 -28
  47. data/lib/business_central/object/employee.rb +0 -21
  48. data/lib/business_central/object/general_ledger_entry.rb +0 -13
  49. data/lib/business_central/object/income_statement.rb +0 -13
  50. data/lib/business_central/object/irs1099_code.rb +0 -16
  51. data/lib/business_central/object/item.rb +0 -47
  52. data/lib/business_central/object/item_category.rb +0 -16
  53. data/lib/business_central/object/journal.rb +0 -29
  54. data/lib/business_central/object/journal_line.rb +0 -48
  55. data/lib/business_central/object/payment_method.rb +0 -16
  56. data/lib/business_central/object/payment_term.rb +0 -16
  57. data/lib/business_central/object/purchase_invoice.rb +0 -69
  58. data/lib/business_central/object/purchase_invoice_line.rb +0 -37
  59. data/lib/business_central/object/retained_earning_statement.rb +0 -13
  60. data/lib/business_central/object/sales_credit_memo.rb +0 -20
  61. data/lib/business_central/object/sales_credit_memo_line.rb +0 -30
  62. data/lib/business_central/object/sales_invoice.rb +0 -62
  63. data/lib/business_central/object/sales_invoice_line.rb +0 -30
  64. data/lib/business_central/object/sales_order.rb +0 -20
  65. data/lib/business_central/object/sales_order_line.rb +0 -30
  66. data/lib/business_central/object/sales_quote.rb +0 -20
  67. data/lib/business_central/object/sales_quote_line.rb +0 -30
  68. data/lib/business_central/object/shipment_method.rb +0 -16
  69. data/lib/business_central/object/subscription.rb +0 -16
  70. data/lib/business_central/object/tax_area.rb +0 -16
  71. data/lib/business_central/object/tax_group.rb +0 -16
  72. data/lib/business_central/object/time_registration_entry.rb +0 -16
  73. data/lib/business_central/object/trial_balance.rb +0 -13
  74. data/lib/business_central/object/units_of_measure.rb +0 -16
  75. data/lib/business_central/object/validation.rb +0 -57
  76. data/lib/business_central/object/vendor.rb +0 -42
  77. data/lib/business_central/object/vendor_purchase.rb +0 -13
  78. data/lib/core_ext/string.rb +0 -31
  79. data/test/business_central/object/account_test.rb +0 -67
  80. data/test/business_central/object/aged_account_payable_test.rb +0 -61
  81. data/test/business_central/object/aged_account_receivable_test.rb +0 -61
  82. data/test/business_central/object/balance_sheet_test.rb +0 -61
  83. data/test/business_central/object/cash_flow_statement_test.rb +0 -61
  84. data/test/business_central/object/company_information_test.rb +0 -81
  85. data/test/business_central/object/country_region_test.rb +0 -129
  86. data/test/business_central/object/currency_test.rb +0 -150
  87. data/test/business_central/object/customer_financial_detail_test.rb +0 -68
  88. data/test/business_central/object/customer_payment_journal_test.rb +0 -134
  89. data/test/business_central/object/customer_payment_test.rb +0 -141
  90. data/test/business_central/object/customer_sale_test.rb +0 -72
  91. data/test/business_central/object/customer_test.rb +0 -168
  92. data/test/business_central/object/default_dimension_test.rb +0 -170
  93. data/test/business_central/object/dimension_line_test.rb +0 -165
  94. data/test/business_central/object/dimension_test.rb +0 -65
  95. data/test/business_central/object/dimension_value_test.rb +0 -68
  96. data/test/business_central/object/employee_test.rb +0 -141
  97. data/test/business_central/object/general_ledger_entry_test.rb +0 -82
  98. data/test/business_central/object/income_statement_test.rb +0 -82
  99. data/test/business_central/object/irs1099_code_test.rb +0 -124
  100. data/test/business_central/object/item_category_test.rb +0 -122
  101. data/test/business_central/object/item_test.rb +0 -121
  102. data/test/business_central/object/journal_line_test.rb +0 -152
  103. data/test/business_central/object/journal_test.rb +0 -144
  104. data/test/business_central/object/payment_method_test.rb +0 -134
  105. data/test/business_central/object/payment_term_test.rb +0 -134
  106. data/test/business_central/object/purchase_invoice_line_test.rb +0 -123
  107. data/test/business_central/object/purchase_invoice_test.rb +0 -119
  108. data/test/business_central/object/retained_earning_statement_test.rb +0 -52
  109. data/test/business_central/object/sales_credit_memo_line_test.rb +0 -134
  110. data/test/business_central/object/sales_credit_memo_test.rb +0 -146
  111. data/test/business_central/object/sales_invoice_line_test.rb +0 -164
  112. data/test/business_central/object/sales_invoice_test.rb +0 -156
  113. data/test/business_central/object/sales_order_line_test.rb +0 -134
  114. data/test/business_central/object/sales_order_test.rb +0 -146
  115. data/test/business_central/object/sales_quote_line_test.rb +0 -134
  116. data/test/business_central/object/sales_quote_test.rb +0 -146
  117. data/test/business_central/object/shipment_method_test.rb +0 -133
  118. data/test/business_central/object/subscription_test.rb +0 -126
  119. data/test/business_central/object/tax_area_test.rb +0 -126
  120. data/test/business_central/object/tax_group_test.rb +0 -126
  121. data/test/business_central/object/time_registration_entry_test.rb +0 -126
  122. data/test/business_central/object/trial_balance_test.rb +0 -82
  123. data/test/business_central/object/units_of_measure_test.rb +0 -126
  124. data/test/business_central/object/validation_test.rb +0 -62
  125. data/test/business_central/object/vendor_purchase_test.rb +0 -82
  126. data/test/business_central/object/vendor_test.rb +0 -119
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class DefaultDimension < Base
6
- OBJECT = 'defaultDimensions'
7
-
8
- OBJECT_VALIDATION = {
9
- parent_id: {
10
- required: true
11
- },
12
- dimension_code: {
13
- maximum_length: 20
14
- },
15
- dimension_value_code: {
16
- maximum_length: 20
17
- }
18
- }.freeze
19
-
20
- OBJECT_METHODS = %i[
21
- get
22
- post
23
- patch
24
- delete
25
- ].freeze
26
-
27
- OBJECT_PARENTS = %w[
28
- items
29
- customers
30
- vendors
31
- employees
32
- ].freeze
33
-
34
- def initialize(client, parent:, parent_id:, **args)
35
- return if !valid_parent?(parent)
36
-
37
- super(client, args)
38
- @parent_path << {
39
- path: parent,
40
- id: parent_id
41
- }
42
- @parent_id = parent_id
43
- end
44
-
45
- def create(params = {})
46
- params[:parent_id] = @parent_id
47
- super(params)
48
- end
49
- end
50
- end
51
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class Dimension < Base
6
- OBJECT = 'dimensions'
7
-
8
- OBJECT_VALIDATION = {
9
- code: {
10
- required: true,
11
- maximum_length: 20
12
- }
13
- }.freeze
14
-
15
- OBJECT_METHODS = %i[
16
- get
17
- ].freeze
18
- end
19
- end
20
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class DimensionLine < Base
6
- OBJECT = 'dimensionLines'
7
-
8
- OBJECT_VALIDATION = {
9
- parent_id: {
10
- required: true
11
- },
12
- code: {
13
- maximum_length: 20
14
- },
15
- display_name: {
16
- maximum_length: 30
17
- },
18
- value_id: {
19
- required: true
20
- },
21
- value_code: {
22
- maximum_length: 20
23
- },
24
- value_display_name: {
25
- maximum_length: 50
26
- }
27
- }.freeze
28
-
29
- OBJECT_METHODS = %i[
30
- get
31
- post
32
- patch
33
- delete
34
- ].freeze
35
- end
36
- end
37
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class DimensionValue < Base
6
- OBJECT = 'dimensionValues'
7
-
8
- OBJECT_VALIDATION = {
9
- code: {
10
- required: true,
11
- maximum_length: 20
12
- }
13
- }.freeze
14
-
15
- OBJECT_METHODS = %i[
16
- get
17
- ].freeze
18
-
19
- def initialize(client, dimension_id:, **args)
20
- super(client, args)
21
- @parent_path << {
22
- path: 'dimensions',
23
- id: dimension_id
24
- }
25
- end
26
- end
27
- end
28
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class Employee < Base
6
- extend BusinessCentral::Object::ObjectHelper
7
-
8
- OBJECT = 'employees'
9
-
10
- OBJECT_METHODS = %i[
11
- get
12
- post
13
- patch
14
- delete
15
- ].freeze
16
-
17
- navigation :default_dimension
18
- navigation :picture
19
- end
20
- end
21
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class GeneralLedgerEntry < Base
6
- OBJECT = 'generalLedgerEntries'
7
-
8
- OBJECT_METHODS = %i[
9
- get
10
- ].freeze
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class IncomeStatement < Base
6
- OBJECT = 'incomeStatement'
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 Irs1099Code < Base
6
- OBJECT = 'irs1099Codes'
7
-
8
- OBJECT_METHODS = %i[
9
- get
10
- post
11
- patch
12
- delete
13
- ].freeze
14
- end
15
- end
16
- end
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class Item < Base
6
- extend BusinessCentral::Object::ObjectHelper
7
-
8
- OBJECT = 'items'
9
-
10
- OBJECT_VALIDATION = {
11
- number: {
12
- maximum_length: 20
13
- },
14
- display_name: {
15
- maximum_length: 100
16
- },
17
- type: {
18
- required: true,
19
- inclusive_of: %w[
20
- Inventory
21
- Service
22
- Non-Inventory
23
- ]
24
- },
25
- item_category_code: {
26
- maximum_length: 20
27
- },
28
- gtin: {
29
- maximum_length: 14
30
- },
31
- tax_group_code: {
32
- maximum_length: 20
33
- }
34
- }.freeze
35
-
36
- OBJECT_METHODS = %i[
37
- get
38
- post
39
- patch
40
- delete
41
- ].freeze
42
-
43
- navigation :default_dimension
44
- navigation :picture
45
- end
46
- end
47
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class ItemCategory < Base
6
- OBJECT = 'itemCategories'
7
-
8
- OBJECT_METHODS = %i[
9
- get
10
- post
11
- patch
12
- delete
13
- ].freeze
14
- end
15
- end
16
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class Journal < Base
6
- extend BusinessCentral::Object::ObjectHelper
7
-
8
- OBJECT = 'journals'
9
-
10
- OBJECT_VALIDATION = {
11
- code: {
12
- maximum_length: 10
13
- },
14
- display_name: {
15
- maximum_length: 50
16
- }
17
- }.freeze
18
-
19
- OBJECT_METHODS = %i[
20
- get
21
- post
22
- patch
23
- delete
24
- ].freeze
25
-
26
- navigation :journal_line
27
- end
28
- end
29
- end
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class JournalLine < Base
6
- OBJECT = 'journalLines'
7
-
8
- OBJECT_VALIDATION = {
9
- account_number: {
10
- maximum_length: 20
11
- },
12
- document_number: {
13
- maximum_length: 20
14
- },
15
- external_document_number: {
16
- maximum_length: 20
17
- },
18
- description: {
19
- maximum_length: 50
20
- },
21
- comment: {
22
- maximum_length: 250
23
- }
24
- }.freeze
25
-
26
- OBJECT_METHODS = %i[
27
- get
28
- post
29
- patch
30
- delete
31
- ].freeze
32
-
33
- OBJECT_PARENTS = %w[
34
- journals
35
- ].freeze
36
-
37
- def initialize(client, parent: 'journals', parent_id:, **args)
38
- return if !valid_parent?(parent)
39
-
40
- super(client, args)
41
- @parent_path << {
42
- path: parent,
43
- id: parent_id
44
- }
45
- end
46
- end
47
- end
48
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class PaymentMethod < Base
6
- OBJECT = 'paymentMethods'
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 PaymentTerm < Base
6
- OBJECT = 'paymentTerms'
7
-
8
- OBJECT_METHODS = %i[
9
- get
10
- post
11
- patch
12
- delete
13
- ].freeze
14
- end
15
- end
16
- end
@@ -1,69 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class PurchaseInvoice < Base
6
- OBJECT = 'purchaseInvoices'
7
-
8
- OBJECT_VALIDATION = {
9
- number: {
10
- maximum_length: 20
11
- },
12
- invoice_date: {
13
- date: true
14
- },
15
- vendor_invoice_number: {
16
- maximum_length: 35
17
- },
18
- vendor_number: {
19
- maximum_length: 20
20
- },
21
- vendor_name: {
22
- maximum_length: 50
23
- },
24
- currency_code: {
25
- maximum_length: 10
26
- },
27
- status: {
28
- maximum_length: 20,
29
- inclusion_of: [
30
- 'Draft',
31
- 'In Review',
32
- 'Open',
33
- 'Paid',
34
- 'Canceled',
35
- 'Corrective. Read-Only'
36
- ]
37
- },
38
- payment_terms: {
39
- maximum_length: 10
40
- },
41
- shipment_method: {
42
- maximum_length: 10
43
- },
44
- pay_to_name: {
45
- maximum_length: 100
46
- },
47
- pay_to_contact: {
48
- maximum_length: 100
49
- },
50
- pay_to_vendor_number: {
51
- maximum_length: 20
52
- },
53
- ship_to_name: {
54
- maximum_length: 100
55
- },
56
- ship_to_contact: {
57
- maximum_length: 100
58
- }
59
- }.freeze
60
-
61
- OBJECT_METHODS = %i[
62
- get
63
- post
64
- patch
65
- delete
66
- ].freeze
67
- end
68
- end
69
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class PurchaseInvoiceLine < Base
6
- OBJECT = 'purchaseInvoiceLines'
7
-
8
- OBJECT_VALIDATION = {
9
- line_type: {
10
- inclusion_of: [
11
- 'Comment',
12
- 'Account',
13
- 'Item',
14
- 'Resource',
15
- 'Fixed Asset',
16
- 'Charge'
17
- ]
18
- }
19
- }.freeze
20
-
21
- OBJECT_METHODS = %i[
22
- get
23
- post
24
- patch
25
- delete
26
- ].freeze
27
-
28
- def initialize(client, purchase_invoice_id:, **args)
29
- super(client, args)
30
- @parent_path << {
31
- path: 'purchaseInvoices',
32
- id: purchase_invoice_id
33
- }
34
- end
35
- end
36
- end
37
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class RetainedEarningStatement < Base
6
- OBJECT = 'retainedEarningsStatement'
7
-
8
- OBJECT_METHODS = %i[
9
- get
10
- ].freeze
11
- end
12
- end
13
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class SalesCreditMemo < Base
6
- extend BusinessCentral::Object::ObjectHelper
7
-
8
- OBJECT = 'salesCreditMemos'
9
-
10
- OBJECT_METHODS = %i[
11
- get
12
- post
13
- patch
14
- delete
15
- ].freeze
16
-
17
- navigation :sales_credit_memo_line
18
- end
19
- end
20
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class SalesCreditMemoLine < Base
6
- OBJECT = 'salesCreditMemoLines'
7
-
8
- OBJECT_METHODS = %i[
9
- get
10
- post
11
- patch
12
- delete
13
- ].freeze
14
-
15
- OBJECT_PARENTS = %w[
16
- salesCreditMemos
17
- ].freeze
18
-
19
- def initialize(client, parent: 'salesCreditMemos', parent_id:, **args)
20
- return if !valid_parent?(parent)
21
-
22
- super(client, args)
23
- @parent_path << {
24
- path: parent,
25
- id: parent_id
26
- }
27
- end
28
- end
29
- end
30
- end
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class SalesInvoice < Base
6
- extend BusinessCentral::Object::ObjectHelper
7
-
8
- OBJECT = 'salesInvoices'
9
-
10
- OBJECT_VALIDATION = {
11
- customer_purchase_order_reference: {
12
- maximum_length: 10
13
- },
14
- customer_number: {
15
- maximum_length: 20
16
- },
17
- contact_id: {
18
- maximum_length: 250
19
- },
20
- currency_code: {
21
- maximum_length: 10
22
- },
23
- email: {
24
- maximum_length: 80
25
- },
26
- phone: {
27
- maximum_length: 30
28
- },
29
- payment_terms: {
30
- maximum_length: 10
31
- },
32
- shipment_method: {
33
- maximum_length: 10
34
- },
35
- salesperson: {
36
- maximum_length: 20
37
- },
38
- bill_to_name: {
39
- maximum_length: 100
40
- },
41
- bill_to_customer_number: {
42
- maximum_length: 20
43
- },
44
- ship_to_name: {
45
- maximum_length: 100
46
- },
47
- ship_to_contact: {
48
- maximum_length: 100
49
- }
50
- }.freeze
51
-
52
- OBJECT_METHODS = %i[
53
- get
54
- post
55
- patch
56
- delete
57
- ].freeze
58
-
59
- navigation :sales_invoice_line
60
- end
61
- end
62
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class SalesInvoiceLine < Base
6
- OBJECT = 'salesInvoiceLines'
7
-
8
- OBJECT_METHODS = %i[
9
- get
10
- post
11
- patch
12
- delete
13
- ].freeze
14
-
15
- OBJECT_PARENTS = %w[
16
- salesInvoices
17
- ].freeze
18
-
19
- def initialize(client, parent: 'salesInvoices', parent_id:, **args)
20
- return if !valid_parent?(parent)
21
-
22
- super(client, args)
23
- @parent_path << {
24
- path: parent,
25
- id: parent_id
26
- }
27
- end
28
- end
29
- end
30
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BusinessCentral
4
- module Object
5
- class SalesOrder < Base
6
- extend BusinessCentral::Object::ObjectHelper
7
-
8
- OBJECT = 'salesOrders'
9
-
10
- OBJECT_METHODS = %i[
11
- get
12
- post
13
- patch
14
- delete
15
- ].freeze
16
-
17
- navigation :sales_order_line
18
- end
19
- end
20
- end