Class: CyberSourceMergedSpec::OrderInformation40

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

Overview

OrderInformation40 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(address: SKIP, bill_to: SKIP, ship_to: SKIP, line_items: SKIP, additional_properties: nil) ⇒ OrderInformation40

Returns a new instance of OrderInformation40.



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/cyber_source_merged_spec/models/order_information40.rb', line 54

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

  @address = address unless address == SKIP
  @bill_to = bill_to unless bill_to == SKIP
  @ship_to = ship_to unless ship_to == SKIP
  @line_items = line_items unless line_items == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#addressAddress

Contains address information related to the order

Returns:



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

def address
  @address
end

#bill_toBillTo66

Contains address information related to the order

Returns:



18
19
20
# File 'lib/cyber_source_merged_spec/models/order_information40.rb', line 18

def bill_to
  @bill_to
end

#line_itemsArray[LineItem13]

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

Returns:



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

def line_items
  @line_items
end

#ship_toShipTo29

Contains recipient shipping information.

Returns:



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

def ship_to
  @ship_to
end

Class Method Details

.from_element(root) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/cyber_source_merged_spec/models/order_information40.rb', line 100

def self.from_element(root)
  address = XmlUtilities.from_element(root, 'Address', Address)
  bill_to = XmlUtilities.from_element(root, 'BillTo66', BillTo66)
  ship_to = XmlUtilities.from_element(root, 'ShipTo29', ShipTo29)
  line_items = XmlUtilities.from_element_to_array(root, 'LineItem13',
                                                  LineItem13)

  new(address: address,
      bill_to: bill_to,
      ship_to: ship_to,
      line_items: line_items,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



67
68
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/cyber_source_merged_spec/models/order_information40.rb', line 67

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  address = Address.from_hash(hash['address']) if hash['address']
  bill_to = BillTo66.from_hash(hash['billTo']) if hash['billTo']
  ship_to = ShipTo29.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 << (LineItem13.from_hash(structure) if structure)
    end
  end

  line_items = SKIP unless hash.key?('lineItems')

  # 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.
  OrderInformation40.new(address: address,
                         bill_to: bill_to,
                         ship_to: ship_to,
                         line_items: line_items,
                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



30
31
32
33
34
35
36
37
# File 'lib/cyber_source_merged_spec/models/order_information40.rb', line 30

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['address'] = 'address'
  @_hash['bill_to'] = 'billTo'
  @_hash['ship_to'] = 'shipTo'
  @_hash['line_items'] = 'lineItems'
  @_hash
end

.nullablesObject

An array for nullable fields



50
51
52
# File 'lib/cyber_source_merged_spec/models/order_information40.rb', line 50

def self.nullables
  []
end

.optionalsObject

An array for optional fields



40
41
42
43
44
45
46
47
# File 'lib/cyber_source_merged_spec/models/order_information40.rb', line 40

def self.optionals
  %w[
    address
    bill_to
    ship_to
    line_items
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



135
136
137
138
139
140
# File 'lib/cyber_source_merged_spec/models/order_information40.rb', line 135

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

#to_sObject

Provides a human-readable string representation of the object.



128
129
130
131
132
# File 'lib/cyber_source_merged_spec/models/order_information40.rb', line 128

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

#to_xml_element(doc, root_name) ⇒ Object



114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/cyber_source_merged_spec/models/order_information40.rb', line 114

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

  XmlUtilities.add_as_subelement(doc, root, 'Address', address)
  XmlUtilities.add_as_subelement(doc, root, 'BillTo66', bill_to)
  XmlUtilities.add_as_subelement(doc, root, 'ShipTo29', ship_to)
  XmlUtilities.add_array_as_subelement(doc, root, 'LineItem13', line_items)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end