Class: BusinessCentral::Object::URLBuilder

Inherits:
Object
  • Object
show all
Extended by:
URLHelper
Defined in:
lib/business_central/object/url_builder.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from URLHelper

encode_url_object, encode_url_params, odata_encode

Constructor Details

#initialize(base_url:, object_path: [], object_id: '', object_code: '', filter: '') ⇒ URLBuilder

Returns a new instance of URLBuilder.



19
20
21
22
23
24
25
# File 'lib/business_central/object/url_builder.rb', line 19

def initialize(base_url:, object_path: [], object_id: '', object_code: '', filter: '')
  @base_url = base_url.to_s
  @object_path = object_path || []
  @object_id = object_id.to_s
  @object_code = object_code.to_s
  @filter = filter.to_s
end

Class Method Details

.sanitize(query = '', values = []) ⇒ Object



11
12
13
14
15
16
# File 'lib/business_central/object/url_builder.rb', line 11

def sanitize(query = '', values = [])
  return encode_url_params(query) if values.length.zero?

  query = replace_template_with_value(query, values)
  encode_url_object(query)
end

Instance Method Details

#buildObject



27
28
29
30
31
32
33
# File 'lib/business_central/object/url_builder.rb', line 27

def build
  url = @base_url
  url += build_parent_path
  url += build_child_path
  url += build_filter
  url
end