business-central 1.0.3 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +58 -15
- data/lib/business_central/client.rb +71 -41
- data/lib/business_central/exceptions.rb +19 -9
- data/lib/business_central/object/account.rb +4 -2
- data/lib/business_central/object/aged_account_payable.rb +4 -2
- data/lib/business_central/object/aged_account_receivable.rb +4 -2
- data/lib/business_central/object/argument_helper.rb +22 -0
- data/lib/business_central/object/attachment.rb +30 -0
- data/lib/business_central/object/balance_sheet.rb +4 -2
- data/lib/business_central/object/base.rb +90 -56
- data/lib/business_central/object/cash_flow_statement.rb +4 -2
- data/lib/business_central/object/company.rb +5 -3
- data/lib/business_central/object/company_information.rb +7 -5
- data/lib/business_central/object/country_region.rb +8 -6
- data/lib/business_central/object/currency.rb +8 -6
- data/lib/business_central/object/customer.rb +16 -9
- data/lib/business_central/object/customer_financial_detail.rb +3 -1
- data/lib/business_central/object/customer_payment.rb +8 -6
- data/lib/business_central/object/customer_payment_journal.rb +8 -6
- data/lib/business_central/object/customer_sale.rb +3 -1
- data/lib/business_central/object/default_dimension.rb +18 -21
- data/lib/business_central/object/dimension.rb +20 -0
- data/lib/business_central/object/dimension_line.rb +37 -0
- data/lib/business_central/object/dimension_value.rb +28 -0
- data/lib/business_central/object/employee.rb +21 -0
- data/lib/business_central/object/filter_query.rb +18 -0
- data/lib/business_central/object/general_ledger_entry.rb +13 -0
- data/lib/business_central/object/income_statement.rb +13 -0
- data/lib/business_central/object/irs1099_code.rb +16 -0
- data/lib/business_central/object/item.rb +17 -10
- data/lib/business_central/object/item_category.rb +16 -0
- data/lib/business_central/object/journal.rb +29 -0
- data/lib/business_central/object/journal_line.rb +48 -0
- data/lib/business_central/object/{helper.rb → object_helper.rb} +18 -10
- data/lib/business_central/object/payment_method.rb +16 -0
- data/lib/business_central/object/payment_term.rb +16 -0
- data/lib/business_central/object/picture.rb +53 -0
- data/lib/business_central/object/purchase_invoice.rb +8 -6
- data/lib/business_central/object/purchase_invoice_line.rb +10 -8
- data/lib/business_central/object/purchase_order.rb +16 -0
- data/lib/business_central/object/request.rb +60 -49
- data/lib/business_central/object/response.rb +31 -23
- data/lib/business_central/object/retained_earning_statement.rb +13 -0
- data/lib/business_central/object/sales_credit_memo.rb +20 -0
- data/lib/business_central/object/sales_credit_memo_line.rb +30 -0
- data/lib/business_central/object/sales_invoice.rb +62 -0
- data/lib/business_central/object/sales_invoice_line.rb +30 -0
- data/lib/business_central/object/sales_order.rb +20 -0
- data/lib/business_central/object/sales_order_line.rb +30 -0
- data/lib/business_central/object/sales_quote.rb +20 -0
- data/lib/business_central/object/sales_quote_line.rb +30 -0
- data/lib/business_central/object/shipment_method.rb +16 -0
- data/lib/business_central/object/subscription.rb +16 -0
- data/lib/business_central/object/tax_area.rb +16 -0
- data/lib/business_central/object/tax_group.rb +16 -0
- data/lib/business_central/object/time_registration_entry.rb +16 -0
- data/lib/business_central/object/trial_balance.rb +13 -0
- data/lib/business_central/object/units_of_measure.rb +16 -0
- data/lib/business_central/object/url_builder.rb +59 -0
- data/lib/business_central/object/url_helper.rb +44 -0
- data/lib/business_central/object/validation.rb +10 -7
- data/lib/business_central/object/vendor.rb +10 -7
- data/lib/business_central/object/vendor_purchase.rb +13 -0
- data/lib/business_central/version.rb +4 -2
- data/lib/business_central/web_service.rb +78 -0
- data/lib/business_central.rb +40 -2
- data/lib/core_ext/string.rb +18 -12
- data/test/business_central/client_test.rb +18 -11
- data/test/business_central/object/account_test.rb +6 -5
- data/test/business_central/object/aged_account_payable_test.rb +6 -5
- data/test/business_central/object/aged_account_receivable_test.rb +6 -5
- data/test/business_central/object/attachment_test.rb +117 -0
- data/test/business_central/object/balance_sheet_test.rb +6 -5
- data/test/business_central/object/base_test.rb +4 -2
- data/test/business_central/object/cash_flow_statement_test.rb +6 -5
- data/test/business_central/object/company_information_test.rb +9 -10
- data/test/business_central/object/company_test.rb +6 -5
- data/test/business_central/object/country_region_test.rb +16 -17
- data/test/business_central/object/currency_test.rb +17 -18
- data/test/business_central/object/customer_financial_detail_test.rb +8 -6
- data/test/business_central/object/customer_payment_journal_test.rb +14 -15
- data/test/business_central/object/customer_payment_test.rb +15 -16
- data/test/business_central/object/customer_sale_test.rb +8 -6
- data/test/business_central/object/customer_test.rb +59 -16
- data/test/business_central/object/default_dimension_test.rb +15 -16
- data/test/business_central/object/dimension_line_test.rb +165 -0
- data/test/business_central/object/dimension_test.rb +65 -0
- data/test/business_central/object/dimension_value_test.rb +68 -0
- data/test/business_central/object/employee_test.rb +141 -0
- data/test/business_central/object/filter_query_test.rb +36 -0
- data/test/business_central/object/general_ledger_entry_test.rb +82 -0
- data/test/business_central/object/income_statement_test.rb +82 -0
- data/test/business_central/object/irs1099_code_test.rb +124 -0
- data/test/business_central/object/item_category_test.rb +122 -0
- data/test/business_central/object/item_test.rb +16 -17
- data/test/business_central/object/journal_line_test.rb +152 -0
- data/test/business_central/object/journal_test.rb +144 -0
- data/test/business_central/object/payment_method_test.rb +134 -0
- data/test/business_central/object/payment_term_test.rb +134 -0
- data/test/business_central/object/picture_test.rb +74 -0
- data/test/business_central/object/purchase_invoice_line_test.rb +15 -15
- data/test/business_central/object/purchase_invoice_test.rb +15 -15
- data/test/business_central/object/request_test.rb +17 -9
- data/test/business_central/object/response_test.rb +14 -7
- data/test/business_central/object/retained_earning_statement_test.rb +52 -0
- data/test/business_central/object/sales_credit_memo_line_test.rb +134 -0
- data/test/business_central/object/sales_credit_memo_test.rb +146 -0
- data/test/business_central/object/sales_invoice_line_test.rb +164 -0
- data/test/business_central/object/sales_invoice_test.rb +156 -0
- data/test/business_central/object/sales_order_line_test.rb +134 -0
- data/test/business_central/object/sales_order_test.rb +146 -0
- data/test/business_central/object/sales_quote_line_test.rb +134 -0
- data/test/business_central/object/sales_quote_test.rb +146 -0
- data/test/business_central/object/shipment_method_test.rb +133 -0
- data/test/business_central/object/subscription_test.rb +126 -0
- data/test/business_central/object/tax_area_test.rb +126 -0
- data/test/business_central/object/tax_group_test.rb +126 -0
- data/test/business_central/object/time_registration_entry_test.rb +126 -0
- data/test/business_central/object/trial_balance_test.rb +82 -0
- data/test/business_central/object/units_of_measure_test.rb +126 -0
- data/test/business_central/object/validation_test.rb +5 -4
- data/test/business_central/object/vendor_purchase_test.rb +82 -0
- data/test/business_central/object/vendor_test.rb +16 -16
- data/test/business_central/web_service_test.rb +100 -0
- data/test/business_central_test.rb +3 -1
- data/test/test_helper.rb +12 -6
- metadata +153 -41
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BusinessCentral
|
2
4
|
module Object
|
3
5
|
class Base
|
4
|
-
|
5
|
-
|
6
|
-
|
6
|
+
include ArgumentHelper
|
7
|
+
|
8
|
+
attr_reader :client, :parent_path, :path
|
7
9
|
|
8
10
|
attr_writer :id, :company_id
|
9
11
|
|
@@ -19,71 +21,107 @@ module BusinessCentral
|
|
19
21
|
]
|
20
22
|
end
|
21
23
|
|
22
|
-
def id(argument)
|
23
|
-
return @id if !@id.nil?
|
24
|
-
return argument.fetch(:id, '') if !argument.nil?
|
25
|
-
return nil
|
26
|
-
end
|
27
|
-
|
28
|
-
def company_id(argument)
|
29
|
-
return @client.default_company_id if !@client.default_company_id.nil?
|
30
|
-
return @company_id if !@company_id.nil?
|
31
|
-
return argument.fetch(:company_id, '') if !argument.nil?
|
32
|
-
return nil
|
33
|
-
end
|
34
|
-
|
35
24
|
def find_all
|
36
|
-
if method_supported?(:get)
|
37
|
-
Request.get(@client, build_url(parent_path: @parent_path, child_path: object_name))
|
38
|
-
else
|
25
|
+
if !method_supported?(:get)
|
39
26
|
raise BusinessCentral::NoSupportedMethod.new(:get, object_methods)
|
40
27
|
end
|
28
|
+
|
29
|
+
Request.get(@client, build_url(parent_path: @parent_path, child_path: object_name))
|
41
30
|
end
|
31
|
+
alias all find_all
|
42
32
|
|
43
33
|
def find_by_id(id)
|
44
|
-
if method_supported?(:get)
|
45
|
-
Request.get(@client, build_url(parent_path: @parent_path, child_path: object_name, child_id: id))
|
46
|
-
else
|
34
|
+
if !method_supported?(:get)
|
47
35
|
raise BusinessCentral::NoSupportedMethod.new(:get, object_methods)
|
48
36
|
end
|
37
|
+
|
38
|
+
Request.get(
|
39
|
+
@client,
|
40
|
+
build_url(
|
41
|
+
parent_path: @parent_path,
|
42
|
+
child_path: object_name,
|
43
|
+
child_id: id
|
44
|
+
)
|
45
|
+
)
|
49
46
|
end
|
47
|
+
alias find find_by_id
|
50
48
|
|
51
|
-
def where(query = '')
|
52
|
-
if method_supported?(:get)
|
53
|
-
Request.get(@client, build_url(parent_path: @parent_path, child_path: object_name, filter: query))
|
54
|
-
else
|
49
|
+
def where(query = '', *values)
|
50
|
+
if !method_supported?(:get)
|
55
51
|
raise BusinessCentral::NoSupportedMethod.new(:get, object_methods)
|
56
52
|
end
|
53
|
+
|
54
|
+
Request.get(
|
55
|
+
@client,
|
56
|
+
build_url(
|
57
|
+
parent_path: @parent_path,
|
58
|
+
child_path: object_name,
|
59
|
+
filter: FilterQuery.sanitize(query, values)
|
60
|
+
)
|
61
|
+
)
|
57
62
|
end
|
58
63
|
|
59
64
|
def create(params = {})
|
60
|
-
if method_supported?(:post)
|
61
|
-
if Validation.new(object_validation, params).valid?
|
62
|
-
Request.post(@client, build_url(parent_path: @parent_path, child_path: object_name), params)
|
63
|
-
end
|
64
|
-
else
|
65
|
+
if !method_supported?(:post)
|
65
66
|
raise BusinessCentral::NoSupportedMethod.new(:post, object_methods)
|
66
67
|
end
|
68
|
+
|
69
|
+
Validation.new(object_validation, params).valid?
|
70
|
+
Request.post(@client, build_url(parent_path: @parent_path, child_path: object_name), params)
|
67
71
|
end
|
68
72
|
|
69
73
|
def update(id, params = {})
|
70
|
-
if method_supported?(:patch)
|
71
|
-
object = find_by_id(id).merge(params)
|
72
|
-
if Validation.new(object_validation, object).valid?
|
73
|
-
Request.patch(@client, build_url(parent_path: @parent_path, child_path: object_name, child_id: id), object[:etag], object)
|
74
|
-
end
|
75
|
-
else
|
74
|
+
if !method_supported?(:patch)
|
76
75
|
raise BusinessCentral::NoSupportedMethod.new(:patch, object_methods)
|
77
76
|
end
|
77
|
+
|
78
|
+
object = find_by_id(id).merge(params)
|
79
|
+
Validation.new(object_validation, object).valid?
|
80
|
+
Request.patch(
|
81
|
+
@client,
|
82
|
+
build_url(
|
83
|
+
parent_path: @parent_path,
|
84
|
+
child_path: object_name,
|
85
|
+
child_id: id
|
86
|
+
),
|
87
|
+
object[:etag],
|
88
|
+
params
|
89
|
+
)
|
78
90
|
end
|
79
91
|
|
80
92
|
def destroy(id)
|
81
|
-
if method_supported?(:delete)
|
82
|
-
object = find_by_id(id)
|
83
|
-
Request.delete(@client, build_url(parent_path: @parent_path, child_path: object_name, child_id: id), object[:etag])
|
84
|
-
else
|
93
|
+
if !method_supported?(:delete)
|
85
94
|
raise BusinessCentral::NoSupportedMethod.new(:delete, object_methods)
|
86
95
|
end
|
96
|
+
|
97
|
+
object = find_by_id(id)
|
98
|
+
Request.delete(
|
99
|
+
@client,
|
100
|
+
build_url(
|
101
|
+
parent_path: @parent_path,
|
102
|
+
child_path: object_name,
|
103
|
+
child_id: id
|
104
|
+
),
|
105
|
+
object[:etag]
|
106
|
+
)
|
107
|
+
end
|
108
|
+
|
109
|
+
protected
|
110
|
+
|
111
|
+
def valid_parent?(parent)
|
112
|
+
return true if object_parent_name.map(&:downcase).include?(parent.downcase)
|
113
|
+
|
114
|
+
raise InvalidArgumentException, "parents allowed: #{object_parent_name.join(', ')}"
|
115
|
+
end
|
116
|
+
|
117
|
+
def build_url(parent_path: [], child_path: '', child_id: '', filter: '')
|
118
|
+
URLBuilder.new(
|
119
|
+
base_url: client.url,
|
120
|
+
parent_path: parent_path,
|
121
|
+
child_path: child_path,
|
122
|
+
child_id: child_id,
|
123
|
+
filter: filter
|
124
|
+
).build
|
87
125
|
end
|
88
126
|
|
89
127
|
private
|
@@ -93,30 +131,26 @@ module BusinessCentral
|
|
93
131
|
end
|
94
132
|
|
95
133
|
def object_validation
|
96
|
-
self.class.const_defined?(:OBJECT_VALIDATION)
|
134
|
+
if self.class.const_defined?(:OBJECT_VALIDATION)
|
135
|
+
self.class.const_get(:OBJECT_VALIDATION)
|
136
|
+
else
|
137
|
+
[]
|
138
|
+
end
|
97
139
|
end
|
98
140
|
|
99
141
|
def object_methods
|
100
142
|
self.class.const_get(:OBJECT_METHODS)
|
101
143
|
end
|
102
144
|
|
103
|
-
def
|
104
|
-
|
105
|
-
return false
|
145
|
+
def object_parent_name
|
146
|
+
self.class.const_get(:OBJECT_PARENTS)
|
106
147
|
end
|
107
148
|
|
108
|
-
def
|
109
|
-
|
110
|
-
end
|
149
|
+
def method_supported?(method)
|
150
|
+
return true if object_methods.include?(method)
|
111
151
|
|
112
|
-
|
113
|
-
url = @client.url
|
114
|
-
url += parent_path.map { |parent| "/#{parent[:path]}(#{parent[:id]})" }.join('') if !parent_path.empty?
|
115
|
-
url += "/#{child_path}" if !child_path.to_s.blank?
|
116
|
-
url += "(#{child_id})" if !child_id.to_s.blank?
|
117
|
-
url += "?$filter=#{CGI::escape(filter)}" if !filter.to_s.blank?
|
118
|
-
return url
|
152
|
+
false
|
119
153
|
end
|
120
154
|
end
|
121
155
|
end
|
122
|
-
end
|
156
|
+
end
|
@@ -1,16 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BusinessCentral
|
2
4
|
module Object
|
3
5
|
class Company < Base
|
4
|
-
OBJECT = 'companies'
|
6
|
+
OBJECT = 'companies'
|
5
7
|
|
6
8
|
OBJECT_METHODS = [
|
7
9
|
:get
|
8
10
|
].freeze
|
9
11
|
|
10
|
-
def initialize(client,
|
12
|
+
def initialize(client, _args)
|
11
13
|
super(client)
|
12
14
|
@parent_path = []
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
16
|
-
end
|
18
|
+
end
|
@@ -1,12 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BusinessCentral
|
2
4
|
module Object
|
3
5
|
class CompanyInformation < Base
|
4
|
-
OBJECT = 'companyInformation'
|
6
|
+
OBJECT = 'companyInformation'
|
5
7
|
|
6
|
-
OBJECT_METHODS = [
|
7
|
-
|
8
|
-
|
8
|
+
OBJECT_METHODS = %i[
|
9
|
+
get
|
10
|
+
patch
|
9
11
|
].freeze
|
10
12
|
end
|
11
13
|
end
|
12
|
-
end
|
14
|
+
end
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BusinessCentral
|
2
4
|
module Object
|
3
5
|
class CountryRegion < Base
|
4
|
-
OBJECT = 'countriesRegions'
|
6
|
+
OBJECT = 'countriesRegions'
|
5
7
|
|
6
8
|
OBJECT_VALIDATION = {
|
7
9
|
code: {
|
@@ -13,11 +15,11 @@ module BusinessCentral
|
|
13
15
|
}
|
14
16
|
}.freeze
|
15
17
|
|
16
|
-
OBJECT_METHODS = [
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
OBJECT_METHODS = %i[
|
19
|
+
get
|
20
|
+
post
|
21
|
+
patch
|
22
|
+
delete
|
21
23
|
].freeze
|
22
24
|
end
|
23
25
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BusinessCentral
|
2
4
|
module Object
|
3
5
|
class Currency < Base
|
4
|
-
OBJECT = 'currencies'
|
6
|
+
OBJECT = 'currencies'
|
5
7
|
|
6
8
|
OBJECT_VALIDATION = {
|
7
9
|
code: {
|
@@ -16,11 +18,11 @@ module BusinessCentral
|
|
16
18
|
}
|
17
19
|
}.freeze
|
18
20
|
|
19
|
-
OBJECT_METHODS = [
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
OBJECT_METHODS = %i[
|
22
|
+
get
|
23
|
+
post
|
24
|
+
patch
|
25
|
+
delete
|
24
26
|
].freeze
|
25
27
|
end
|
26
28
|
end
|
@@ -1,7 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BusinessCentral
|
2
4
|
module Object
|
3
5
|
class Customer < Base
|
4
|
-
|
6
|
+
extend BusinessCentral::Object::ObjectHelper
|
7
|
+
|
8
|
+
OBJECT = 'customers'
|
5
9
|
|
6
10
|
OBJECT_VALIDATION = {
|
7
11
|
display_name: {
|
@@ -9,19 +13,22 @@ module BusinessCentral
|
|
9
13
|
maximum_length: 100
|
10
14
|
},
|
11
15
|
type: {
|
12
|
-
inclusion_of: [
|
13
|
-
|
14
|
-
|
16
|
+
inclusion_of: %w[
|
17
|
+
Company
|
18
|
+
Person
|
15
19
|
]
|
16
20
|
}
|
17
21
|
}.freeze
|
18
22
|
|
19
|
-
OBJECT_METHODS = [
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
OBJECT_METHODS = %i[
|
24
|
+
get
|
25
|
+
post
|
26
|
+
patch
|
27
|
+
delete
|
24
28
|
].freeze
|
29
|
+
|
30
|
+
navigation :default_dimension
|
31
|
+
navigation :picture
|
25
32
|
end
|
26
33
|
end
|
27
34
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BusinessCentral
|
2
4
|
module Object
|
3
5
|
class CustomerPayment < Base
|
4
|
-
OBJECT = 'customerPayments'
|
6
|
+
OBJECT = 'customerPayments'
|
5
7
|
|
6
8
|
OBJECT_VALIDATION = {
|
7
9
|
customer_number: {
|
@@ -30,11 +32,11 @@ module BusinessCentral
|
|
30
32
|
}
|
31
33
|
}.freeze
|
32
34
|
|
33
|
-
OBJECT_METHODS = [
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
OBJECT_METHODS = %i[
|
36
|
+
get
|
37
|
+
post
|
38
|
+
patch
|
39
|
+
delete
|
38
40
|
].freeze
|
39
41
|
end
|
40
42
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BusinessCentral
|
2
4
|
module Object
|
3
5
|
class CustomerPaymentJournal < Base
|
4
|
-
OBJECT = 'customerPaymentJournals'
|
6
|
+
OBJECT = 'customerPaymentJournals'
|
5
7
|
|
6
8
|
OBJECT_VALIDATION = {
|
7
9
|
code: {
|
@@ -12,11 +14,11 @@ module BusinessCentral
|
|
12
14
|
}
|
13
15
|
}.freeze
|
14
16
|
|
15
|
-
OBJECT_METHODS = [
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
OBJECT_METHODS = %i[
|
18
|
+
get
|
19
|
+
post
|
20
|
+
patch
|
21
|
+
delete
|
20
22
|
].freeze
|
21
23
|
end
|
22
24
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BusinessCentral
|
2
4
|
module Object
|
3
5
|
class DefaultDimension < Base
|
4
|
-
OBJECT = 'defaultDimensions'
|
6
|
+
OBJECT = 'defaultDimensions'
|
5
7
|
|
6
8
|
OBJECT_VALIDATION = {
|
7
9
|
parent_id: {
|
@@ -15,25 +17,26 @@ module BusinessCentral
|
|
15
17
|
}
|
16
18
|
}.freeze
|
17
19
|
|
18
|
-
OBJECT_METHODS = [
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
OBJECT_METHODS = %i[
|
21
|
+
get
|
22
|
+
post
|
23
|
+
patch
|
24
|
+
delete
|
23
25
|
].freeze
|
24
26
|
|
25
|
-
OBJECT_PARENTS = [
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
OBJECT_PARENTS = %w[
|
28
|
+
items
|
29
|
+
customers
|
30
|
+
vendors
|
31
|
+
employees
|
30
32
|
].freeze
|
31
33
|
|
32
|
-
def initialize(client,
|
33
|
-
|
34
|
-
|
34
|
+
def initialize(client, parent:, parent_id:, **args)
|
35
|
+
return if !valid_parent?(parent)
|
36
|
+
|
37
|
+
super(client, args)
|
35
38
|
@parent_path << {
|
36
|
-
path: parent
|
39
|
+
path: parent,
|
37
40
|
id: parent_id
|
38
41
|
}
|
39
42
|
@parent_id = parent_id
|
@@ -43,12 +46,6 @@ module BusinessCentral
|
|
43
46
|
params[:parent_id] = @parent_id
|
44
47
|
super(params)
|
45
48
|
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
def valid_parent?(parent)
|
50
|
-
OBJECT_PARENTS.include?(parent.downcase)
|
51
|
-
end
|
52
49
|
end
|
53
50
|
end
|
54
51
|
end
|
@@ -0,0 +1,20 @@
|
|
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
|
@@ -0,0 +1,37 @@
|
|
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
|
@@ -0,0 +1,28 @@
|
|
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
|
@@ -0,0 +1,21 @@
|
|
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
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
class FilterQuery
|
6
|
+
extend URLHelper
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def sanitize(query = '', values = [])
|
10
|
+
return encode_url_params(query) if values.length.zero?
|
11
|
+
|
12
|
+
query = replace_template_with_value(query, values)
|
13
|
+
encode_url_params(query)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|