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