Class: NewStoreApi::RoutingRuleset

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

Overview

RoutingRuleset 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, routes = SKIP, sl_levels_priority = SKIP) ⇒ RoutingRuleset

Returns a new instance of RoutingRuleset.



48
49
50
51
52
53
# File 'lib/new_store_api/models/routing_ruleset.rb', line 48

def initialize(location_groups = SKIP, routes = SKIP,
               sl_levels_priority = SKIP)
  @location_groups = location_groups unless location_groups == SKIP
  @routes = routes unless routes == SKIP
  @sl_levels_priority = sl_levels_priority unless sl_levels_priority == 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_ruleset.rb', line 14

def location_groups
  @location_groups
end

#routesArray[RoutesV1]

Routing rules specification

Returns:



18
19
20
# File 'lib/new_store_api/models/routing_ruleset.rb', line 18

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])


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

def sl_levels_priority
  @sl_levels_priority
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/new_store_api/models/routing_ruleset.rb', line 56

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  location_groups =
    hash.key?('location_groups') ? hash['location_groups'] : 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 << (RoutesV1.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

  # Create object from extracted values.
  RoutingRuleset.new(location_groups,
                     routes,
                     sl_levels_priority)
end

.namesObject

A mapping from model property names to API property names.



26
27
28
29
30
31
32
# File 'lib/new_store_api/models/routing_ruleset.rb', line 26

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

.nullablesObject

An array for nullable fields



44
45
46
# File 'lib/new_store_api/models/routing_ruleset.rb', line 44

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



89
90
91
92
93
# File 'lib/new_store_api/models/routing_ruleset.rb', line 89

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

#to_sObject

Provides a human-readable string representation of the object.



82
83
84
85
86
# File 'lib/new_store_api/models/routing_ruleset.rb', line 82

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