Class: NewStoreApi::FulfillmentConfigRoutingRules

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

Overview

Mirrors fulfillment_config FulfillmentConfigRoutingRules (routing ruleset).

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 = nil, routes = nil, sl_levels_priority = nil, zip_code_regions = nil, preferred_locations = SKIP) ⇒ FulfillmentConfigRoutingRules

Returns a new instance of FulfillmentConfigRoutingRules.



58
59
60
61
62
63
64
65
66
# File 'lib/new_store_api/models/fulfillment_config_routing_rules.rb', line 58

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

Instance Attribute Details

#location_groupsHash[String, Object]

Location group identifiers mapped to ordered location IDs.

Returns:

  • (Hash[String, Object])


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

def location_groups
  @location_groups
end

#preferred_locationsHash[String, Object]

Preferred location IDs within each location group, tried before others in the group.

Returns:

  • (Hash[String, Object])


19
20
21
# File 'lib/new_store_api/models/fulfillment_config_routing_rules.rb', line 19

def preferred_locations
  @preferred_locations
end

#routesArray[FulfillmentConfigRoute]

Routing rules specification.

Returns:



23
24
25
# File 'lib/new_store_api/models/fulfillment_config_routing_rules.rb', line 23

def routes
  @routes
end

#sl_levels_priorityArray[String]

Service levels in priority order (first is preferred).

Returns:

  • (Array[String])


27
28
29
# File 'lib/new_store_api/models/fulfillment_config_routing_rules.rb', line 27

def sl_levels_priority
  @sl_levels_priority
end

#zip_code_regionsHash[String, Object]

Zip code region identifiers mapped to zip code patterns.

Returns:

  • (Hash[String, Object])


31
32
33
# File 'lib/new_store_api/models/fulfillment_config_routing_rules.rb', line 31

def zip_code_regions
  @zip_code_regions
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/new_store_api/models/fulfillment_config_routing_rules.rb', line 69

def self.from_hash(hash)
  return nil unless hash

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

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

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

.namesObject

A mapping from model property names to API property names.



34
35
36
37
38
39
40
41
42
# File 'lib/new_store_api/models/fulfillment_config_routing_rules.rb', line 34

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



52
53
54
55
56
# File 'lib/new_store_api/models/fulfillment_config_routing_rules.rb', line 52

def self.nullables
  %w[
    preferred_locations
  ]
end

.optionalsObject

An array for optional fields



45
46
47
48
49
# File 'lib/new_store_api/models/fulfillment_config_routing_rules.rb', line 45

def self.optionals
  %w[
    preferred_locations
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



109
110
111
112
113
114
# File 'lib/new_store_api/models/fulfillment_config_routing_rules.rb', line 109

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.



101
102
103
104
105
106
# File 'lib/new_store_api/models/fulfillment_config_routing_rules.rb', line 101

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