Class: CyberSourceMergedSpec::OrderInformation37

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/cyber_source_merged_spec/models/order_information37.rb

Overview

OrderInformation37 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(amount_details: SKIP, pre_order: SKIP, pre_order_date: SKIP, reordered: SKIP, ship_to: SKIP, line_items: SKIP, bill_to: SKIP, total_offers_count: SKIP, additional_properties: nil) ⇒ OrderInformation37

Returns a new instance of OrderInformation37.



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/cyber_source_merged_spec/models/order_information37.rb', line 93

def initialize(amount_details: SKIP, pre_order: SKIP, pre_order_date: SKIP,
               reordered: SKIP, ship_to: SKIP, line_items: SKIP,
               bill_to: SKIP, total_offers_count: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @amount_details = amount_details unless amount_details == SKIP
  @pre_order = pre_order unless pre_order == SKIP
  @pre_order_date = pre_order_date unless pre_order_date == SKIP
  @reordered = reordered unless reordered == SKIP
  @ship_to = ship_to unless ship_to == SKIP
  @line_items = line_items unless line_items == SKIP
  @bill_to = bill_to unless bill_to == SKIP
  @total_offers_count = total_offers_count unless total_offers_count == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#amount_detailsAmountDetails38

Contains currency and totalAmount for this order.

Returns:



14
15
16
# File 'lib/cyber_source_merged_spec/models/order_information37.rb', line 14

def amount_details
  @amount_details
end

#bill_toBillTo65

This array contains detailed information about individual products in the order.

Returns:



53
54
55
# File 'lib/cyber_source_merged_spec/models/order_information37.rb', line 53

def bill_to
  @bill_to
end

#line_itemsArray[LineItem12]

This array contains detailed information about individual products in the order.

Returns:



48
49
50
# File 'lib/cyber_source_merged_spec/models/order_information37.rb', line 48

def line_items
  @line_items
end

#pre_orderString

Indicates whether cardholder is placing an order with a future availability or release date. This field can contain one of these values:

  • MERCHANDISE_AVAILABLE: Merchandise available
  • FUTURE_AVAILABILITY: Future availability

Returns:

  • (String)


22
23
24
# File 'lib/cyber_source_merged_spec/models/order_information37.rb', line 22

def pre_order
  @pre_order
end

#pre_order_dateString

Expected date that a pre-ordered purchase will be available. Format: YYYYMMDD

Returns:

  • (String)


27
28
29
# File 'lib/cyber_source_merged_spec/models/order_information37.rb', line 27

def pre_order_date
  @pre_order_date
end

#reorderedTrueClass | FalseClass

Indicates whether the cardholder is reordering previously purchased merchandise. This field can contain one of these values:

  • false: First time ordered
  • true: Reordered

Returns:

  • (TrueClass | FalseClass)


35
36
37
# File 'lib/cyber_source_merged_spec/models/order_information37.rb', line 35

def reordered
  @reordered
end

#ship_toShipTo27

Indicates whether the cardholder is reordering previously purchased merchandise. This field can contain one of these values:

  • false: First time ordered
  • true: Reordered

Returns:



43
44
45
# File 'lib/cyber_source_merged_spec/models/order_information37.rb', line 43

def ship_to
  @ship_to
end

#total_offers_countString

Total number of articles/items in the order as a numeric decimal count. Possible values: 00 - 99

Returns:

  • (String)


58
59
60
# File 'lib/cyber_source_merged_spec/models/order_information37.rb', line 58

def total_offers_count
  @total_offers_count
end

Class Method Details

.from_element(root) ⇒ Object



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/cyber_source_merged_spec/models/order_information37.rb', line 154

def self.from_element(root)
  amount_details = XmlUtilities.from_element(root, 'AmountDetails38',
                                             AmountDetails38)
  pre_order = XmlUtilities.from_element(root, 'preOrder', String)
  pre_order_date = XmlUtilities.from_element(root, 'preOrderDate', String)
  reordered = XmlUtilities.from_element(root, 'reordered', TrueClass)
  ship_to = XmlUtilities.from_element(root, 'ShipTo27', ShipTo27)
  line_items = XmlUtilities.from_element_to_array(root, 'LineItem12',
                                                  LineItem12)
  bill_to = XmlUtilities.from_element(root, 'BillTo65', BillTo65)
  total_offers_count = XmlUtilities.from_element(root, 'totalOffersCount',
                                                 String)

  new(amount_details: amount_details,
      pre_order: pre_order,
      pre_order_date: pre_order_date,
      reordered: reordered,
      ship_to: ship_to,
      line_items: line_items,
      bill_to: bill_to,
      total_offers_count: total_offers_count,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/cyber_source_merged_spec/models/order_information37.rb', line 112

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  amount_details = AmountDetails38.from_hash(hash['amountDetails']) if hash['amountDetails']
  pre_order = hash.key?('preOrder') ? hash['preOrder'] : SKIP
  pre_order_date = hash.key?('preOrderDate') ? hash['preOrderDate'] : SKIP
  reordered = hash.key?('reordered') ? hash['reordered'] : SKIP
  ship_to = ShipTo27.from_hash(hash['shipTo']) if hash['shipTo']
  # Parameter is an array, so we need to iterate through it
  line_items = nil
  unless hash['lineItems'].nil?
    line_items = []
    hash['lineItems'].each do |structure|
      line_items << (LineItem12.from_hash(structure) if structure)
    end
  end

  line_items = SKIP unless hash.key?('lineItems')
  bill_to = BillTo65.from_hash(hash['billTo']) if hash['billTo']
  total_offers_count =
    hash.key?('totalOffersCount') ? hash['totalOffersCount'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  OrderInformation37.new(amount_details: amount_details,
                         pre_order: pre_order,
                         pre_order_date: pre_order_date,
                         reordered: reordered,
                         ship_to: ship_to,
                         line_items: line_items,
                         bill_to: bill_to,
                         total_offers_count: total_offers_count,
                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/cyber_source_merged_spec/models/order_information37.rb', line 61

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['amount_details'] = 'amountDetails'
  @_hash['pre_order'] = 'preOrder'
  @_hash['pre_order_date'] = 'preOrderDate'
  @_hash['reordered'] = 'reordered'
  @_hash['ship_to'] = 'shipTo'
  @_hash['line_items'] = 'lineItems'
  @_hash['bill_to'] = 'billTo'
  @_hash['total_offers_count'] = 'totalOffersCount'
  @_hash
end

.nullablesObject

An array for nullable fields



89
90
91
# File 'lib/cyber_source_merged_spec/models/order_information37.rb', line 89

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    amount_details
    pre_order
    pre_order_date
    reordered
    ship_to
    line_items
    bill_to
    total_offers_count
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



207
208
209
210
211
212
213
214
# File 'lib/cyber_source_merged_spec/models/order_information37.rb', line 207

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} amount_details: #{@amount_details.inspect}, pre_order:"\
  " #{@pre_order.inspect}, pre_order_date: #{@pre_order_date.inspect}, reordered:"\
  " #{@reordered.inspect}, ship_to: #{@ship_to.inspect}, line_items: #{@line_items.inspect},"\
  " bill_to: #{@bill_to.inspect}, total_offers_count: #{@total_offers_count.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



198
199
200
201
202
203
204
# File 'lib/cyber_source_merged_spec/models/order_information37.rb', line 198

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} amount_details: #{@amount_details}, pre_order: #{@pre_order},"\
  " pre_order_date: #{@pre_order_date}, reordered: #{@reordered}, ship_to: #{@ship_to},"\
  " line_items: #{@line_items}, bill_to: #{@bill_to}, total_offers_count:"\
  " #{@total_offers_count}, additional_properties: #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/cyber_source_merged_spec/models/order_information37.rb', line 178

def to_xml_element(doc, root_name)
  root = doc.create_element(root_name)

  XmlUtilities.add_as_subelement(doc, root, 'AmountDetails38',
                                 amount_details)
  XmlUtilities.add_as_subelement(doc, root, 'preOrder', pre_order)
  XmlUtilities.add_as_subelement(doc, root, 'preOrderDate', pre_order_date)
  XmlUtilities.add_as_subelement(doc, root, 'reordered', reordered)
  XmlUtilities.add_as_subelement(doc, root, 'ShipTo27', ship_to)
  XmlUtilities.add_array_as_subelement(doc, root, 'LineItem12', line_items)
  XmlUtilities.add_as_subelement(doc, root, 'BillTo65', bill_to)
  XmlUtilities.add_as_subelement(doc, root, 'totalOffersCount',
                                 total_offers_count)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end