maytes-api-client-rb 0.1.1

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 (163) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/LICENSE +21 -0
  4. data/README.md +47 -0
  5. data/Rakefile +10 -0
  6. data/docs/CancelCheckout409Response.md +24 -0
  7. data/docs/CancelCheckoutRequest.md +18 -0
  8. data/docs/CancelCheckoutResponse.md +18 -0
  9. data/docs/CaptureCheckout409Response.md +24 -0
  10. data/docs/CaptureCheckout422Response.md +24 -0
  11. data/docs/CaptureCheckoutRequest.md +24 -0
  12. data/docs/CaptureCheckoutResponse.md +18 -0
  13. data/docs/Checkout.md +48 -0
  14. data/docs/CheckoutCancelled.md +22 -0
  15. data/docs/CheckoutCaptured.md +28 -0
  16. data/docs/CheckoutCreated.md +24 -0
  17. data/docs/CheckoutDiscount.md +30 -0
  18. data/docs/CheckoutFee.md +32 -0
  19. data/docs/CreateCheckout401Response.md +24 -0
  20. data/docs/CreateCheckout409Response.md +24 -0
  21. data/docs/CreateCheckout422Response.md +24 -0
  22. data/docs/CreateCheckoutRequest.md +44 -0
  23. data/docs/CreateCheckoutResponse.md +18 -0
  24. data/docs/CreateRefundRequest.md +20 -0
  25. data/docs/CustomerData.md +22 -0
  26. data/docs/DefaultApi.md +633 -0
  27. data/docs/DigitalGoodsCustomData.md +18 -0
  28. data/docs/DigitalGoodsLineItem.md +38 -0
  29. data/docs/DonationLineItem.md +36 -0
  30. data/docs/ErrorResponseDto.md +24 -0
  31. data/docs/Fee.md +24 -0
  32. data/docs/FeeBreakdownLine.md +24 -0
  33. data/docs/FoodBeverageLineItem.md +36 -0
  34. data/docs/GetCheckout404Response.md +24 -0
  35. data/docs/GetCheckout422Response.md +24 -0
  36. data/docs/GetCheckoutResponse.md +18 -0
  37. data/docs/GetSettlementResponse.md +18 -0
  38. data/docs/HealthResponse.md +18 -0
  39. data/docs/LineItem.md +94 -0
  40. data/docs/ListSettlementsResponse.md +18 -0
  41. data/docs/OAuthTokenRequest.md +30 -0
  42. data/docs/OAuthTokenResponse.md +26 -0
  43. data/docs/OtherLineItem.md +36 -0
  44. data/docs/PhysicalGoodsCustomData.md +20 -0
  45. data/docs/PhysicalGoodsLineItem.md +38 -0
  46. data/docs/RefundCheckout402Response.md +24 -0
  47. data/docs/RefundCheckout409Response.md +24 -0
  48. data/docs/ServiceCustomData.md +18 -0
  49. data/docs/ServiceLineItem.md +38 -0
  50. data/docs/Settlement.md +52 -0
  51. data/docs/Tax.md +22 -0
  52. data/docs/TicketCustomData.md +40 -0
  53. data/docs/TicketLineItem.md +38 -0
  54. data/docs/TicketSeating.md +24 -0
  55. data/lib/maytes_api_client/api/default_api.rb +642 -0
  56. data/lib/maytes_api_client/api_client.rb +397 -0
  57. data/lib/maytes_api_client/api_error.rb +58 -0
  58. data/lib/maytes_api_client/api_model_base.rb +88 -0
  59. data/lib/maytes_api_client/configuration.rb +316 -0
  60. data/lib/maytes_api_client/managed_client.rb +140 -0
  61. data/lib/maytes_api_client/models/cancel_checkout409_response.rb +258 -0
  62. data/lib/maytes_api_client/models/cancel_checkout_request.rb +147 -0
  63. data/lib/maytes_api_client/models/cancel_checkout_response.rb +164 -0
  64. data/lib/maytes_api_client/models/capture_checkout409_response.rb +258 -0
  65. data/lib/maytes_api_client/models/capture_checkout422_response.rb +258 -0
  66. data/lib/maytes_api_client/models/capture_checkout_request.rb +218 -0
  67. data/lib/maytes_api_client/models/capture_checkout_response.rb +164 -0
  68. data/lib/maytes_api_client/models/checkout.rb +483 -0
  69. data/lib/maytes_api_client/models/checkout_cancelled.rb +202 -0
  70. data/lib/maytes_api_client/models/checkout_captured.rb +266 -0
  71. data/lib/maytes_api_client/models/checkout_created.rb +242 -0
  72. data/lib/maytes_api_client/models/checkout_discount.rb +329 -0
  73. data/lib/maytes_api_client/models/checkout_fee.rb +351 -0
  74. data/lib/maytes_api_client/models/create_checkout401_response.rb +258 -0
  75. data/lib/maytes_api_client/models/create_checkout409_response.rb +258 -0
  76. data/lib/maytes_api_client/models/create_checkout422_response.rb +258 -0
  77. data/lib/maytes_api_client/models/create_checkout_request.rb +444 -0
  78. data/lib/maytes_api_client/models/create_checkout_response.rb +164 -0
  79. data/lib/maytes_api_client/models/create_refund_request.rb +212 -0
  80. data/lib/maytes_api_client/models/customer_data.rb +168 -0
  81. data/lib/maytes_api_client/models/digital_goods_custom_data.rb +148 -0
  82. data/lib/maytes_api_client/models/digital_goods_line_item.rb +414 -0
  83. data/lib/maytes_api_client/models/donation_line_item.rb +405 -0
  84. data/lib/maytes_api_client/models/error_response_dto.rb +227 -0
  85. data/lib/maytes_api_client/models/fee.rb +271 -0
  86. data/lib/maytes_api_client/models/fee_breakdown_line.rb +266 -0
  87. data/lib/maytes_api_client/models/food_beverage_line_item.rb +405 -0
  88. data/lib/maytes_api_client/models/get_checkout404_response.rb +258 -0
  89. data/lib/maytes_api_client/models/get_checkout422_response.rb +258 -0
  90. data/lib/maytes_api_client/models/get_checkout_response.rb +164 -0
  91. data/lib/maytes_api_client/models/get_settlement_response.rb +164 -0
  92. data/lib/maytes_api_client/models/health_response.rb +164 -0
  93. data/lib/maytes_api_client/models/line_item.rb +65 -0
  94. data/lib/maytes_api_client/models/list_settlements_response.rb +166 -0
  95. data/lib/maytes_api_client/models/o_auth_token_request.rb +244 -0
  96. data/lib/maytes_api_client/models/o_auth_token_response.rb +251 -0
  97. data/lib/maytes_api_client/models/other_line_item.rb +405 -0
  98. data/lib/maytes_api_client/models/physical_goods_custom_data.rb +173 -0
  99. data/lib/maytes_api_client/models/physical_goods_line_item.rb +431 -0
  100. data/lib/maytes_api_client/models/refund_checkout402_response.rb +258 -0
  101. data/lib/maytes_api_client/models/refund_checkout409_response.rb +258 -0
  102. data/lib/maytes_api_client/models/service_custom_data.rb +148 -0
  103. data/lib/maytes_api_client/models/service_line_item.rb +414 -0
  104. data/lib/maytes_api_client/models/settlement.rb +526 -0
  105. data/lib/maytes_api_client/models/tax.rb +202 -0
  106. data/lib/maytes_api_client/models/ticket_custom_data.rb +333 -0
  107. data/lib/maytes_api_client/models/ticket_line_item.rb +431 -0
  108. data/lib/maytes_api_client/models/ticket_seating.rb +176 -0
  109. data/lib/maytes_api_client/version.rb +15 -0
  110. data/lib/maytes_api_client/webhook_verifier.rb +212 -0
  111. data/lib/maytes_api_client.rb +95 -0
  112. data/maytes_api_client.gemspec +39 -0
  113. data/spec/api/default_api_spec.rb +145 -0
  114. data/spec/models/cancel_checkout409_response_spec.rb +58 -0
  115. data/spec/models/cancel_checkout_request_spec.rb +36 -0
  116. data/spec/models/cancel_checkout_response_spec.rb +36 -0
  117. data/spec/models/capture_checkout409_response_spec.rb +58 -0
  118. data/spec/models/capture_checkout422_response_spec.rb +58 -0
  119. data/spec/models/capture_checkout_request_spec.rb +54 -0
  120. data/spec/models/capture_checkout_response_spec.rb +36 -0
  121. data/spec/models/checkout_cancelled_spec.rb +48 -0
  122. data/spec/models/checkout_captured_spec.rb +66 -0
  123. data/spec/models/checkout_created_spec.rb +54 -0
  124. data/spec/models/checkout_discount_spec.rb +76 -0
  125. data/spec/models/checkout_fee_spec.rb +86 -0
  126. data/spec/models/checkout_spec.rb +126 -0
  127. data/spec/models/create_checkout401_response_spec.rb +58 -0
  128. data/spec/models/create_checkout409_response_spec.rb +58 -0
  129. data/spec/models/create_checkout422_response_spec.rb +58 -0
  130. data/spec/models/create_checkout_request_spec.rb +118 -0
  131. data/spec/models/create_checkout_response_spec.rb +36 -0
  132. data/spec/models/create_refund_request_spec.rb +42 -0
  133. data/spec/models/customer_data_spec.rb +48 -0
  134. data/spec/models/digital_goods_custom_data_spec.rb +36 -0
  135. data/spec/models/digital_goods_line_item_spec.rb +100 -0
  136. data/spec/models/donation_line_item_spec.rb +94 -0
  137. data/spec/models/error_response_dto_spec.rb +54 -0
  138. data/spec/models/fee_breakdown_line_spec.rb +58 -0
  139. data/spec/models/fee_spec.rb +54 -0
  140. data/spec/models/food_beverage_line_item_spec.rb +94 -0
  141. data/spec/models/get_checkout404_response_spec.rb +58 -0
  142. data/spec/models/get_checkout422_response_spec.rb +58 -0
  143. data/spec/models/get_checkout_response_spec.rb +36 -0
  144. data/spec/models/get_settlement_response_spec.rb +36 -0
  145. data/spec/models/health_response_spec.rb +36 -0
  146. data/spec/models/line_item_spec.rb +44 -0
  147. data/spec/models/list_settlements_response_spec.rb +36 -0
  148. data/spec/models/o_auth_token_request_spec.rb +72 -0
  149. data/spec/models/o_auth_token_response_spec.rb +60 -0
  150. data/spec/models/other_line_item_spec.rb +94 -0
  151. data/spec/models/physical_goods_custom_data_spec.rb +42 -0
  152. data/spec/models/physical_goods_line_item_spec.rb +100 -0
  153. data/spec/models/refund_checkout402_response_spec.rb +58 -0
  154. data/spec/models/refund_checkout409_response_spec.rb +58 -0
  155. data/spec/models/service_custom_data_spec.rb +36 -0
  156. data/spec/models/service_line_item_spec.rb +100 -0
  157. data/spec/models/settlement_spec.rb +138 -0
  158. data/spec/models/tax_spec.rb +48 -0
  159. data/spec/models/ticket_custom_data_spec.rb +106 -0
  160. data/spec/models/ticket_line_item_spec.rb +100 -0
  161. data/spec/models/ticket_seating_spec.rb +54 -0
  162. data/spec/spec_helper.rb +111 -0
  163. metadata +295 -0
