mundi_api 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +2186 -0
  4. data/lib/mundi_api.rb +137 -0
  5. data/lib/mundi_api/api_helper.rb +209 -0
  6. data/lib/mundi_api/configuration.rb +25 -0
  7. data/lib/mundi_api/controllers/base_controller.rb +61 -0
  8. data/lib/mundi_api/controllers/charges_controller.rb +359 -0
  9. data/lib/mundi_api/controllers/customers_controller.rb +758 -0
  10. data/lib/mundi_api/controllers/invoices_controller.rb +184 -0
  11. data/lib/mundi_api/controllers/orders_controller.rb +171 -0
  12. data/lib/mundi_api/controllers/plans_controller.rb +387 -0
  13. data/lib/mundi_api/controllers/subscriptions_controller.rb +648 -0
  14. data/lib/mundi_api/controllers/tokens_controller.rb +87 -0
  15. data/lib/mundi_api/exceptions/api_exception.rb +18 -0
  16. data/lib/mundi_api/exceptions/error_exception.rb +37 -0
  17. data/lib/mundi_api/http/auth/basic_auth.rb +20 -0
  18. data/lib/mundi_api/http/faraday_client.rb +55 -0
  19. data/lib/mundi_api/http/http_call_back.rb +22 -0
  20. data/lib/mundi_api/http/http_client.rb +92 -0
  21. data/lib/mundi_api/http/http_context.rb +18 -0
  22. data/lib/mundi_api/http/http_method_enum.rb +11 -0
  23. data/lib/mundi_api/http/http_request.rb +48 -0
  24. data/lib/mundi_api/http/http_response.rb +21 -0
  25. data/lib/mundi_api/models/base_model.rb +34 -0
  26. data/lib/mundi_api/models/create_access_token_request.rb +35 -0
  27. data/lib/mundi_api/models/create_address_request.rb +108 -0
  28. data/lib/mundi_api/models/create_bank_transfer_payment_request.rb +44 -0
  29. data/lib/mundi_api/models/create_boleto_payment_request.rb +83 -0
  30. data/lib/mundi_api/models/create_cancel_charge_request.rb +35 -0
  31. data/lib/mundi_api/models/create_cancel_subscription_request.rb +35 -0
  32. data/lib/mundi_api/models/create_capture_charge_request.rb +45 -0
  33. data/lib/mundi_api/models/create_card_options_request.rb +36 -0
  34. data/lib/mundi_api/models/create_card_request.rb +136 -0
  35. data/lib/mundi_api/models/create_card_token_request.rb +80 -0
  36. data/lib/mundi_api/models/create_charge_request.rb +92 -0
  37. data/lib/mundi_api/models/create_checkout_boleto_payment_request.rb +54 -0
  38. data/lib/mundi_api/models/create_checkout_card_installment_option_request.rb +44 -0
  39. data/lib/mundi_api/models/create_checkout_card_payment_request.rb +51 -0
  40. data/lib/mundi_api/models/create_checkout_payment_request.rb +82 -0
  41. data/lib/mundi_api/models/create_credit_card_payment_request.rb +108 -0
  42. data/lib/mundi_api/models/create_customer_request.rb +108 -0
  43. data/lib/mundi_api/models/create_discount_request.rb +62 -0
  44. data/lib/mundi_api/models/create_order_item_request.rb +71 -0
  45. data/lib/mundi_api/models/create_order_request.rb +114 -0
  46. data/lib/mundi_api/models/create_payment_request.rb +121 -0
  47. data/lib/mundi_api/models/create_phone_request.rb +53 -0
  48. data/lib/mundi_api/models/create_phones_request.rb +46 -0
  49. data/lib/mundi_api/models/create_plan_item_request.rb +81 -0
  50. data/lib/mundi_api/models/create_plan_request.rb +199 -0
  51. data/lib/mundi_api/models/create_price_bracket_request.rb +62 -0
  52. data/lib/mundi_api/models/create_pricing_scheme_request.rb +69 -0
  53. data/lib/mundi_api/models/create_seller_request.rb +90 -0
  54. data/lib/mundi_api/models/create_setup_request.rb +55 -0
  55. data/lib/mundi_api/models/create_shipping_request.rb +81 -0
  56. data/lib/mundi_api/models/create_subscription_item_request.rb +106 -0
  57. data/lib/mundi_api/models/create_subscription_request.rb +269 -0
  58. data/lib/mundi_api/models/create_token_request.rb +44 -0
  59. data/lib/mundi_api/models/create_usage_request.rb +54 -0
  60. data/lib/mundi_api/models/create_voucher_payment_request.rb +72 -0
  61. data/lib/mundi_api/models/get_access_token_response.rb +73 -0
  62. data/lib/mundi_api/models/get_address_response.rb +163 -0
  63. data/lib/mundi_api/models/get_bank_transfer_transaction_response.rb +118 -0
  64. data/lib/mundi_api/models/get_billing_address_response.rb +98 -0
  65. data/lib/mundi_api/models/get_boleto_transaction_response.rb +137 -0
  66. data/lib/mundi_api/models/get_card_response.rb +164 -0
  67. data/lib/mundi_api/models/get_card_token_response.rb +89 -0
  68. data/lib/mundi_api/models/get_charge_response.rb +184 -0
  69. data/lib/mundi_api/models/get_checkout_payment_settings_response.rb +99 -0
  70. data/lib/mundi_api/models/get_credit_card_transaction_response.rb +163 -0
  71. data/lib/mundi_api/models/get_customer_response.rb +145 -0
  72. data/lib/mundi_api/models/get_discount_response.rb +100 -0
  73. data/lib/mundi_api/models/get_invoice_item_response.rb +73 -0
  74. data/lib/mundi_api/models/get_invoice_response.rb +210 -0
  75. data/lib/mundi_api/models/get_order_item_response.rb +63 -0
  76. data/lib/mundi_api/models/get_order_response.rb +167 -0
  77. data/lib/mundi_api/models/get_period_response.rb +73 -0
  78. data/lib/mundi_api/models/get_phone_response.rb +53 -0
  79. data/lib/mundi_api/models/get_phones_response.rb +46 -0
  80. data/lib/mundi_api/models/get_plan_item_response.rb +127 -0
  81. data/lib/mundi_api/models/get_plan_response.rb +223 -0
  82. data/lib/mundi_api/models/get_price_bracket_response.rb +62 -0
  83. data/lib/mundi_api/models/get_pricing_scheme_response.rb +69 -0
  84. data/lib/mundi_api/models/get_safety_pay_transaction_response.rb +109 -0
  85. data/lib/mundi_api/models/get_seller_response.rb +126 -0
  86. data/lib/mundi_api/models/get_setup_response.rb +62 -0
  87. data/lib/mundi_api/models/get_shipping_response.rb +72 -0
  88. data/lib/mundi_api/models/get_subscription_item_response.rb +135 -0
  89. data/lib/mundi_api/models/get_subscription_response.rb +261 -0
  90. data/lib/mundi_api/models/get_token_response.rb +72 -0
  91. data/lib/mundi_api/models/get_transaction_response.rb +136 -0
  92. data/lib/mundi_api/models/get_usage_response.rb +82 -0
  93. data/lib/mundi_api/models/get_voucher_transaction_response.rb +163 -0
  94. data/lib/mundi_api/models/list_access_tokens_response.rb +51 -0
  95. data/lib/mundi_api/models/list_addresses_response.rb +51 -0
  96. data/lib/mundi_api/models/list_cards_response.rb +51 -0
  97. data/lib/mundi_api/models/list_charges_response.rb +51 -0
  98. data/lib/mundi_api/models/list_customers_response.rb +51 -0
  99. data/lib/mundi_api/models/list_invoices_response.rb +51 -0
  100. data/lib/mundi_api/models/list_order_response.rb +51 -0
  101. data/lib/mundi_api/models/list_plans_response.rb +51 -0
  102. data/lib/mundi_api/models/list_subscription_items_response.rb +51 -0
  103. data/lib/mundi_api/models/list_subscriptions_response.rb +51 -0
  104. data/lib/mundi_api/models/list_transactions_response.rb +51 -0
  105. data/lib/mundi_api/models/list_usages_response.rb +51 -0
  106. data/lib/mundi_api/models/paging_response.rb +53 -0
  107. data/lib/mundi_api/models/update_address_request.rb +53 -0
  108. data/lib/mundi_api/models/update_card_request.rb +81 -0
  109. data/lib/mundi_api/models/update_charge_card_request.rb +62 -0
  110. data/lib/mundi_api/models/update_charge_due_date_request.rb +36 -0
  111. data/lib/mundi_api/models/update_charge_payment_method_request.rb +74 -0
  112. data/lib/mundi_api/models/update_customer_request.rb +90 -0
  113. data/lib/mundi_api/models/update_metadata_request.rb +35 -0
  114. data/lib/mundi_api/models/update_plan_item_request.rb +81 -0
  115. data/lib/mundi_api/models/update_plan_request.rb +161 -0
  116. data/lib/mundi_api/models/update_price_bracket_request.rb +62 -0
  117. data/lib/mundi_api/models/update_pricing_scheme_request.rb +69 -0
  118. data/lib/mundi_api/models/update_subscription_billing_date_request.rb +37 -0
  119. data/lib/mundi_api/models/update_subscription_card_request.rb +44 -0
  120. data/lib/mundi_api/models/update_subscription_item_request.rb +81 -0
  121. data/lib/mundi_api/models/update_subscription_payment_method_request.rb +53 -0
  122. data/lib/mundi_api/mundi_api_client.rb +63 -0
  123. metadata +246 -0
