Class: BusinessCentral::URLBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/business_central/url_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent_path, parent_id, options = {}) ⇒ URLBuilder

Returns a new instance of URLBuilder.

Parameters:

  • parent_path (String)

    The path for the parent object

  • parent_id (String)

    The object ID

  • options (Hash) (defaults to: {})

    any associated child object



15
16
17
18
19
20
21
22
23
# File 'lib/business_central/url_builder.rb', line 15

def initialize(parent_path, parent_id, options = {})
  @url = ""
  @parent_path = parent_path
  @parent_id = parent_id
  @child_path = options.fetch(:child_path, nil)
  @child_id = options.fetch(:child_id, nil)
  @sequence = options.fetch(:sequence, nil)
  build
end

Instance Attribute Details

#child_idObject (readonly)

Returns the value of attribute child_id.



9
10
11
# File 'lib/business_central/url_builder.rb', line 9

def child_id
  @child_id
end

#child_pathObject (readonly)

Returns the value of attribute child_path.



9
10
11
# File 'lib/business_central/url_builder.rb', line 9

def child_path
  @child_path
end

#parent_idObject (readonly)

Returns the value of attribute parent_id.



8
9
10
# File 'lib/business_central/url_builder.rb', line 8

def parent_id
  @parent_id
end

#parent_pathObject (readonly)

Returns the value of attribute parent_path.



8
9
10
# File 'lib/business_central/url_builder.rb', line 8

def parent_path
  @parent_path
end

#sequenceObject (readonly)

Returns the value of attribute sequence.



9
10
11
# File 'lib/business_central/url_builder.rb', line 9

def sequence
  @sequence
end

#urlObject (readonly)

Returns the value of attribute url.



7
8
9
# File 'lib/business_central/url_builder.rb', line 7

def url
  @url
end

Instance Method Details

#buildObject

Creates the URL string from the provided options



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

def build
  @url = "/#{@parent_path}(#{@parent_id})"
  @url += "/#{@child_path}" unless @child_path.nil?
  @url += "(#{@child_id})" unless @child_id.nil?
end