Class: MundiApi::CreateOrderRequest
- Defined in:
- lib/mundi_api/models/create_order_request.rb
Overview
Request for creating an order
Instance Attribute Summary collapse
-
#antifraud_enabled ⇒ Boolean
Defines whether the order will go through anti-fraud.
-
#code ⇒ String
The order code.
-
#customer ⇒ CreateCustomerRequest
Customer.
-
#customer_id ⇒ String
The customer id.
-
#items ⇒ List of CreateOrderItemRequest
Items.
-
#metadata ⇒ Array<String, String>
Metadata.
-
#payments ⇒ List of CreatePaymentRequest
Payment data.
-
#shipping ⇒ CreateShippingRequest
Shipping data.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#initialize(items = nil, customer = nil, payments = nil, code = nil, customer_id = nil, shipping = nil, metadata = nil, antifraud_enabled = nil) ⇒ CreateOrderRequest
constructor
A new instance of CreateOrderRequest.
Methods inherited from BaseModel
Constructor Details
#initialize(items = nil, customer = nil, payments = nil, code = nil, customer_id = nil, shipping = nil, metadata = nil, antifraud_enabled = nil) ⇒ CreateOrderRequest
Returns a new instance of CreateOrderRequest.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/mundi_api/models/create_order_request.rb', line 55 def initialize(items = nil, customer = nil, payments = nil, code = nil, customer_id = nil, shipping = nil, = nil, antifraud_enabled = nil) @items = items @customer = customer @payments = payments @code = code @customer_id = customer_id @shipping = shipping @metadata = @antifraud_enabled = antifraud_enabled end |
Instance Attribute Details
#antifraud_enabled ⇒ Boolean
Defines whether the order will go through anti-fraud
37 38 39 |
# File 'lib/mundi_api/models/create_order_request.rb', line 37 def antifraud_enabled @antifraud_enabled end |
#code ⇒ String
The order code
21 22 23 |
# File 'lib/mundi_api/models/create_order_request.rb', line 21 def code @code end |
#customer ⇒ CreateCustomerRequest
Customer
13 14 15 |
# File 'lib/mundi_api/models/create_order_request.rb', line 13 def customer @customer end |
#customer_id ⇒ String
The customer id
25 26 27 |
# File 'lib/mundi_api/models/create_order_request.rb', line 25 def customer_id @customer_id end |
#items ⇒ List of CreateOrderItemRequest
Items
9 10 11 |
# File 'lib/mundi_api/models/create_order_request.rb', line 9 def items @items end |
#metadata ⇒ Array<String, String>
Metadata
33 34 35 |
# File 'lib/mundi_api/models/create_order_request.rb', line 33 def @metadata end |
#payments ⇒ List of CreatePaymentRequest
Payment data
17 18 19 |
# File 'lib/mundi_api/models/create_order_request.rb', line 17 def payments @payments end |
#shipping ⇒ CreateShippingRequest
Shipping data
29 30 31 |
# File 'lib/mundi_api/models/create_order_request.rb', line 29 def shipping @shipping end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/mundi_api/models/create_order_request.rb', line 74 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. # Parameter is an array, so we need to iterate through it items = nil unless hash['items'].nil? items = [] hash['items'].each do |structure| items << (CreateOrderItemRequest.from_hash(structure) if structure) end end customer = CreateCustomerRequest.from_hash(hash['customer']) if hash['customer'] # Parameter is an array, so we need to iterate through it payments = nil unless hash['payments'].nil? payments = [] hash['payments'].each do |structure| payments << (CreatePaymentRequest.from_hash(structure) if structure) end end code = hash['code'] customer_id = hash['customer_id'] shipping = CreateShippingRequest.from_hash(hash['shipping']) if hash['shipping'] = hash['metadata'] antifraud_enabled = hash['antifraud_enabled'] # Create object from extracted values. CreateOrderRequest.new(items, customer, payments, code, customer_id, shipping, , antifraud_enabled) end |
.names ⇒ Object
A mapping from model property names to API property names.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/mundi_api/models/create_order_request.rb', line 40 def self.names if @_hash.nil? @_hash = {} @_hash['items'] = 'items' @_hash['customer'] = 'customer' @_hash['payments'] = 'payments' @_hash['code'] = 'code' @_hash['customer_id'] = 'customer_id' @_hash['shipping'] = 'shipping' @_hash['metadata'] = 'metadata' @_hash['antifraud_enabled'] = 'antifraud_enabled' end @_hash end |