Class: NewStoreApi::RequestShippingOption

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

Overview

RequestShippingOption 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(audit = nil, location_id = nil, products = nil, recipient_address = nil, sender_address = nil, service_level = nil, channel_type = SKIP, demand_location_id = SKIP) ⇒ RequestShippingOption

Returns a new instance of RequestShippingOption.



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/new_store_api/models/request_shipping_option.rb', line 74

def initialize(audit = nil, location_id = nil, products = nil,
               recipient_address = nil, sender_address = nil,
               service_level = nil, channel_type = SKIP,
               demand_location_id = SKIP)
  @audit = audit
  @channel_type = channel_type unless channel_type == SKIP
  @demand_location_id = demand_location_id unless demand_location_id == SKIP
  @location_id = location_id
  @products = products
  @recipient_address = recipient_address
  @sender_address = sender_address
  @service_level = service_level
end

Instance Attribute Details

#auditShippingOptionAudit

TODO: Write general description for this method

Returns:



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

def audit
  @audit
end

#channel_typeString

TODO: Write general description for this method

Returns:

  • (String)


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

def channel_type
  @channel_type
end

#demand_location_idString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/new_store_api/models/request_shipping_option.rb', line 22

def demand_location_id
  @demand_location_id
end

#location_idString

TODO: Write general description for this method

Returns:

  • (String)


26
27
28
# File 'lib/new_store_api/models/request_shipping_option.rb', line 26

def location_id
  @location_id
end

#productsArray[Product]

TODO: Write general description for this method

Returns:



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

def products
  @products
end

#recipient_addressAddress

TODO: Write general description for this method

Returns:



34
35
36
# File 'lib/new_store_api/models/request_shipping_option.rb', line 34

def recipient_address
  @recipient_address
end

#sender_addressAddress

TODO: Write general description for this method

Returns:



38
39
40
# File 'lib/new_store_api/models/request_shipping_option.rb', line 38

def sender_address
  @sender_address
end

#service_levelString

TODO: Write general description for this method

Returns:

  • (String)


42
43
44
# File 'lib/new_store_api/models/request_shipping_option.rb', line 42

def service_level
  @service_level
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/new_store_api/models/request_shipping_option.rb', line 89

def self.from_hash(hash)
  return nil unless hash

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

  products = nil unless hash.key?('products')
  recipient_address = Address.from_hash(hash['recipient_address']) if
    hash['recipient_address']
  sender_address = Address.from_hash(hash['sender_address']) if hash['sender_address']
  service_level = hash.key?('service_level') ? hash['service_level'] : nil
  channel_type = hash.key?('channel_type') ? hash['channel_type'] : SKIP
  demand_location_id =
    hash.key?('demand_location_id') ? hash['demand_location_id'] : SKIP

  # Create object from extracted values.
  RequestShippingOption.new(audit,
                            location_id,
                            products,
                            recipient_address,
                            sender_address,
                            service_level,
                            channel_type,
                            demand_location_id)
end

.namesObject

A mapping from model property names to API property names.



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/new_store_api/models/request_shipping_option.rb', line 45

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['audit'] = 'audit'
  @_hash['channel_type'] = 'channel_type'
  @_hash['demand_location_id'] = 'demand_location_id'
  @_hash['location_id'] = 'location_id'
  @_hash['products'] = 'products'
  @_hash['recipient_address'] = 'recipient_address'
  @_hash['sender_address'] = 'sender_address'
  @_hash['service_level'] = 'service_level'
  @_hash
end

.nullablesObject

An array for nullable fields



67
68
69
70
71
72
# File 'lib/new_store_api/models/request_shipping_option.rb', line 67

def self.nullables
  %w[
    channel_type
    demand_location_id
  ]
end

.optionalsObject

An array for optional fields



59
60
61
62
63
64
# File 'lib/new_store_api/models/request_shipping_option.rb', line 59

def self.optionals
  %w[
    channel_type
    demand_location_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



134
135
136
137
138
139
140
# File 'lib/new_store_api/models/request_shipping_option.rb', line 134

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} audit: #{@audit.inspect}, channel_type: #{@channel_type.inspect},"\
  " demand_location_id: #{@demand_location_id.inspect}, location_id: #{@location_id.inspect},"\
  " products: #{@products.inspect}, recipient_address: #{@recipient_address.inspect},"\
  " sender_address: #{@sender_address.inspect}, service_level: #{@service_level.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



125
126
127
128
129
130
131
# File 'lib/new_store_api/models/request_shipping_option.rb', line 125

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} audit: #{@audit}, channel_type: #{@channel_type}, demand_location_id:"\
  " #{@demand_location_id}, location_id: #{@location_id}, products: #{@products},"\
  " recipient_address: #{@recipient_address}, sender_address: #{@sender_address},"\
  " service_level: #{@service_level}>"
end