Class: MundiApi::CreateOrderRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/mundi_api/models/create_order_request.rb

Overview

Request for creating an order

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

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_enabledBoolean

Defines whether the order will go through anti-fraud

Returns:

  • (Boolean)


37
38
39
# File 'lib/mundi_api/models/create_order_request.rb', line 37

def antifraud_enabled
  @antifraud_enabled
end

#codeString

The order code

Returns:



21
22
23
# File 'lib/mundi_api/models/create_order_request.rb', line 21

def code
  @code
end

#customerCreateCustomerRequest

Customer



13
14
15
# File 'lib/mundi_api/models/create_order_request.rb', line 13

def customer
  @customer
end

#customer_idString

The customer id

Returns:



25
26
27
# File 'lib/mundi_api/models/create_order_request.rb', line 25

def customer_id
  @customer_id
end

#itemsList of CreateOrderItemRequest

Items

Returns:



9
10
11
# File 'lib/mundi_api/models/create_order_request.rb', line 9

def items
  @items
end

#metadataArray<String, String>

Metadata

Returns:



33
34
35
# File 'lib/mundi_api/models/create_order_request.rb', line 33

def 
  @metadata
end

#paymentsList of CreatePaymentRequest

Payment data

Returns:



17
18
19
# File 'lib/mundi_api/models/create_order_request.rb', line 17

def payments
  @payments
end

#shippingCreateShippingRequest

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

.namesObject

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