Class: NewStoreApi::RoutingRuleset1

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/routing_ruleset1.rb

Overview

RoutingRuleset1 Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(location_groups = SKIP, preferred_locations = SKIP, routes = SKIP, sl_levels_priority = SKIP, zip_code_regions = SKIP) ⇒ RoutingRuleset1

Returns a new instance of RoutingRuleset1.



64
65
66
67
68
69
70
71
72
# File 'lib/new_store_api/models/routing_ruleset1.rb', line 64

def initialize(location_groups = SKIP, preferred_locations = SKIP,
               routes = SKIP, sl_levels_priority = SKIP,
               zip_code_regions = SKIP)
  @location_groups = location_groups unless location_groups == SKIP
  @preferred_locations = preferred_locations unless preferred_locations == SKIP
  @routes = routes unless routes == SKIP
  @sl_levels_priority = sl_levels_priority unless sl_levels_priority == SKIP
  @zip_code_regions = zip_code_regions unless zip_code_regions == SKIP
end

Instance Attribute Details

#location_groupsHash[String, Object]

Location groups identifiers

Returns:

  • (Hash[String, Object])


14
15
16
# File 'lib/new_store_api/models/routing_ruleset1.rb', line 14

def location_groups
  @location_groups
end

#preferred_locationsHash[String, Object]

Specifies which locations within each group the routing engine should try first before falling back to the remaining locations in that group. The key is the location group identifier, the value is an ordered list of location IDs to prefer within this group.

Returns:

  • (Hash[String, Object])


21
22
23
# File 'lib/new_store_api/models/routing_ruleset1.rb', line 21

def preferred_locations
  @preferred_locations
end

#routesArray[Routes]

Routing rules specification

Returns:



25
26
27
# File 'lib/new_store_api/models/routing_ruleset1.rb', line 25

def routes
  @routes
end

#sl_levels_priorityArray[String]

Service levels priority. This is ordered according to which service level will be taken first

Returns:

  • (Array[String])


30
31
32
# File 'lib/new_store_api/models/routing_ruleset1.rb', line 30

def sl_levels_priority
  @sl_levels_priority
end

#zip_code_regionsHash[String, Object]

Zip code groups, in order to facilitate the identification routes per regions

Returns:

  • (Hash[String, Object])


35
36
37
# File 'lib/new_store_api/models/routing_ruleset1.rb', line 35

def zip_code_regions
  @zip_code_regions
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/new_store_api/models/routing_ruleset1.rb', line 75

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  location_groups =
    hash.key?('location_groups') ? hash['location_groups'] : SKIP
  preferred_locations =
    hash.key?('preferred_locations') ? hash['preferred_locations'] : SKIP
  # Parameter is an array, so we need to iterate through it
  routes = nil
  unless hash['routes'].nil?
    routes = []
    hash['routes'].each do |structure|
      routes << (Routes.from_hash(structure) if structure)
    end
  end

  routes = SKIP unless hash.key?('routes')
  sl_levels_priority =
    hash.key?('sl_levels_priority') ? hash['sl_levels_priority'] : SKIP
  zip_code_regions =
    hash.key?('zip_code_regions') ? hash['zip_code_regions'] : SKIP

  # Create object from extracted values.
  RoutingRuleset1.new(location_groups,
                      preferred_locations,
                      routes,
                      sl_levels_priority,
                      zip_code_regions)
end

.namesObject

A mapping from model property names to API property names.



38
39
40
41
42
43
44
45
46
# File 'lib/new_store_api/models/routing_ruleset1.rb', line 38

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['location_groups'] = 'location_groups'
  @_hash['preferred_locations'] = 'preferred_locations'
  @_hash['routes'] = 'routes'
  @_hash['sl_levels_priority'] = 'sl_levels_priority'
  @_hash['zip_code_regions'] = 'zip_code_regions'
  @_hash
end

.nullablesObject

An array for nullable fields



60
61
62
# File 'lib/new_store_api/models/routing_ruleset1.rb', line 60

def self.nullables
  []
end

.optionalsObject

An array for optional fields



49
50
51
52
53
54
55
56
57
# File 'lib/new_store_api/models/routing_ruleset1.rb', line 49

def self.optionals
  %w[
    location_groups
    preferred_locations
    routes
    sl_levels_priority
    zip_code_regions
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



115
116
117
118
119
120
# File 'lib/new_store_api/models/routing_ruleset1.rb', line 115

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} location_groups: #{@location_groups.inspect}, preferred_locations:"\
  " #{@preferred_locations.inspect}, routes: #{@routes.inspect}, sl_levels_priority:"\
  " #{@sl_levels_priority.inspect}, zip_code_regions: #{@zip_code_regions.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



107
108
109
110
111
112
# File 'lib/new_store_api/models/routing_ruleset1.rb', line 107

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} location_groups: #{@location_groups}, preferred_locations:"\
  " #{@preferred_locations}, routes: #{@routes}, sl_levels_priority: #{@sl_levels_priority},"\
  " zip_code_regions: #{@zip_code_regions}>"
end