Class: BusinessCentral::WebService
- Inherits:
-
Object
- Object
- BusinessCentral::WebService
- Defined in:
- lib/business_central/web_service.rb
Constant Summary collapse
- DEFAULT_URL =
'https://api.businesscentral.dynamics.com/v2.0/production/ODataV4'
Instance Attribute Summary collapse
-
#object_url ⇒ Object
readonly
Returns the value of attribute object_url.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #delete ⇒ Object
- #get(query = '', *values) ⇒ Object
-
#initialize(client:, **options) ⇒ WebService
constructor
A new instance of WebService.
- #object(object_url = '', *values) ⇒ Object
- #patch(params = {}) ⇒ Object
- #post(params = {}) ⇒ Object
Constructor Details
#initialize(client:, **options) ⇒ WebService
Returns a new instance of WebService.
11 12 13 14 15 |
# File 'lib/business_central/web_service.rb', line 11 def initialize(client:, **) @client = client opts = .dup @url = opts.delete(:url) || DEFAULT_URL end |
Instance Attribute Details
#object_url ⇒ Object (readonly)
Returns the value of attribute object_url.
9 10 11 |
# File 'lib/business_central/web_service.rb', line 9 def object_url @object_url end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
9 10 11 |
# File 'lib/business_central/web_service.rb', line 9 def url @url end |
Instance Method Details
#delete ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/business_central/web_service.rb', line 60 def delete raise InvalidObjectURLException if @object_url.to_s.blank? object = get Object::Request.delete( @client, build_url, object[:etag] ) end |
#get(query = '', *values) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/business_central/web_service.rb', line 27 def get(query = '', *values) raise InvalidObjectURLException if @object_url.to_s.blank? Object::Request.get( @client, build_url( filter: Object::FilterQuery.sanitize(query, values) ) ) end |
#object(object_url = '', *values) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/business_central/web_service.rb', line 17 def object(object_url = '', *values) if values.length.zero? @object_url = object_url return self end @object_url = Object::URLBuilder.sanitize(object_url, values) self end |
#patch(params = {}) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/business_central/web_service.rb', line 48 def patch(params = {}) raise InvalidObjectURLException if @object_url.to_s.blank? object = get Object::Request.patch( @client, build_url, object[:etag], params ) end |
#post(params = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/business_central/web_service.rb', line 38 def post(params = {}) raise InvalidObjectURLException if @object_url.to_s.blank? Object::Request.post( @client, build_url, params ) end |