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,329 @@
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 CheckoutDiscount < ApiModelBase
18
+ attr_accessor :name
19
+
20
+ attr_accessor :description
21
+
22
+ attr_accessor :scope
23
+
24
+ attr_accessor :amount
25
+
26
+ attr_accessor :currency
27
+
28
+ attr_accessor :metadata
29
+
30
+ attr_accessor :applies_to
31
+
32
+ class EnumAttributeValidator
33
+ attr_reader :datatype
34
+ attr_reader :allowable_values
35
+
36
+ def initialize(datatype, allowable_values)
37
+ @allowable_values = allowable_values.map do |value|
38
+ case datatype.to_s
39
+ when /Integer/i
40
+ value.to_i
41
+ when /Float/i
42
+ value.to_f
43
+ else
44
+ value
45
+ end
46
+ end
47
+ end
48
+
49
+ def valid?(value)
50
+ !value || allowable_values.include?(value)
51
+ end
52
+ end
53
+
54
+ # Attribute mapping from ruby-style variable name to JSON key.
55
+ def self.attribute_map
56
+ {
57
+ :'name' => :'name',
58
+ :'description' => :'description',
59
+ :'scope' => :'scope',
60
+ :'amount' => :'amount',
61
+ :'currency' => :'currency',
62
+ :'metadata' => :'metadata',
63
+ :'applies_to' => :'applies_to'
64
+ }
65
+ end
66
+
67
+ # Returns attribute mapping this model knows about
68
+ def self.acceptable_attribute_map
69
+ attribute_map
70
+ end
71
+
72
+ # Returns all the JSON keys this model knows about
73
+ def self.acceptable_attributes
74
+ acceptable_attribute_map.values
75
+ end
76
+
77
+ # Attribute type mapping.
78
+ def self.openapi_types
79
+ {
80
+ :'name' => :'String',
81
+ :'description' => :'String',
82
+ :'scope' => :'String',
83
+ :'amount' => :'Integer',
84
+ :'currency' => :'String',
85
+ :'metadata' => :'Hash<String, Object>',
86
+ :'applies_to' => :'Array<String>'
87
+ }
88
+ end
89
+
90
+ # List of attributes with nullable: true
91
+ def self.openapi_nullable
92
+ Set.new([
93
+ :'description',
94
+ :'metadata',
95
+ :'applies_to'
96
+ ])
97
+ end
98
+
99
+ # Initializes the object
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ def initialize(attributes = {})
102
+ if (!attributes.is_a?(Hash))
103
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MaytesApiClient::CheckoutDiscount` initialize method"
104
+ end
105
+
106
+ # check to see if the attribute exists and convert string to symbol for hash key
107
+ acceptable_attribute_map = self.class.acceptable_attribute_map
108
+ attributes = attributes.each_with_object({}) { |(k, v), h|
109
+ if (!acceptable_attribute_map.key?(k.to_sym))
110
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MaytesApiClient::CheckoutDiscount`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
111
+ end
112
+ h[k.to_sym] = v
113
+ }
114
+
115
+ if attributes.key?(:'name')
116
+ self.name = attributes[:'name']
117
+ else
118
+ self.name = nil
119
+ end
120
+
121
+ if attributes.key?(:'description')
122
+ self.description = attributes[:'description']
123
+ end
124
+
125
+ if attributes.key?(:'scope')
126
+ self.scope = attributes[:'scope']
127
+ else
128
+ self.scope = nil
129
+ end
130
+
131
+ if attributes.key?(:'amount')
132
+ self.amount = attributes[:'amount']
133
+ else
134
+ self.amount = nil
135
+ end
136
+
137
+ if attributes.key?(:'currency')
138
+ self.currency = attributes[:'currency']
139
+ else
140
+ self.currency = nil
141
+ end
142
+
143
+ if attributes.key?(:'metadata')
144
+ if (value = attributes[:'metadata']).is_a?(Hash)
145
+ self.metadata = value
146
+ end
147
+ end
148
+
149
+ if attributes.key?(:'applies_to')
150
+ if (value = attributes[:'applies_to']).is_a?(Array)
151
+ self.applies_to = value
152
+ end
153
+ end
154
+ end
155
+
156
+ # Show invalid properties with the reasons. Usually used together with valid?
157
+ # @return Array for valid properties with the reasons
158
+ def list_invalid_properties
159
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
160
+ invalid_properties = Array.new
161
+ if @name.nil?
162
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
163
+ end
164
+
165
+ if @name.to_s.length < 1
166
+ invalid_properties.push('invalid value for "name", the character length must be greater than or equal to 1.')
167
+ end
168
+
169
+ if @scope.nil?
170
+ invalid_properties.push('invalid value for "scope", scope cannot be nil.')
171
+ end
172
+
173
+ if @amount.nil?
174
+ invalid_properties.push('invalid value for "amount", amount cannot be nil.')
175
+ end
176
+
177
+ if @amount < 0
178
+ invalid_properties.push('invalid value for "amount", must be greater than or equal to 0.')
179
+ end
180
+
181
+ if @currency.nil?
182
+ invalid_properties.push('invalid value for "currency", currency cannot be nil.')
183
+ end
184
+
185
+ pattern = Regexp.new(/^[A-Z]{3}$/)
186
+ if @currency !~ pattern
187
+ invalid_properties.push("invalid value for \"currency\", must conform to the pattern #{pattern}.")
188
+ end
189
+
190
+ invalid_properties
191
+ end
192
+
193
+ # Check to see if the all the properties in the model are valid
194
+ # @return true if the model is valid
195
+ def valid?
196
+ warn '[DEPRECATED] the `valid?` method is obsolete'
197
+ return false if @name.nil?
198
+ return false if @name.to_s.length < 1
199
+ return false if @scope.nil?
200
+ scope_validator = EnumAttributeValidator.new('String', ["cart", "item"])
201
+ return false unless scope_validator.valid?(@scope)
202
+ return false if @amount.nil?
203
+ return false if @amount < 0
204
+ return false if @currency.nil?
205
+ return false if @currency !~ Regexp.new(/^[A-Z]{3}$/)
206
+ true
207
+ end
208
+
209
+ # Custom attribute writer method with validation
210
+ # @param [Object] name Value to be assigned
211
+ def name=(name)
212
+ if name.nil?
213
+ fail ArgumentError, 'name cannot be nil'
214
+ end
215
+
216
+ if name.to_s.length < 1
217
+ fail ArgumentError, 'invalid value for "name", the character length must be greater than or equal to 1.'
218
+ end
219
+
220
+ @name = name
221
+ end
222
+
223
+ # Custom attribute writer method checking allowed values (enum).
224
+ # @param [Object] scope Object to be assigned
225
+ def scope=(scope)
226
+ validator = EnumAttributeValidator.new('String', ["cart", "item"])
227
+ unless validator.valid?(scope)
228
+ fail ArgumentError, "invalid value for \"scope\", must be one of #{validator.allowable_values}."
229
+ end
230
+ @scope = scope
231
+ end
232
+
233
+ # Custom attribute writer method with validation
234
+ # @param [Object] amount Value to be assigned
235
+ def amount=(amount)
236
+ if amount.nil?
237
+ fail ArgumentError, 'amount cannot be nil'
238
+ end
239
+
240
+ if amount < 0
241
+ fail ArgumentError, 'invalid value for "amount", must be greater than or equal to 0.'
242
+ end
243
+
244
+ @amount = amount
245
+ end
246
+
247
+ # Custom attribute writer method with validation
248
+ # @param [Object] currency Value to be assigned
249
+ def currency=(currency)
250
+ if currency.nil?
251
+ fail ArgumentError, 'currency cannot be nil'
252
+ end
253
+
254
+ pattern = Regexp.new(/^[A-Z]{3}$/)
255
+ if currency !~ pattern
256
+ fail ArgumentError, "invalid value for \"currency\", must conform to the pattern #{pattern}."
257
+ end
258
+
259
+ @currency = currency
260
+ end
261
+
262
+ # Checks equality by comparing each attribute.
263
+ # @param [Object] Object to be compared
264
+ def ==(o)
265
+ return true if self.equal?(o)
266
+ self.class == o.class &&
267
+ name == o.name &&
268
+ description == o.description &&
269
+ scope == o.scope &&
270
+ amount == o.amount &&
271
+ currency == o.currency &&
272
+ metadata == o.metadata &&
273
+ applies_to == o.applies_to
274
+ end
275
+
276
+ # @see the `==` method
277
+ # @param [Object] Object to be compared
278
+ def eql?(o)
279
+ self == o
280
+ end
281
+
282
+ # Calculates hash code according to all attributes.
283
+ # @return [Integer] Hash code
284
+ def hash
285
+ [name, description, scope, amount, currency, metadata, applies_to].hash
286
+ end
287
+
288
+ # Builds the object from hash
289
+ # @param [Hash] attributes Model attributes in the form of hash
290
+ # @return [Object] Returns the model itself
291
+ def self.build_from_hash(attributes)
292
+ return nil unless attributes.is_a?(Hash)
293
+ attributes = attributes.transform_keys(&:to_sym)
294
+ transformed_hash = {}
295
+ openapi_types.each_pair do |key, type|
296
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
297
+ transformed_hash["#{key}"] = nil
298
+ elsif type =~ /\AArray<(.*)>/i
299
+ # check to ensure the input is an array given that the attribute
300
+ # is documented as an array but the input is not
301
+ if attributes[attribute_map[key]].is_a?(Array)
302
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
303
+ end
304
+ elsif !attributes[attribute_map[key]].nil?
305
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
306
+ end
307
+ end
308
+ new(transformed_hash)
309
+ end
310
+
311
+ # Returns the object in the form of hash
312
+ # @return [Hash] Returns the object in the form of hash
313
+ def to_hash
314
+ hash = {}
315
+ self.class.attribute_map.each_pair do |attr, param|
316
+ value = self.send(attr)
317
+ if value.nil?
318
+ is_nullable = self.class.openapi_nullable.include?(attr)
319
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
320
+ end
321
+
322
+ hash[param] = _to_hash(value)
323
+ end
324
+ hash
325
+ end
326
+
327
+ end
328
+
329
+ end
@@ -0,0 +1,351 @@
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 CheckoutFee < ApiModelBase
18
+ attr_accessor :name
19
+
20
+ attr_accessor :description
21
+
22
+ attr_accessor :fee_type
23
+
24
+ attr_accessor :scope
25
+
26
+ attr_accessor :amount
27
+
28
+ attr_accessor :currency
29
+
30
+ attr_accessor :metadata
31
+
32
+ attr_accessor :applies_to
33
+
34
+ class EnumAttributeValidator
35
+ attr_reader :datatype
36
+ attr_reader :allowable_values
37
+
38
+ def initialize(datatype, allowable_values)
39
+ @allowable_values = allowable_values.map do |value|
40
+ case datatype.to_s
41
+ when /Integer/i
42
+ value.to_i
43
+ when /Float/i
44
+ value.to_f
45
+ else
46
+ value
47
+ end
48
+ end
49
+ end
50
+
51
+ def valid?(value)
52
+ !value || allowable_values.include?(value)
53
+ end
54
+ end
55
+
56
+ # Attribute mapping from ruby-style variable name to JSON key.
57
+ def self.attribute_map
58
+ {
59
+ :'name' => :'name',
60
+ :'description' => :'description',
61
+ :'fee_type' => :'fee_type',
62
+ :'scope' => :'scope',
63
+ :'amount' => :'amount',
64
+ :'currency' => :'currency',
65
+ :'metadata' => :'metadata',
66
+ :'applies_to' => :'applies_to'
67
+ }
68
+ end
69
+
70
+ # Returns attribute mapping this model knows about
71
+ def self.acceptable_attribute_map
72
+ attribute_map
73
+ end
74
+
75
+ # Returns all the JSON keys this model knows about
76
+ def self.acceptable_attributes
77
+ acceptable_attribute_map.values
78
+ end
79
+
80
+ # Attribute type mapping.
81
+ def self.openapi_types
82
+ {
83
+ :'name' => :'String',
84
+ :'description' => :'String',
85
+ :'fee_type' => :'String',
86
+ :'scope' => :'String',
87
+ :'amount' => :'Integer',
88
+ :'currency' => :'String',
89
+ :'metadata' => :'Hash<String, Object>',
90
+ :'applies_to' => :'Array<String>'
91
+ }
92
+ end
93
+
94
+ # List of attributes with nullable: true
95
+ def self.openapi_nullable
96
+ Set.new([
97
+ :'description',
98
+ :'fee_type',
99
+ :'metadata',
100
+ :'applies_to'
101
+ ])
102
+ end
103
+
104
+ # Initializes the object
105
+ # @param [Hash] attributes Model attributes in the form of hash
106
+ def initialize(attributes = {})
107
+ if (!attributes.is_a?(Hash))
108
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MaytesApiClient::CheckoutFee` initialize method"
109
+ end
110
+
111
+ # check to see if the attribute exists and convert string to symbol for hash key
112
+ acceptable_attribute_map = self.class.acceptable_attribute_map
113
+ attributes = attributes.each_with_object({}) { |(k, v), h|
114
+ if (!acceptable_attribute_map.key?(k.to_sym))
115
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MaytesApiClient::CheckoutFee`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
116
+ end
117
+ h[k.to_sym] = v
118
+ }
119
+
120
+ if attributes.key?(:'name')
121
+ self.name = attributes[:'name']
122
+ else
123
+ self.name = nil
124
+ end
125
+
126
+ if attributes.key?(:'description')
127
+ self.description = attributes[:'description']
128
+ end
129
+
130
+ if attributes.key?(:'fee_type')
131
+ self.fee_type = attributes[:'fee_type']
132
+ end
133
+
134
+ if attributes.key?(:'scope')
135
+ self.scope = attributes[:'scope']
136
+ else
137
+ self.scope = nil
138
+ end
139
+
140
+ if attributes.key?(:'amount')
141
+ self.amount = attributes[:'amount']
142
+ else
143
+ self.amount = nil
144
+ end
145
+
146
+ if attributes.key?(:'currency')
147
+ self.currency = attributes[:'currency']
148
+ else
149
+ self.currency = nil
150
+ end
151
+
152
+ if attributes.key?(:'metadata')
153
+ if (value = attributes[:'metadata']).is_a?(Hash)
154
+ self.metadata = value
155
+ end
156
+ end
157
+
158
+ if attributes.key?(:'applies_to')
159
+ if (value = attributes[:'applies_to']).is_a?(Array)
160
+ self.applies_to = value
161
+ end
162
+ end
163
+ end
164
+
165
+ # Show invalid properties with the reasons. Usually used together with valid?
166
+ # @return Array for valid properties with the reasons
167
+ def list_invalid_properties
168
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
169
+ invalid_properties = Array.new
170
+ if @name.nil?
171
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
172
+ end
173
+
174
+ if @name.to_s.length < 1
175
+ invalid_properties.push('invalid value for "name", the character length must be greater than or equal to 1.')
176
+ end
177
+
178
+ if @scope.nil?
179
+ invalid_properties.push('invalid value for "scope", scope cannot be nil.')
180
+ end
181
+
182
+ if @amount.nil?
183
+ invalid_properties.push('invalid value for "amount", amount cannot be nil.')
184
+ end
185
+
186
+ if @amount < 0
187
+ invalid_properties.push('invalid value for "amount", must be greater than or equal to 0.')
188
+ end
189
+
190
+ if @currency.nil?
191
+ invalid_properties.push('invalid value for "currency", currency cannot be nil.')
192
+ end
193
+
194
+ pattern = Regexp.new(/^[A-Z]{3}$/)
195
+ if @currency !~ pattern
196
+ invalid_properties.push("invalid value for \"currency\", must conform to the pattern #{pattern}.")
197
+ end
198
+
199
+ invalid_properties
200
+ end
201
+
202
+ # Check to see if the all the properties in the model are valid
203
+ # @return true if the model is valid
204
+ def valid?
205
+ warn '[DEPRECATED] the `valid?` method is obsolete'
206
+ return false if @name.nil?
207
+ return false if @name.to_s.length < 1
208
+ fee_type_validator = EnumAttributeValidator.new('String', ["refund_protection", "surcharge", "transaction_fee", "service_fee", "delivery_fee", "carbon_offset", "other"])
209
+ return false unless fee_type_validator.valid?(@fee_type)
210
+ return false if @scope.nil?
211
+ scope_validator = EnumAttributeValidator.new('String', ["cart", "item"])
212
+ return false unless scope_validator.valid?(@scope)
213
+ return false if @amount.nil?
214
+ return false if @amount < 0
215
+ return false if @currency.nil?
216
+ return false if @currency !~ Regexp.new(/^[A-Z]{3}$/)
217
+ true
218
+ end
219
+
220
+ # Custom attribute writer method with validation
221
+ # @param [Object] name Value to be assigned
222
+ def name=(name)
223
+ if name.nil?
224
+ fail ArgumentError, 'name cannot be nil'
225
+ end
226
+
227
+ if name.to_s.length < 1
228
+ fail ArgumentError, 'invalid value for "name", the character length must be greater than or equal to 1.'
229
+ end
230
+
231
+ @name = name
232
+ end
233
+
234
+ # Custom attribute writer method checking allowed values (enum).
235
+ # @param [Object] fee_type Object to be assigned
236
+ def fee_type=(fee_type)
237
+ validator = EnumAttributeValidator.new('String', ["refund_protection", "surcharge", "transaction_fee", "service_fee", "delivery_fee", "carbon_offset", "other"])
238
+ unless validator.valid?(fee_type)
239
+ fail ArgumentError, "invalid value for \"fee_type\", must be one of #{validator.allowable_values}."
240
+ end
241
+ @fee_type = fee_type
242
+ end
243
+
244
+ # Custom attribute writer method checking allowed values (enum).
245
+ # @param [Object] scope Object to be assigned
246
+ def scope=(scope)
247
+ validator = EnumAttributeValidator.new('String', ["cart", "item"])
248
+ unless validator.valid?(scope)
249
+ fail ArgumentError, "invalid value for \"scope\", must be one of #{validator.allowable_values}."
250
+ end
251
+ @scope = scope
252
+ end
253
+
254
+ # Custom attribute writer method with validation
255
+ # @param [Object] amount Value to be assigned
256
+ def amount=(amount)
257
+ if amount.nil?
258
+ fail ArgumentError, 'amount cannot be nil'
259
+ end
260
+
261
+ if amount < 0
262
+ fail ArgumentError, 'invalid value for "amount", must be greater than or equal to 0.'
263
+ end
264
+
265
+ @amount = amount
266
+ end
267
+
268
+ # Custom attribute writer method with validation
269
+ # @param [Object] currency Value to be assigned
270
+ def currency=(currency)
271
+ if currency.nil?
272
+ fail ArgumentError, 'currency cannot be nil'
273
+ end
274
+
275
+ pattern = Regexp.new(/^[A-Z]{3}$/)
276
+ if currency !~ pattern
277
+ fail ArgumentError, "invalid value for \"currency\", must conform to the pattern #{pattern}."
278
+ end
279
+
280
+ @currency = currency
281
+ end
282
+
283
+ # Checks equality by comparing each attribute.
284
+ # @param [Object] Object to be compared
285
+ def ==(o)
286
+ return true if self.equal?(o)
287
+ self.class == o.class &&
288
+ name == o.name &&
289
+ description == o.description &&
290
+ fee_type == o.fee_type &&
291
+ scope == o.scope &&
292
+ amount == o.amount &&
293
+ currency == o.currency &&
294
+ metadata == o.metadata &&
295
+ applies_to == o.applies_to
296
+ end
297
+
298
+ # @see the `==` method
299
+ # @param [Object] Object to be compared
300
+ def eql?(o)
301
+ self == o
302
+ end
303
+
304
+ # Calculates hash code according to all attributes.
305
+ # @return [Integer] Hash code
306
+ def hash
307
+ [name, description, fee_type, scope, amount, currency, metadata, applies_to].hash
308
+ end
309
+
310
+ # Builds the object from hash
311
+ # @param [Hash] attributes Model attributes in the form of hash
312
+ # @return [Object] Returns the model itself
313
+ def self.build_from_hash(attributes)
314
+ return nil unless attributes.is_a?(Hash)
315
+ attributes = attributes.transform_keys(&:to_sym)
316
+ transformed_hash = {}
317
+ openapi_types.each_pair do |key, type|
318
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
319
+ transformed_hash["#{key}"] = nil
320
+ elsif type =~ /\AArray<(.*)>/i
321
+ # check to ensure the input is an array given that the attribute
322
+ # is documented as an array but the input is not
323
+ if attributes[attribute_map[key]].is_a?(Array)
324
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
325
+ end
326
+ elsif !attributes[attribute_map[key]].nil?
327
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
328
+ end
329
+ end
330
+ new(transformed_hash)
331
+ end
332
+
333
+ # Returns the object in the form of hash
334
+ # @return [Hash] Returns the object in the form of hash
335
+ def to_hash
336
+ hash = {}
337
+ self.class.attribute_map.each_pair do |attr, param|
338
+ value = self.send(attr)
339
+ if value.nil?
340
+ is_nullable = self.class.openapi_nullable.include?(attr)
341
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
342
+ end
343
+
344
+ hash[param] = _to_hash(value)
345
+ end
346
+ hash
347
+ end
348
+
349
+ end
350
+
351
+ end