@@ -0,0 +1,82 @@
1
+ # This file was automatically generated by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
3
+
4
+ module MundiApi
5
+ # Checkout payment request
6
+ class CreateCheckoutPaymentRequest < BaseModel
7
+ # Accepted Payment Methods
8
+ # @return [List of String]
9
+ attr_accessor :accepted_payment_methods
10
+
11
+ # Success url
12
+ # @return [String]
13
+ attr_accessor :success_url
14
+
15
+ # Default payment method
16
+ # @return [String]
17
+ attr_accessor :default_payment_method
18
+
19
+ # Gateway Affiliation Id
20
+ # @return [String]
21
+ attr_accessor :gateway_affiliation_id
22
+
23
+ # Card payment request
24
+ # @return [CreateCheckoutCardPaymentRequest]
25
+ attr_accessor :credit_card
26
+
27
+ # Boleto payment request
28
+ # @return [CreateCheckoutBoletoPaymentRequest]
29
+ attr_accessor :boleto
30
+
31
+ # A mapping from model property names to API property names.
32
+ def self.names
33
+ if @_hash.nil?
34
+ @_hash = {}
35
+ @_hash['accepted_payment_methods'] = 'accepted_payment_methods'
36
+ @_hash['success_url'] = 'success_url'
37
+ @_hash['default_payment_method'] = 'default_payment_method'
38
+ @_hash['gateway_affiliation_id'] = 'gateway_affiliation_id'
39
+ @_hash['credit_card'] = 'credit_card'
40
+ @_hash['boleto'] = 'boleto'
41
+ end
42
+ @_hash
43
+ end
44
+
45
+ def initialize(accepted_payment_methods = nil,
46
+ success_url = nil,
47
+ default_payment_method = nil,
48
+ gateway_affiliation_id = nil,
49
+ credit_card = nil,
50
+ boleto = nil)
51
+ @accepted_payment_methods = accepted_payment_methods
52
+ @success_url = success_url
53
+ @default_payment_method = default_payment_method
54
+ @gateway_affiliation_id = gateway_affiliation_id
55
+ @credit_card = credit_card
56
+ @boleto = boleto
57
+ end
58
+
59
+ # Creates an instance of the object from a hash.
60
+ def self.from_hash(hash)
61
+ return nil unless hash
62
+
63
+ # Extract variables from the hash.
64
+ accepted_payment_methods = hash['accepted_payment_methods']
65
+ success_url = hash['success_url']
66
+ default_payment_method = hash['default_payment_method']
67
+ gateway_affiliation_id = hash['gateway_affiliation_id']
68
+ credit_card = CreateCheckoutCardPaymentRequest.from_hash(hash['credit_card']) if
69
+ hash['credit_card']
70
+ boleto = CreateCheckoutBoletoPaymentRequest.from_hash(hash['boleto']) if
71
+ hash['boleto']
72
+
73
+ # Create object from extracted values.
74
+ CreateCheckoutPaymentRequest.new(accepted_payment_methods,
75
+ success_url,
76
+ default_payment_method,
77
+ gateway_affiliation_id,
78
+ credit_card,
79
+ boleto)
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,108 @@
1
+ # This file was automatically generated by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
3
+
4
+ module MundiApi
5
+ # The settings for creating a credit card payment
6
+ class CreateCreditCardPaymentRequest < BaseModel
7
+ # Number of installments
8
+ # @return [Integer]
9
+ attr_accessor :installments
10
+
11
+ # The text that will be shown on the credit card's statement
12
+ # @return [String]
13
+ attr_accessor :statement_descriptor
14
+
15
+ # Credit card data
16
+ # @return [CreateCardRequest]
17
+ attr_accessor :card
18
+
19
+ # Number of retries
20
+ # @return [Integer]
21
+ attr_accessor :retries
22
+
23
+ # Indicates if the card from the subscription must be updated
24
+ # @return [Boolean]
25
+ attr_accessor :update_subscription_card
26
+
27
+ # The credit card id
28
+ # @return [String]
29
+ attr_accessor :card_id
30
+
31
+ # The credit card id
32
+ # @return [String]
33
+ attr_accessor :card_token
34
+
35
+ # Indicates a recurrence
36
+ # @return [Boolean]
37
+ attr_accessor :recurrence
38
+
39
+ # Indicates if the operation should be only authorization or auth and
40
+ # capture.
41
+ # @return [Boolean]
42
+ attr_accessor :capture
43
+
44
+ # A mapping from model property names to API property names.
45
+ def self.names
46
+ if @_hash.nil?
47
+ @_hash = {}
48
+ @_hash['installments'] = 'installments'
49
+ @_hash['statement_descriptor'] = 'statement_descriptor'
50
+ @_hash['card'] = 'card'
51
+ @_hash['retries'] = 'retries'
52
+ @_hash['update_subscription_card'] = 'update_subscription_card'
53
+ @_hash['card_id'] = 'card_id'
54
+ @_hash['card_token'] = 'card_token'
55
+ @_hash['recurrence'] = 'recurrence'
56
+ @_hash['capture'] = 'capture'
57
+ end
58
+ @_hash
59
+ end
60
+
61
+ def initialize(installments = 1,
62
+ statement_descriptor = nil,
63
+ card = nil,
64
+ retries = nil,
65
+ update_subscription_card = nil,
66
+ card_id = nil,
67
+ card_token = nil,
68
+ recurrence = nil,
69
+ capture = true)
70
+ @installments = installments
71
+ @statement_descriptor = statement_descriptor
72
+ @card = card
73
+ @retries = retries
74
+ @update_subscription_card = update_subscription_card
75
+ @card_id = card_id
76
+ @card_token = card_token
77
+ @recurrence = recurrence
78
+ @capture = capture
79
+ end
80
+
81
+ # Creates an instance of the object from a hash.
82
+ def self.from_hash(hash)
83
+ return nil unless hash
84
+
85
+ # Extract variables from the hash.
86
+ installments = hash['installments'] ||= 1
87
+ statement_descriptor = hash['statement_descriptor']
88
+ card = CreateCardRequest.from_hash(hash['card']) if hash['card']
89
+ retries = hash['retries']
90
+ update_subscription_card = hash['update_subscription_card']
91
+ card_id = hash['card_id']
92
+ card_token = hash['card_token']
93
+ recurrence = hash['recurrence']
94
+ capture = hash['capture'] ||= true
95
+
96
+ # Create object from extracted values.
97
+ CreateCreditCardPaymentRequest.new(installments,
98
+ statement_descriptor,
99
+ card,
100
+ retries,
101
+ update_subscription_card,
102
+ card_id,
103
+ card_token,
104
+ recurrence,
105
+ capture)
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,108 @@
1
+ # This file was automatically generated by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
3
+
4
+ module MundiApi
5
+ # Request for creating a new customer
6
+ class CreateCustomerRequest < BaseModel
7
+ # Name
8
+ # @return [String]
9
+ attr_accessor :name
10
+
11
+ # Email
12
+ # @return [String]
13
+ attr_accessor :email
14
+
15
+ # Document number. Only numbers, no special characters.
16
+ # @return [String]
17
+ attr_accessor :document
18
+
19
+ # Person type. Can be either 'individual' or 'company'
20
+ # @return [String]
21
+ attr_accessor :type
22
+
23
+ # The customer's address
24
+ # @return [CreateAddressRequest]
25
+ attr_accessor :address
26
+
27
+ # Metadata
28
+ # @return [Array<String, String>]
29
+ attr_accessor :metadata
30
+
31
+ # Metadata
32
+ # @return [CreatePhonesRequest]
33
+ attr_accessor :phones
34
+
35
+ # Customer code
36
+ # @return [String]
37
+ attr_accessor :code
38
+
39
+ # Customer Gender
40
+ # @return [String]
41
+ attr_accessor :gender
42
+
43
+ # A mapping from model property names to API property names.
44
+ def self.names
45
+ if @_hash.nil?
46
+ @_hash = {}
47
+ @_hash['name'] = 'name'
48
+ @_hash['email'] = 'email'
49
+ @_hash['document'] = 'document'
50
+ @_hash['type'] = 'type'
51
+ @_hash['address'] = 'address'
52
+ @_hash['metadata'] = 'metadata'
53
+ @_hash['phones'] = 'phones'
54
+ @_hash['code'] = 'code'
55
+ @_hash['gender'] = 'gender'
56
+ end
57
+ @_hash
58
+ end
59
+
60
+ def initialize(name = nil,
61
+ email = nil,
62
+ document = nil,
63
+ type = nil,
64
+ address = nil,
65
+ metadata = nil,
66
+ phones = nil,
67
+ code = nil,
68
+ gender = nil)
69
+ @name = name
70
+ @email = email
71
+ @document = document
72
+ @type = type
73
+ @address = address
74
+ @metadata = metadata
75
+ @phones = phones
76
+ @code = code
77
+ @gender = gender
78
+ end
79
+
80
+ # Creates an instance of the object from a hash.
81
+ def self.from_hash(hash)
82
+ return nil unless hash
83
+
84
+ # Extract variables from the hash.
85
+ name = hash['name']
86
+ email = hash['email']
87
+ document = hash['document']
88
+ type = hash['type']
89
+ address = CreateAddressRequest.from_hash(hash['address']) if
90
+ hash['address']
91
+ metadata = hash['metadata']
92
+ phones = CreatePhonesRequest.from_hash(hash['phones']) if hash['phones']
93
+ code = hash['code']
94
+ gender = hash['gender']
95
+
96
+ # Create object from extracted values.
97
+ CreateCustomerRequest.new(name,
98
+ email,
99
+ document,
100
+ type,
101
+ address,
102
+ metadata,
103
+ phones,
104
+ code,
105
+ gender)
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,62 @@
1
+ # This file was automatically generated by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
3
+
4
+ module MundiApi
5
+ # Request for creating a new discount
6
+ class CreateDiscountRequest < BaseModel
7
+ # The discount value
8
+ # @return [Float]
9
+ attr_accessor :value
10
+
11
+ # Discount type. Can be either flat or percentage.
12
+ # @return [String]
13
+ attr_accessor :discount_type
14
+
15
+ # The item where the discount will be applied
16
+ # @return [String]
17
+ attr_accessor :item_id
18
+
19
+ # Number of cycles that the discount will be applied
20
+ # @return [Integer]
21
+ attr_accessor :cycles
22
+
23
+ # A mapping from model property names to API property names.
24
+ def self.names
25
+ if @_hash.nil?
26
+ @_hash = {}
27
+ @_hash['value'] = 'value'
28
+ @_hash['discount_type'] = 'discount_type'
29
+ @_hash['item_id'] = 'item_id'
30
+ @_hash['cycles'] = 'cycles'
31
+ end
32
+ @_hash
33
+ end
34
+
35
+ def initialize(value = nil,
36
+ discount_type = nil,
37
+ item_id = nil,
38
+ cycles = nil)
39
+ @value = value
40
+ @discount_type = discount_type
41
+ @item_id = item_id
42
+ @cycles = cycles
43
+ end
44
+
45
+ # Creates an instance of the object from a hash.
46
+ def self.from_hash(hash)
47
+ return nil unless hash
48
+
49
+ # Extract variables from the hash.
50
+ value = hash['value']
51
+ discount_type = hash['discount_type']
52
+ item_id = hash['item_id']
53
+ cycles = hash['cycles']
54
+
55
+ # Create object from extracted values.
56
+ CreateDiscountRequest.new(value,
57
+ discount_type,
58
+ item_id,
59
+ cycles)
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,71 @@
1
+ # This file was automatically generated by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
3
+
4
+ module MundiApi
5
+ # Request for creating an order item
6
+ class CreateOrderItemRequest < BaseModel
7
+ # Amount
8
+ # @return [Integer]
9
+ attr_accessor :amount
10
+
11
+ # Description
12
+ # @return [String]
13
+ attr_accessor :description
14
+
15
+ # Quantity
16
+ # @return [Integer]
17
+ attr_accessor :quantity
18
+
19
+ # Item seller
20
+ # @return [CreateSellerRequest]
21
+ attr_accessor :seller
22
+
23
+ # seller identificator
24
+ # @return [String]
25
+ attr_accessor :seller_id
26
+
27
+ # A mapping from model property names to API property names.
28
+ def self.names
29
+ if @_hash.nil?
30
+ @_hash = {}
31
+ @_hash['amount'] = 'amount'
32
+ @_hash['description'] = 'description'
33
+ @_hash['quantity'] = 'quantity'
34
+ @_hash['seller'] = 'seller'
35
+ @_hash['seller_id'] = 'seller_id'
36
+ end
37
+ @_hash
38
+ end
39
+
40
+ def initialize(amount = nil,
41
+ description = nil,
42
+ quantity = nil,
43
+ seller = nil,
44
+ seller_id = nil)
45
+ @amount = amount
46
+ @description = description
47
+ @quantity = quantity
48
+ @seller = seller
49
+ @seller_id = seller_id
50
+ end
51
+
52
+ # Creates an instance of the object from a hash.
53
+ def self.from_hash(hash)
54
+ return nil unless hash
55
+
56
+ # Extract variables from the hash.
57
+ amount = hash['amount']
58
+ description = hash['description']
59
+ quantity = hash['quantity']
60
+ seller = CreateSellerRequest.from_hash(hash['seller']) if hash['seller']
61
+ seller_id = hash['seller_id']
62
+
63
+ # Create object from extracted values.
64
+ CreateOrderItemRequest.new(amount,
65
+ description,
66
+ quantity,
67
+ seller,
68
+ seller_id)
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,114 @@
1
+ # This file was automatically generated by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
3
+
4
+ module MundiApi
5
+ # Request for creating an order
6
+ class CreateOrderRequest < BaseModel
7
+ # Items
8
+ # @return [List of CreateOrderItemRequest]
9
+ attr_accessor :items
10
+
11
+ # Customer
12
+ # @return [CreateCustomerRequest]
13
+ attr_accessor :customer
14
+
15
+ # Payment data
16
+ # @return [List of CreatePaymentRequest]
17
+ attr_accessor :payments
18
+
19
+ # The order code
20
+ # @return [String]
21
+ attr_accessor :code
22
+
23
+ # The customer id
24
+ # @return [String]
25
+ attr_accessor :customer_id
26
+
27
+ # Shipping data
28
+ # @return [CreateShippingRequest]
29
+ attr_accessor :shipping
30
+
31
+ # Metadata
32
+ # @return [Array<String, String>]
33
+ attr_accessor :metadata
34
+
35
+ # Defines whether the order will go through anti-fraud
36
+ # @return [Boolean]
37
+ attr_accessor :antifraud_enabled
38
+
39
+ # A mapping from model property names to API property names.
40
+ def self.names
41
+ if @_hash.nil?
42
+ @_hash = {}
43
+ @_hash['items'] = 'items'
44
+ @_hash['customer'] = 'customer'
45
+ @_hash['payments'] = 'payments'
46
+ @_hash['code'] = 'code'
47
+ @_hash['customer_id'] = 'customer_id'
48
+ @_hash['shipping'] = 'shipping'
49
+ @_hash['metadata'] = 'metadata'
50
+ @_hash['antifraud_enabled'] = 'antifraud_enabled'
51
+ end
52
+ @_hash
53
+ end
54
+
55
+ def initialize(items = nil,
56
+ customer = nil,
57
+ payments = nil,
58
+ code = nil,
59
+ customer_id = nil,
60
+ shipping = nil,
61
+ metadata = nil,
62
+ antifraud_enabled = nil)
63
+ @items = items
64
+ @customer = customer
65
+ @payments = payments
66
+ @code = code
67
+ @customer_id = customer_id
68
+ @shipping = shipping
69
+ @metadata = metadata
70
+ @antifraud_enabled = antifraud_enabled
71
+ end
72
+
73
+ # Creates an instance of the object from a hash.
74
+ def self.from_hash(hash)
75
+ return nil unless hash
76
+
77
+ # Extract variables from the hash.
78
+ # Parameter is an array, so we need to iterate through it
79
+ items = nil
80
+ unless hash['items'].nil?
81
+ items = []
82
+ hash['items'].each do |structure|
83
+ items << (CreateOrderItemRequest.from_hash(structure) if structure)
84
+ end
85
+ end
86
+ customer = CreateCustomerRequest.from_hash(hash['customer']) if
87
+ hash['customer']
88
+ # Parameter is an array, so we need to iterate through it
89
+ payments = nil
90
+ unless hash['payments'].nil?
91
+ payments = []
92
+ hash['payments'].each do |structure|
93
+ payments << (CreatePaymentRequest.from_hash(structure) if structure)
94
+ end
95
+ end
96
+ code = hash['code']
97
+ customer_id = hash['customer_id']
98
+ shipping = CreateShippingRequest.from_hash(hash['shipping']) if
99
+ hash['shipping']
100
+ metadata = hash['metadata']
101
+ antifraud_enabled = hash['antifraud_enabled']
102
+
103
+ # Create object from extracted values.
104
+ CreateOrderRequest.new(items,
105
+ customer,
106
+ payments,
107
+ code,
108
+ customer_id,
109
+ shipping,
110
+ metadata,
111
+ antifraud_enabled)
112
+ end
113
+ end
114
+ end