@@ -0,0 +1,258 @@
1
+ =begin
2
+ #Maytes API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.22.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module MaytesApiClient
17
+ class CreateCheckout422Response < ApiModelBase
18
+ attr_accessor :message
19
+
20
+ attr_accessor :error
21
+
22
+ attr_accessor :code
23
+
24
+ attr_accessor :metadata
25
+
26
+ class EnumAttributeValidator
27
+ attr_reader :datatype
28
+ attr_reader :allowable_values
29
+
30
+ def initialize(datatype, allowable_values)
31
+ @allowable_values = allowable_values.map do |value|
32
+ case datatype.to_s
33
+ when /Integer/i
34
+ value.to_i
35
+ when /Float/i
36
+ value.to_f
37
+ else
38
+ value
39
+ end
40
+ end
41
+ end
42
+
43
+ def valid?(value)
44
+ !value || allowable_values.include?(value)
45
+ end
46
+ end
47
+
48
+ # Attribute mapping from ruby-style variable name to JSON key.
49
+ def self.attribute_map
50
+ {
51
+ :'message' => :'message',
52
+ :'error' => :'error',
53
+ :'code' => :'code',
54
+ :'metadata' => :'metadata'
55
+ }
56
+ end
57
+
58
+ # Returns attribute mapping this model knows about
59
+ def self.acceptable_attribute_map
60
+ attribute_map
61
+ end
62
+
63
+ # Returns all the JSON keys this model knows about
64
+ def self.acceptable_attributes
65
+ acceptable_attribute_map.values
66
+ end
67
+
68
+ # Attribute type mapping.
69
+ def self.openapi_types
70
+ {
71
+ :'message' => :'String',
72
+ :'error' => :'String',
73
+ :'code' => :'String',
74
+ :'metadata' => :'Hash<String, Object>'
75
+ }
76
+ end
77
+
78
+ # List of attributes with nullable: true
79
+ def self.openapi_nullable
80
+ Set.new([
81
+ ])
82
+ end
83
+
84
+ # List of class defined in allOf (OpenAPI v3)
85
+ def self.openapi_all_of
86
+ [
87
+ :'ErrorResponseDto'
88
+ ]
89
+ end
90
+
91
+ # Initializes the object
92
+ # @param [Hash] attributes Model attributes in the form of hash
93
+ def initialize(attributes = {})
94
+ if (!attributes.is_a?(Hash))
95
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MaytesApiClient::CreateCheckout422Response` initialize method"
96
+ end
97
+
98
+ # check to see if the attribute exists and convert string to symbol for hash key
99
+ acceptable_attribute_map = self.class.acceptable_attribute_map
100
+ attributes = attributes.each_with_object({}) { |(k, v), h|
101
+ if (!acceptable_attribute_map.key?(k.to_sym))
102
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MaytesApiClient::CreateCheckout422Response`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
103
+ end
104
+ h[k.to_sym] = v
105
+ }
106
+
107
+ if attributes.key?(:'message')
108
+ self.message = attributes[:'message']
109
+ else
110
+ self.message = nil
111
+ end
112
+
113
+ if attributes.key?(:'error')
114
+ self.error = attributes[:'error']
115
+ else
116
+ self.error = nil
117
+ end
118
+
119
+ if attributes.key?(:'code')
120
+ self.code = attributes[:'code']
121
+ else
122
+ self.code = nil
123
+ end
124
+
125
+ if attributes.key?(:'metadata')
126
+ if (value = attributes[:'metadata']).is_a?(Hash)
127
+ self.metadata = value
128
+ end
129
+ end
130
+ end
131
+
132
+ # Show invalid properties with the reasons. Usually used together with valid?
133
+ # @return Array for valid properties with the reasons
134
+ def list_invalid_properties
135
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
136
+ invalid_properties = Array.new
137
+ if @message.nil?
138
+ invalid_properties.push('invalid value for "message", message cannot be nil.')
139
+ end
140
+
141
+ if @error.nil?
142
+ invalid_properties.push('invalid value for "error", error cannot be nil.')
143
+ end
144
+
145
+ if @code.nil?
146
+ invalid_properties.push('invalid value for "code", code cannot be nil.')
147
+ end
148
+
149
+ invalid_properties
150
+ end
151
+
152
+ # Check to see if the all the properties in the model are valid
153
+ # @return true if the model is valid
154
+ def valid?
155
+ warn '[DEPRECATED] the `valid?` method is obsolete'
156
+ return false if @message.nil?
157
+ return false if @error.nil?
158
+ return false if @code.nil?
159
+ code_validator = EnumAttributeValidator.new('String', ["invalid_amount", "amount_below_minimum", "invalid_amount_arithmetic", "currency_not_supported", "merchant_currency_mismatch", "merchant_not_configured"])
160
+ return false unless code_validator.valid?(@code)
161
+ true
162
+ end
163
+
164
+ # Custom attribute writer method with validation
165
+ # @param [Object] message Value to be assigned
166
+ def message=(message)
167
+ if message.nil?
168
+ fail ArgumentError, 'message cannot be nil'
169
+ end
170
+
171
+ @message = message
172
+ end
173
+
174
+ # Custom attribute writer method with validation
175
+ # @param [Object] error Value to be assigned
176
+ def error=(error)
177
+ if error.nil?
178
+ fail ArgumentError, 'error cannot be nil'
179
+ end
180
+
181
+ @error = error
182
+ end
183
+
184
+ # Custom attribute writer method checking allowed values (enum).
185
+ # @param [Object] code Object to be assigned
186
+ def code=(code)
187
+ validator = EnumAttributeValidator.new('String', ["invalid_amount", "amount_below_minimum", "invalid_amount_arithmetic", "currency_not_supported", "merchant_currency_mismatch", "merchant_not_configured"])
188
+ unless validator.valid?(code)
189
+ fail ArgumentError, "invalid value for \"code\", must be one of #{validator.allowable_values}."
190
+ end
191
+ @code = code
192
+ end
193
+
194
+ # Checks equality by comparing each attribute.
195
+ # @param [Object] Object to be compared
196
+ def ==(o)
197
+ return true if self.equal?(o)
198
+ self.class == o.class &&
199
+ message == o.message &&
200
+ error == o.error &&
201
+ code == o.code &&
202
+ metadata == o.metadata
203
+ end
204
+
205
+ # @see the `==` method
206
+ # @param [Object] Object to be compared
207
+ def eql?(o)
208
+ self == o
209
+ end
210
+
211
+ # Calculates hash code according to all attributes.
212
+ # @return [Integer] Hash code
213
+ def hash
214
+ [message, error, code, metadata].hash
215
+ end
216
+
217
+ # Builds the object from hash
218
+ # @param [Hash] attributes Model attributes in the form of hash
219
+ # @return [Object] Returns the model itself
220
+ def self.build_from_hash(attributes)
221
+ return nil unless attributes.is_a?(Hash)
222
+ attributes = attributes.transform_keys(&:to_sym)
223
+ transformed_hash = {}
224
+ openapi_types.each_pair do |key, type|
225
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
226
+ transformed_hash["#{key}"] = nil
227
+ elsif type =~ /\AArray<(.*)>/i
228
+ # check to ensure the input is an array given that the attribute
229
+ # is documented as an array but the input is not
230
+ if attributes[attribute_map[key]].is_a?(Array)
231
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
232
+ end
233
+ elsif !attributes[attribute_map[key]].nil?
234
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
235
+ end
236
+ end
237
+ new(transformed_hash)
238
+ end
239
+
240
+ # Returns the object in the form of hash
241
+ # @return [Hash] Returns the object in the form of hash
242
+ def to_hash
243
+ hash = {}
244
+ self.class.attribute_map.each_pair do |attr, param|
245
+ value = self.send(attr)
246
+ if value.nil?
247
+ is_nullable = self.class.openapi_nullable.include?(attr)
248
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
249
+ end
250
+
251
+ hash[param] = _to_hash(value)
252
+ end
253
+ hash
254
+ end
255
+
256
+ end
257
+
258
+ end
@@ -0,0 +1,444 @@
1
+ =begin
2
+ #Maytes API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.22.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module MaytesApiClient
17
+ class CreateCheckoutRequest < ApiModelBase
18
+ attr_accessor :merchant_order_id
19
+
20
+ attr_accessor :merchant_expires_at
21
+
22
+ attr_accessor :total_amount
23
+
24
+ attr_accessor :currency
25
+
26
+ attr_accessor :return_url
27
+
28
+ attr_accessor :cancel_url
29
+
30
+ attr_accessor :items
31
+
32
+ attr_accessor :fees
33
+
34
+ attr_accessor :discounts
35
+
36
+ attr_accessor :tax
37
+
38
+ attr_accessor :shipping_amount
39
+
40
+ attr_accessor :customer_data
41
+
42
+ attr_accessor :metadata
43
+
44
+ attr_accessor :allocation_model
45
+
46
+ class EnumAttributeValidator
47
+ attr_reader :datatype
48
+ attr_reader :allowable_values
49
+
50
+ def initialize(datatype, allowable_values)
51
+ @allowable_values = allowable_values.map do |value|
52
+ case datatype.to_s
53
+ when /Integer/i
54
+ value.to_i
55
+ when /Float/i
56
+ value.to_f
57
+ else
58
+ value
59
+ end
60
+ end
61
+ end
62
+
63
+ def valid?(value)
64
+ !value || allowable_values.include?(value)
65
+ end
66
+ end
67
+
68
+ # Attribute mapping from ruby-style variable name to JSON key.
69
+ def self.attribute_map
70
+ {
71
+ :'merchant_order_id' => :'merchant_order_id',
72
+ :'merchant_expires_at' => :'merchant_expires_at',
73
+ :'total_amount' => :'total_amount',
74
+ :'currency' => :'currency',
75
+ :'return_url' => :'return_url',
76
+ :'cancel_url' => :'cancel_url',
77
+ :'items' => :'items',
78
+ :'fees' => :'fees',
79
+ :'discounts' => :'discounts',
80
+ :'tax' => :'tax',
81
+ :'shipping_amount' => :'shipping_amount',
82
+ :'customer_data' => :'customer_data',
83
+ :'metadata' => :'metadata',
84
+ :'allocation_model' => :'allocation_model'
85
+ }
86
+ end
87
+
88
+ # Returns attribute mapping this model knows about
89
+ def self.acceptable_attribute_map
90
+ attribute_map
91
+ end
92
+
93
+ # Returns all the JSON keys this model knows about
94
+ def self.acceptable_attributes
95
+ acceptable_attribute_map.values
96
+ end
97
+
98
+ # Attribute type mapping.
99
+ def self.openapi_types
100
+ {
101
+ :'merchant_order_id' => :'String',
102
+ :'merchant_expires_at' => :'Time',
103
+ :'total_amount' => :'Integer',
104
+ :'currency' => :'String',
105
+ :'return_url' => :'String',
106
+ :'cancel_url' => :'String',
107
+ :'items' => :'Array<LineItem>',
108
+ :'fees' => :'Array<CheckoutFee>',
109
+ :'discounts' => :'Array<CheckoutDiscount>',
110
+ :'tax' => :'Tax',
111
+ :'shipping_amount' => :'Integer',
112
+ :'customer_data' => :'CustomerData',
113
+ :'metadata' => :'Hash<String, Object>',
114
+ :'allocation_model' => :'String'
115
+ }
116
+ end
117
+
118
+ # List of attributes with nullable: true
119
+ def self.openapi_nullable
120
+ Set.new([
121
+ :'merchant_order_id',
122
+ :'merchant_expires_at',
123
+ :'fees',
124
+ :'discounts',
125
+ :'tax',
126
+ :'shipping_amount',
127
+ :'customer_data',
128
+ :'metadata',
129
+ :'allocation_model'
130
+ ])
131
+ end
132
+
133
+ # Initializes the object
134
+ # @param [Hash] attributes Model attributes in the form of hash
135
+ def initialize(attributes = {})
136
+ if (!attributes.is_a?(Hash))
137
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MaytesApiClient::CreateCheckoutRequest` initialize method"
138
+ end
139
+
140
+ # check to see if the attribute exists and convert string to symbol for hash key
141
+ acceptable_attribute_map = self.class.acceptable_attribute_map
142
+ attributes = attributes.each_with_object({}) { |(k, v), h|
143
+ if (!acceptable_attribute_map.key?(k.to_sym))
144
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MaytesApiClient::CreateCheckoutRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
145
+ end
146
+ h[k.to_sym] = v
147
+ }
148
+
149
+ if attributes.key?(:'merchant_order_id')
150
+ self.merchant_order_id = attributes[:'merchant_order_id']
151
+ end
152
+
153
+ if attributes.key?(:'merchant_expires_at')
154
+ self.merchant_expires_at = attributes[:'merchant_expires_at']
155
+ end
156
+
157
+ if attributes.key?(:'total_amount')
158
+ self.total_amount = attributes[:'total_amount']
159
+ else
160
+ self.total_amount = nil
161
+ end
162
+
163
+ if attributes.key?(:'currency')
164
+ self.currency = attributes[:'currency']
165
+ else
166
+ self.currency = nil
167
+ end
168
+
169
+ if attributes.key?(:'return_url')
170
+ self.return_url = attributes[:'return_url']
171
+ else
172
+ self.return_url = nil
173
+ end
174
+
175
+ if attributes.key?(:'cancel_url')
176
+ self.cancel_url = attributes[:'cancel_url']
177
+ else
178
+ self.cancel_url = nil
179
+ end
180
+
181
+ if attributes.key?(:'items')
182
+ if (value = attributes[:'items']).is_a?(Array)
183
+ self.items = value
184
+ end
185
+ else
186
+ self.items = nil
187
+ end
188
+
189
+ if attributes.key?(:'fees')
190
+ if (value = attributes[:'fees']).is_a?(Array)
191
+ self.fees = value
192
+ end
193
+ end
194
+
195
+ if attributes.key?(:'discounts')
196
+ if (value = attributes[:'discounts']).is_a?(Array)
197
+ self.discounts = value
198
+ end
199
+ end
200
+
201
+ if attributes.key?(:'tax')
202
+ self.tax = attributes[:'tax']
203
+ end
204
+
205
+ if attributes.key?(:'shipping_amount')
206
+ self.shipping_amount = attributes[:'shipping_amount']
207
+ end
208
+
209
+ if attributes.key?(:'customer_data')
210
+ self.customer_data = attributes[:'customer_data']
211
+ end
212
+
213
+ if attributes.key?(:'metadata')
214
+ if (value = attributes[:'metadata']).is_a?(Hash)
215
+ self.metadata = value
216
+ end
217
+ end
218
+
219
+ if attributes.key?(:'allocation_model')
220
+ self.allocation_model = attributes[:'allocation_model']
221
+ end
222
+ end
223
+
224
+ # Show invalid properties with the reasons. Usually used together with valid?
225
+ # @return Array for valid properties with the reasons
226
+ def list_invalid_properties
227
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
228
+ invalid_properties = Array.new
229
+ if @total_amount.nil?
230
+ invalid_properties.push('invalid value for "total_amount", total_amount cannot be nil.')
231
+ end
232
+
233
+ if @total_amount <= 0
234
+ invalid_properties.push('invalid value for "total_amount", must be greater than 0.')
235
+ end
236
+
237
+ if @currency.nil?
238
+ invalid_properties.push('invalid value for "currency", currency cannot be nil.')
239
+ end
240
+
241
+ pattern = Regexp.new(/^[A-Z]{3}$/)
242
+ if @currency !~ pattern
243
+ invalid_properties.push("invalid value for \"currency\", must conform to the pattern #{pattern}.")
244
+ end
245
+
246
+ if @return_url.nil?
247
+ invalid_properties.push('invalid value for "return_url", return_url cannot be nil.')
248
+ end
249
+
250
+ if @cancel_url.nil?
251
+ invalid_properties.push('invalid value for "cancel_url", cancel_url cannot be nil.')
252
+ end
253
+
254
+ if @items.nil?
255
+ invalid_properties.push('invalid value for "items", items cannot be nil.')
256
+ end
257
+
258
+ if @items.length < 1
259
+ invalid_properties.push('invalid value for "items", number of items must be greater than or equal to 1.')
260
+ end
261
+
262
+ if !@shipping_amount.nil? && @shipping_amount < 0
263
+ invalid_properties.push('invalid value for "shipping_amount", must be greater than or equal to 0.')
264
+ end
265
+
266
+ invalid_properties
267
+ end
268
+
269
+ # Check to see if the all the properties in the model are valid
270
+ # @return true if the model is valid
271
+ def valid?
272
+ warn '[DEPRECATED] the `valid?` method is obsolete'
273
+ return false if @total_amount.nil?
274
+ return false if @total_amount <= 0
275
+ return false if @currency.nil?
276
+ return false if @currency !~ Regexp.new(/^[A-Z]{3}$/)
277
+ return false if @return_url.nil?
278
+ return false if @cancel_url.nil?
279
+ return false if @items.nil?
280
+ return false if @items.length < 1
281
+ return false if !@shipping_amount.nil? && @shipping_amount < 0
282
+ allocation_model_validator = EnumAttributeValidator.new('String', ["basic_amount", "item_assignment"])
283
+ return false unless allocation_model_validator.valid?(@allocation_model)
284
+ true
285
+ end
286
+
287
+ # Custom attribute writer method with validation
288
+ # @param [Object] total_amount Value to be assigned
289
+ def total_amount=(total_amount)
290
+ if total_amount.nil?
291
+ fail ArgumentError, 'total_amount cannot be nil'
292
+ end
293
+
294
+ if total_amount <= 0
295
+ fail ArgumentError, 'invalid value for "total_amount", must be greater than 0.'
296
+ end
297
+
298
+ @total_amount = total_amount
299
+ end
300
+
301
+ # Custom attribute writer method with validation
302
+ # @param [Object] currency Value to be assigned
303
+ def currency=(currency)
304
+ if currency.nil?
305
+ fail ArgumentError, 'currency cannot be nil'
306
+ end
307
+
308
+ pattern = Regexp.new(/^[A-Z]{3}$/)
309
+ if currency !~ pattern
310
+ fail ArgumentError, "invalid value for \"currency\", must conform to the pattern #{pattern}."
311
+ end
312
+
313
+ @currency = currency
314
+ end
315
+
316
+ # Custom attribute writer method with validation
317
+ # @param [Object] return_url Value to be assigned
318
+ def return_url=(return_url)
319
+ if return_url.nil?
320
+ fail ArgumentError, 'return_url cannot be nil'
321
+ end
322
+
323
+ @return_url = return_url
324
+ end
325
+
326
+ # Custom attribute writer method with validation
327
+ # @param [Object] cancel_url Value to be assigned
328
+ def cancel_url=(cancel_url)
329
+ if cancel_url.nil?
330
+ fail ArgumentError, 'cancel_url cannot be nil'
331
+ end
332
+
333
+ @cancel_url = cancel_url
334
+ end
335
+
336
+ # Custom attribute writer method with validation
337
+ # @param [Object] items Value to be assigned
338
+ def items=(items)
339
+ if items.nil?
340
+ fail ArgumentError, 'items cannot be nil'
341
+ end
342
+
343
+ if items.length < 1
344
+ fail ArgumentError, 'invalid value for "items", number of items must be greater than or equal to 1.'
345
+ end
346
+
347
+ @items = items
348
+ end
349
+
350
+ # Custom attribute writer method with validation
351
+ # @param [Object] shipping_amount Value to be assigned
352
+ def shipping_amount=(shipping_amount)
353
+ if !shipping_amount.nil? && shipping_amount < 0
354
+ fail ArgumentError, 'invalid value for "shipping_amount", must be greater than or equal to 0.'
355
+ end
356
+
357
+ @shipping_amount = shipping_amount
358
+ end
359
+
360
+ # Custom attribute writer method checking allowed values (enum).
361
+ # @param [Object] allocation_model Object to be assigned
362
+ def allocation_model=(allocation_model)
363
+ validator = EnumAttributeValidator.new('String', ["basic_amount", "item_assignment"])
364
+ unless validator.valid?(allocation_model)
365
+ fail ArgumentError, "invalid value for \"allocation_model\", must be one of #{validator.allowable_values}."
366
+ end
367
+ @allocation_model = allocation_model
368
+ end
369
+
370
+ # Checks equality by comparing each attribute.
371
+ # @param [Object] Object to be compared
372
+ def ==(o)
373
+ return true if self.equal?(o)
374
+ self.class == o.class &&
375
+ merchant_order_id == o.merchant_order_id &&
376
+ merchant_expires_at == o.merchant_expires_at &&
377
+ total_amount == o.total_amount &&
378
+ currency == o.currency &&
379
+ return_url == o.return_url &&
380
+ cancel_url == o.cancel_url &&
381
+ items == o.items &&
382
+ fees == o.fees &&
383
+ discounts == o.discounts &&
384
+ tax == o.tax &&
385
+ shipping_amount == o.shipping_amount &&
386
+ customer_data == o.customer_data &&
387
+ metadata == o.metadata &&
388
+ allocation_model == o.allocation_model
389
+ end
390
+
391
+ # @see the `==` method
392
+ # @param [Object] Object to be compared
393
+ def eql?(o)
394
+ self == o
395
+ end
396
+
397
+ # Calculates hash code according to all attributes.
398
+ # @return [Integer] Hash code
399
+ def hash
400
+ [merchant_order_id, merchant_expires_at, total_amount, currency, return_url, cancel_url, items, fees, discounts, tax, shipping_amount, customer_data, metadata, allocation_model].hash
401
+ end
402
+
403
+ # Builds the object from hash
404
+ # @param [Hash] attributes Model attributes in the form of hash
405
+ # @return [Object] Returns the model itself
406
+ def self.build_from_hash(attributes)
407
+ return nil unless attributes.is_a?(Hash)
408
+ attributes = attributes.transform_keys(&:to_sym)
409
+ transformed_hash = {}
410
+ openapi_types.each_pair do |key, type|
411
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
412
+ transformed_hash["#{key}"] = nil
413
+ elsif type =~ /\AArray<(.*)>/i
414
+ # check to ensure the input is an array given that the attribute
415
+ # is documented as an array but the input is not
416
+ if attributes[attribute_map[key]].is_a?(Array)
417
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
418
+ end
419
+ elsif !attributes[attribute_map[key]].nil?
420
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
421
+ end
422
+ end
423
+ new(transformed_hash)
424
+ end
425
+
426
+ # Returns the object in the form of hash
427
+ # @return [Hash] Returns the object in the form of hash
428
+ def to_hash
429
+ hash = {}
430
+ self.class.attribute_map.each_pair do |attr, param|
431
+ value = self.send(attr)
432
+ if value.nil?
433
+ is_nullable = self.class.openapi_nullable.include?(attr)
434
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
435
+ end
436
+
437
+ hash[param] = _to_hash(value)
438
+ end
439
+ hash
440
+ end
441
+
442
+ end
443
+
444
+ end