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.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0f72fc6bbd65910d177852470a583d46dd0ec8972df68f3aed670cb0a2ff7f9
|
4
|
+
data.tar.gz: 42984f880fd1d2fa3b72d81ea788e3e1d60b0fec81d1f8bf89c4ed8b2a774592
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee5ff0ec47a550c3a2433b12ab79f6c733f3adc17a0dca4aa83393a0661cc90a0e4351743c937f523af567aef048213e60dfcec7a48c58ab94ab7f25a8a9751d
|
7
|
+
data.tar.gz: 912b7d625087bed194cd73707425089798dec3a09ab048d347842a904f170bb021f770d2826ac1398cda0be3f94f82efd406b56d5088b3bda08fa1b4b87be6c9
|
data/README.md
CHANGED
@@ -26,6 +26,22 @@ This gem supports both authentication methods:
|
|
26
26
|
|
27
27
|
https://docs.microsoft.com/en-us/dynamics-nav/api-reference/v1.0/endpoints-apis-for-dynamics
|
28
28
|
|
29
|
+
```Ruby
|
30
|
+
require 'business_central'
|
31
|
+
|
32
|
+
client = BusinessCentral::Client.new(
|
33
|
+
username: '<username>', # Basic authentication username
|
34
|
+
password: '<password>', # Basic authentication password
|
35
|
+
url: '<url>', # URL for API defaults to https://api.businesscentral.dynamics.com/v2.0/production/api/v1.0
|
36
|
+
web_service_url: '<url>', # URL for custom web services defaults to https://api.businesscentral.dynamics.com/v2.0/production/ODataV4
|
37
|
+
application_id: '<application_id>', # Oauth2 authentication application ID
|
38
|
+
secret_key: '<application_secret_key>', # OAuth2 authentication application secret key
|
39
|
+
oauth2_login_url: '<url>', # OAuth2 authentication login URL defaults to https://login.microsoftonline.com/common
|
40
|
+
default_company_id: '<company_id>', # Default company ID used in all requests (if required)
|
41
|
+
debug: false # Output requests to console
|
42
|
+
)
|
43
|
+
```
|
44
|
+
|
29
45
|
### Basic Authentication:
|
30
46
|
|
31
47
|
https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-develop-connect-apps#setting-up-basic-authentication
|
@@ -36,26 +52,27 @@ require 'business_central'
|
|
36
52
|
client = BusinessCentral::Client.new(
|
37
53
|
username: '<username>',
|
38
54
|
password: '<password>',
|
39
|
-
url: '<url>'
|
55
|
+
url: '<url>',
|
56
|
+
default_company_id: '11111111-2222-3333-4444-555555555555'
|
40
57
|
)
|
41
58
|
|
42
59
|
# Find all vendors
|
43
|
-
vendors = client.vendor
|
60
|
+
vendors = client.vendor.all
|
44
61
|
|
45
62
|
# Find vendor by ID
|
46
|
-
vendor = client.vendor
|
63
|
+
vendor = client.vendor.find('3f445b08-2ffd-4f9d-81a0-b82f0d9714c4')
|
47
64
|
|
48
65
|
# Query vendor by display name
|
49
|
-
vendor = client.vendor
|
66
|
+
vendor = client.vendor.where("displayName eq 'First Up Consultants'")
|
50
67
|
|
51
68
|
# Create a new vendor
|
52
|
-
vendor = client.vendor
|
69
|
+
vendor = client.vendor.create({ display_name: 'hello testing new vendor' })
|
53
70
|
|
54
71
|
# Update an existing vendor by ID
|
55
|
-
vendor = client.vendor
|
72
|
+
vendor = client.vendor.update('3f445b08-2ffd-4f9d-81a0-b82f0d9714c4', { phone_number: '1112' })
|
56
73
|
|
57
74
|
# Delete a vendor
|
58
|
-
client.vendor
|
75
|
+
client.vendor.destroy('f0730ada-b315-ea11-a813-000d3ad21e99')
|
59
76
|
```
|
60
77
|
|
61
78
|
### Oauth2 Authentication
|
@@ -67,10 +84,10 @@ require 'business_central'
|
|
67
84
|
|
68
85
|
# Create client - used to connect to the API
|
69
86
|
client = BusinessCentral::Client.new(
|
70
|
-
tenant_id: '<tenant_id>',
|
71
87
|
application_id: '<application_id>',
|
72
88
|
secret_key: '<application_secret_key>',
|
73
|
-
url: '<url>'
|
89
|
+
url: '<url>',
|
90
|
+
default_company_id: '11111111-2222-3333-4444-555555555555'
|
74
91
|
)
|
75
92
|
|
76
93
|
# Controller endpoint 1
|
@@ -87,22 +104,48 @@ client.authorize_from_token(
|
|
87
104
|
)
|
88
105
|
|
89
106
|
# Find all vendors
|
90
|
-
vendors = client.vendor
|
107
|
+
vendors = client.vendor.all
|
91
108
|
|
92
109
|
# Find vendor by ID
|
93
|
-
vendor = client.vendor
|
110
|
+
vendor = client.vendor.find('3f445b08-2ffd-4f9d-81a0-b82f0d9714c4')
|
94
111
|
|
95
112
|
# Query vendor by display name
|
96
|
-
vendor = client.vendor
|
113
|
+
vendor = client.vendor.where("displayName eq 'First Up Consultants'")
|
97
114
|
|
98
115
|
# Create a new vendor
|
99
|
-
vendor = client.vendor
|
116
|
+
vendor = client.vendor.create({ display_name: 'hello testing' })
|
100
117
|
|
101
118
|
# Update an existing vendor by ID
|
102
|
-
vendor = client.vendor
|
119
|
+
vendor = client.vendor.update('3f445b08-2ffd-4f9d-81a0-b82f0d9714c4', { phone_number: '1112' })
|
103
120
|
|
104
121
|
# Delete a vendor
|
105
|
-
client.vendor
|
122
|
+
client.vendor.destroy('f0730ada-b315-ea11-a813-000d3ad21e99')
|
123
|
+
```
|
124
|
+
|
125
|
+
### OData Web Services
|
126
|
+
|
127
|
+
https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/webservices/odata-web-services
|
128
|
+
|
129
|
+
```Ruby
|
130
|
+
require 'business_central'
|
131
|
+
|
132
|
+
client = BusinessCentral::Client.new(
|
133
|
+
username: '<username>',
|
134
|
+
password: '<password>',
|
135
|
+
web_service_url: '<url>'
|
136
|
+
)
|
137
|
+
|
138
|
+
# Query a record
|
139
|
+
company = client.web_service.object("Company('?')/Purchase_Order", 'My Company').get
|
140
|
+
|
141
|
+
# Create a record
|
142
|
+
client.web_service.object("Company('?')/Purchase_Order", 'My Company').post({})
|
143
|
+
|
144
|
+
# Update a record
|
145
|
+
client.web_service.object("Company('?')/Purchase_Order", 'My Company').patch({})
|
146
|
+
|
147
|
+
# Delete a record
|
148
|
+
client.web_service.object("Company('?')/Purchase_Order", 'My Company').delete
|
106
149
|
```
|
107
150
|
|
108
151
|
## Development
|
@@ -1,26 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BusinessCentral
|
2
4
|
class Client
|
3
|
-
extend BusinessCentral::Object::
|
5
|
+
extend BusinessCentral::Object::ObjectHelper
|
4
6
|
|
5
|
-
|
7
|
+
DEFAULT_LOGIN_URL = 'https://login.microsoftonline.com/common'
|
6
8
|
|
7
|
-
|
9
|
+
DEFAULT_URL = 'https://api.businesscentral.dynamics.com/v2.0/production/api/v1.0'
|
8
10
|
|
9
|
-
attr_reader :
|
10
|
-
:username,
|
11
|
+
attr_reader :username,
|
11
12
|
:password,
|
12
13
|
:application_id,
|
13
14
|
:secret_key,
|
14
15
|
:url,
|
16
|
+
:web_service_url,
|
15
17
|
:oauth2_login_url,
|
16
|
-
:
|
17
|
-
:default_company_id
|
18
|
+
:oauth2_access_token,
|
19
|
+
:default_company_id,
|
20
|
+
:debug
|
18
21
|
|
19
|
-
|
22
|
+
alias access_token oauth2_access_token
|
20
23
|
|
21
24
|
object :account
|
22
25
|
object :aged_account_payable
|
23
26
|
object :aged_account_receivable
|
27
|
+
object :attachment
|
24
28
|
object :balance_sheet
|
25
29
|
object :cash_flow_statement
|
26
30
|
object :company
|
@@ -33,81 +37,107 @@ module BusinessCentral
|
|
33
37
|
object :customer_payment_journal
|
34
38
|
object :customer_sale
|
35
39
|
object :default_dimension
|
36
|
-
object :
|
40
|
+
object :dimension
|
41
|
+
object :dimension_line
|
42
|
+
object :dimension_value
|
43
|
+
object :employee
|
44
|
+
object :general_ledger_entry
|
45
|
+
object :income_statement
|
46
|
+
object :irs1099_code
|
37
47
|
object :purchase_invoice
|
38
48
|
object :purchase_invoice_line
|
39
49
|
object :item
|
50
|
+
object :item_category
|
51
|
+
object :journal
|
52
|
+
object :journal_line
|
53
|
+
object :payment_method
|
54
|
+
object :payment_term
|
55
|
+
object :picture
|
56
|
+
object :retained_earning_statement
|
57
|
+
object :sales_invoice
|
58
|
+
object :sales_invoice_line
|
59
|
+
object :sales_credit_memo
|
60
|
+
object :sales_credit_memo_line
|
61
|
+
object :sales_order
|
62
|
+
object :sales_order_line
|
63
|
+
object :sales_quote
|
64
|
+
object :sales_quote_line
|
65
|
+
object :shipment_method
|
66
|
+
object :subscription
|
67
|
+
object :tax_area
|
68
|
+
object :tax_group
|
69
|
+
object :time_registration_entry
|
70
|
+
object :trial_balance
|
71
|
+
object :units_of_measure
|
72
|
+
object :vendor
|
73
|
+
object :vendor_purchase
|
74
|
+
object :purchase_order
|
40
75
|
|
41
76
|
def initialize(options = {})
|
42
77
|
opts = options.dup
|
43
|
-
@tenant_id = opts.delete(:tenant_id)
|
44
78
|
@username = opts.delete(:username)
|
45
79
|
@password = opts.delete(:password)
|
46
80
|
@url = opts.delete(:url) || DEFAULT_URL
|
81
|
+
@web_service_url = opts.delete(:web_service_url)
|
47
82
|
@application_id = opts.delete(:application_id)
|
48
83
|
@secret_key = opts.delete(:secret_key)
|
49
84
|
@oauth2_login_url = opts.delete(:oauth2_login_url) || DEFAULT_LOGIN_URL
|
50
85
|
@default_company_id = opts.delete(:default_company_id)
|
86
|
+
@debug = opts.delete(:debug) || false
|
51
87
|
end
|
52
88
|
|
53
89
|
def authorize(params = {}, oauth_authorize_callback: '')
|
54
90
|
params[:redirect_uri] = oauth_authorize_callback
|
55
91
|
begin
|
56
92
|
oauth2_client.auth_code.authorize_url(params)
|
57
|
-
rescue OAuth2::Error =>
|
58
|
-
handle_error(
|
93
|
+
rescue OAuth2::Error => e
|
94
|
+
handle_error(e)
|
59
95
|
end
|
60
96
|
end
|
61
97
|
|
62
98
|
def request_token(code = '', oauth_token_callback: '')
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
handle_error(error)
|
67
|
-
end
|
99
|
+
oauth2_client.auth_code.get_token(code, redirect_uri: oauth_token_callback)
|
100
|
+
rescue OAuth2::Error => e
|
101
|
+
handle_error(e)
|
68
102
|
end
|
69
103
|
|
70
104
|
def authorize_from_token(token: '', refresh_token: '', expires_at: nil, expires_in: nil)
|
71
|
-
@
|
105
|
+
@oauth2_access_token = OAuth2::AccessToken.new(
|
72
106
|
oauth2_client,
|
73
107
|
token,
|
74
108
|
refresh_token: refresh_token,
|
75
109
|
expires_at: expires_at,
|
76
|
-
expires_in: expires_in
|
110
|
+
expires_in: expires_in
|
77
111
|
)
|
78
112
|
end
|
79
113
|
|
80
114
|
def refresh_token
|
81
|
-
@
|
115
|
+
@oauth2_access_token.refresh!
|
116
|
+
end
|
117
|
+
|
118
|
+
def web_service
|
119
|
+
@web_service ||= BusinessCentral::WebService.new(client: self, url: web_service_url)
|
82
120
|
end
|
83
121
|
|
84
122
|
private
|
85
123
|
|
86
124
|
def oauth2_client
|
87
|
-
|
88
|
-
@
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
token_url: 'oauth2/token?resource=https://api.businesscentral.dynamics.com'
|
95
|
-
}
|
96
|
-
)
|
97
|
-
end
|
98
|
-
|
99
|
-
return @oauth2_client
|
125
|
+
OAuth2::Client.new(
|
126
|
+
@application_id,
|
127
|
+
@secret_key,
|
128
|
+
site: @oauth2_login_url,
|
129
|
+
authorize_url: 'oauth2/authorize?resource=https://api.businesscentral.dynamics.com',
|
130
|
+
token_url: 'oauth2/token?resource=https://api.businesscentral.dynamics.com'
|
131
|
+
)
|
100
132
|
end
|
101
133
|
|
102
134
|
def handle_error(error)
|
103
|
-
if
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
else
|
109
|
-
raise ApiException.new(error.message)
|
135
|
+
raise ApiException, error.message if error.code.nil?
|
136
|
+
|
137
|
+
case error.code
|
138
|
+
when 'invalid_client'
|
139
|
+
raise InvalidClientException
|
110
140
|
end
|
111
141
|
end
|
112
142
|
end
|
113
|
-
end
|
143
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
module BusinessCentral
|
3
4
|
class BusinessCentralError < StandardError; end
|
4
5
|
|
5
6
|
class InvalidClientException < BusinessCentralError
|
@@ -13,9 +14,7 @@ module BusinessCentral
|
|
13
14
|
@message = message
|
14
15
|
end
|
15
16
|
|
16
|
-
|
17
|
-
@message
|
18
|
-
end
|
17
|
+
attr_reader :message
|
19
18
|
end
|
20
19
|
|
21
20
|
class CompanyNotFoundException < BusinessCentralError
|
@@ -30,15 +29,19 @@ module BusinessCentral
|
|
30
29
|
end
|
31
30
|
end
|
32
31
|
|
32
|
+
class NotFoundException < BusinessCentralError
|
33
|
+
def message
|
34
|
+
'Not Found - The URL provided cannot be found'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
33
38
|
class InvalidObjectException < BusinessCentralError
|
34
39
|
def initialize(errors)
|
35
40
|
@errors = errors
|
36
41
|
end
|
37
42
|
|
38
43
|
def message
|
39
|
-
@errors.each
|
40
|
-
"#{error[:field]} - #{error[:message]}"
|
41
|
-
end
|
44
|
+
@errors.each { |error| "#{error[:field]} - #{error[:message]}" }
|
42
45
|
end
|
43
46
|
end
|
44
47
|
|
@@ -49,7 +52,8 @@ module BusinessCentral
|
|
49
52
|
end
|
50
53
|
|
51
54
|
def message
|
52
|
-
|
55
|
+
methods_allowed = @allowed_methods.join(', ')
|
56
|
+
"#{@method} method is currently not support. Allowed methods are: #{methods_allowed}"
|
53
57
|
end
|
54
58
|
end
|
55
59
|
|
@@ -62,4 +66,10 @@ module BusinessCentral
|
|
62
66
|
"Invalid argument entered - #{@message}"
|
63
67
|
end
|
64
68
|
end
|
65
|
-
|
69
|
+
|
70
|
+
class InvalidObjectURLException < BusinessCentralError
|
71
|
+
def message
|
72
|
+
'Object URL missing for request'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BusinessCentral
|
2
4
|
module Object
|
3
5
|
class AgedAccountPayable < Base
|
4
|
-
OBJECT = 'agedAccountsPayable'
|
6
|
+
OBJECT = 'agedAccountsPayable'
|
5
7
|
|
6
8
|
OBJECT_METHODS = [
|
7
9
|
:get
|
8
10
|
].freeze
|
9
11
|
end
|
10
12
|
end
|
11
|
-
end
|
13
|
+
end
|
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BusinessCentral
|
2
4
|
module Object
|
3
5
|
class AgedAccountReceivable < Base
|
4
|
-
OBJECT = 'agedAccountsReceivable'
|
6
|
+
OBJECT = 'agedAccountsReceivable'
|
5
7
|
|
6
8
|
OBJECT_METHODS = [
|
7
9
|
:get
|
8
10
|
].freeze
|
9
11
|
end
|
10
12
|
end
|
11
|
-
end
|
13
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
module ArgumentHelper
|
6
|
+
def id(argument)
|
7
|
+
return @id if instance_variable_defined?('@id') && !@id.nil?
|
8
|
+
return argument.fetch(:id, '') if !argument.nil?
|
9
|
+
|
10
|
+
nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def company_id(argument)
|
14
|
+
return @client.default_company_id if !@client.default_company_id.nil?
|
15
|
+
return @company_id if instance_variable_defined?('@company_id') && !@company_id.nil?
|
16
|
+
return argument.fetch(:company_id, '') if !argument.nil?
|
17
|
+
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BusinessCentral
|
4
|
+
module Object
|
5
|
+
class Attachment < Base
|
6
|
+
OBJECT = 'attachments'
|
7
|
+
|
8
|
+
OBJECT_METHODS = %i[
|
9
|
+
get
|
10
|
+
post
|
11
|
+
patch
|
12
|
+
delete
|
13
|
+
].freeze
|
14
|
+
|
15
|
+
def update(parent_id:, attachment_id:, **params)
|
16
|
+
url = "#{build_url(child_path: OBJECT)}(parentId=#{parent_id},id=#{attachment_id})/content"
|
17
|
+
Request.call(:patch, @client, url, etag: '', params: {}) do |request|
|
18
|
+
request['Content-Type'] = 'application/json'
|
19
|
+
request['If-Match'] = 'application/json'
|
20
|
+
request.body = Request.convert(params)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def destroy(parent_id:, attachment_id:)
|
25
|
+
url = "#{build_url(child_path: OBJECT)}(#{parent_id},#{attachment_id})"
|
26
|
+
Request.call(:delete, @client, url, etag: '')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|