billabear 1.0.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 (187) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +1340 -0
  4. data/Rakefile +8 -0
  5. data/billabear.gemspec +38 -0
  6. data/docs/Address.md +13 -0
  7. data/docs/BillingAdmin.md +8 -0
  8. data/docs/CheckoutApi.md +61 -0
  9. data/docs/CheckoutBody.md +12 -0
  10. data/docs/CheckoutItems.md +11 -0
  11. data/docs/CheckoutSubscriptions.md +9 -0
  12. data/docs/Customer.md +18 -0
  13. data/docs/CustomersApi.md +904 -0
  14. data/docs/Error.md +8 -0
  15. data/docs/Feature.md +10 -0
  16. data/docs/FrontendToken.md +7 -0
  17. data/docs/InlineResponse200.md +9 -0
  18. data/docs/InlineResponse2001.md +9 -0
  19. data/docs/InlineResponse20010.md +9 -0
  20. data/docs/InlineResponse20011.md +7 -0
  21. data/docs/InlineResponse20012.md +8 -0
  22. data/docs/InlineResponse2002.md +9 -0
  23. data/docs/InlineResponse2003.md +9 -0
  24. data/docs/InlineResponse2004.md +9 -0
  25. data/docs/InlineResponse2005.md +9 -0
  26. data/docs/InlineResponse2006.md +9 -0
  27. data/docs/InlineResponse2007.md +9 -0
  28. data/docs/InlineResponse2007Data.md +14 -0
  29. data/docs/InlineResponse2007Receipts.md +9 -0
  30. data/docs/InlineResponse2008.md +9 -0
  31. data/docs/InlineResponse2009.md +9 -0
  32. data/docs/InlineResponse201.md +15 -0
  33. data/docs/InlineResponse201Lines.md +14 -0
  34. data/docs/InlineResponse400.md +7 -0
  35. data/docs/Invoice.md +21 -0
  36. data/docs/InvoiceLines.md +12 -0
  37. data/docs/InvoicesApi.md +169 -0
  38. data/docs/IssueRefundPayment.md +9 -0
  39. data/docs/Limit.md +8 -0
  40. data/docs/PaymentDetails.md +14 -0
  41. data/docs/PaymentDetailsApi.md +447 -0
  42. data/docs/PaymentsApi.md +399 -0
  43. data/docs/Price.md +14 -0
  44. data/docs/PricesApi.md +122 -0
  45. data/docs/Product.md +10 -0
  46. data/docs/ProductTaxType.md +9 -0
  47. data/docs/ProductsApi.md +228 -0
  48. data/docs/ReceiptApi.md +61 -0
  49. data/docs/Refund.md +16 -0
  50. data/docs/RefundsApi.md +181 -0
  51. data/docs/SeatsAddBody.md +7 -0
  52. data/docs/SeatsRemoveBody.md +7 -0
  53. data/docs/Subscription.md +18 -0
  54. data/docs/SubscriptionIdCancelBody.md +10 -0
  55. data/docs/SubscriptionIdExtendBody.md +7 -0
  56. data/docs/SubscriptionIdPlanBody.md +9 -0
  57. data/docs/SubscriptionIdPriceBody.md +8 -0
  58. data/docs/SubscriptionPlan.md +20 -0
  59. data/docs/SubscriptionStartBody.md +14 -0
  60. data/docs/SubscriptionTrialBody.md +10 -0
  61. data/docs/SubscriptionsApi.md +731 -0
  62. data/docs/VoucherCode.md +7 -0
  63. data/git_push.sh +55 -0
  64. data/lib/swagger_client/api/checkout_api.rb +78 -0
  65. data/lib/swagger_client/api/customers_api.rb +980 -0
  66. data/lib/swagger_client/api/invoices_api.rb +188 -0
  67. data/lib/swagger_client/api/payment_details_api.rb +494 -0
  68. data/lib/swagger_client/api/payments_api.rb +432 -0
  69. data/lib/swagger_client/api/prices_api.rb +146 -0
  70. data/lib/swagger_client/api/products_api.rb +249 -0
  71. data/lib/swagger_client/api/receipt_api.rb +76 -0
  72. data/lib/swagger_client/api/refunds_api.rb +200 -0
  73. data/lib/swagger_client/api/subscriptions_api.rb +812 -0
  74. data/lib/swagger_client/api_client.rb +388 -0
  75. data/lib/swagger_client/api_error.rb +57 -0
  76. data/lib/swagger_client/configuration.rb +205 -0
  77. data/lib/swagger_client/models/address.rb +265 -0
  78. data/lib/swagger_client/models/billing_admin.rb +215 -0
  79. data/lib/swagger_client/models/checkout_body.rb +265 -0
  80. data/lib/swagger_client/models/checkout_items.rb +242 -0
  81. data/lib/swagger_client/models/checkout_subscriptions.rb +224 -0
  82. data/lib/swagger_client/models/customer.rb +370 -0
  83. data/lib/swagger_client/models/error.rb +225 -0
  84. data/lib/swagger_client/models/feature.rb +240 -0
  85. data/lib/swagger_client/models/frontend_token.rb +211 -0
  86. data/lib/swagger_client/models/inline_response_200.rb +226 -0
  87. data/lib/swagger_client/models/inline_response_200_1.rb +228 -0
  88. data/lib/swagger_client/models/inline_response_200_10.rb +226 -0
  89. data/lib/swagger_client/models/inline_response_200_11.rb +206 -0
  90. data/lib/swagger_client/models/inline_response_200_12.rb +250 -0
  91. data/lib/swagger_client/models/inline_response_200_2.rb +226 -0
  92. data/lib/swagger_client/models/inline_response_200_3.rb +226 -0
  93. data/lib/swagger_client/models/inline_response_200_4.rb +226 -0
  94. data/lib/swagger_client/models/inline_response_200_5.rb +226 -0
  95. data/lib/swagger_client/models/inline_response_200_6.rb +226 -0
  96. data/lib/swagger_client/models/inline_response_200_7.rb +226 -0
  97. data/lib/swagger_client/models/inline_response_200_7_data.rb +307 -0
  98. data/lib/swagger_client/models/inline_response_200_7_receipts.rb +224 -0
  99. data/lib/swagger_client/models/inline_response_200_8.rb +226 -0
  100. data/lib/swagger_client/models/inline_response_200_9.rb +226 -0
  101. data/lib/swagger_client/models/inline_response_201.rb +285 -0
  102. data/lib/swagger_client/models/inline_response_201_lines.rb +269 -0
  103. data/lib/swagger_client/models/inline_response_400.rb +213 -0
  104. data/lib/swagger_client/models/invoice.rb +334 -0
  105. data/lib/swagger_client/models/invoice_lines.rb +251 -0
  106. data/lib/swagger_client/models/issue_refund_payment.rb +232 -0
  107. data/lib/swagger_client/models/limit.rb +215 -0
  108. data/lib/swagger_client/models/payment_details.rb +271 -0
  109. data/lib/swagger_client/models/price.rb +325 -0
  110. data/lib/swagger_client/models/product.rb +240 -0
  111. data/lib/swagger_client/models/product_tax_type.rb +229 -0
  112. data/lib/swagger_client/models/refund.rb +324 -0
  113. data/lib/swagger_client/models/seats_add_body.rb +211 -0
  114. data/lib/swagger_client/models/seats_remove_body.rb +211 -0
  115. data/lib/swagger_client/models/subscription.rb +305 -0
  116. data/lib/swagger_client/models/subscription_id_cancel_body.rb +294 -0
  117. data/lib/swagger_client/models/subscription_id_extend_body.rb +211 -0
  118. data/lib/swagger_client/models/subscription_id_plan_body.rb +270 -0
  119. data/lib/swagger_client/models/subscription_id_price_body.rb +259 -0
  120. data/lib/swagger_client/models/subscription_plan.rb +330 -0
  121. data/lib/swagger_client/models/subscription_start_body.rb +314 -0
  122. data/lib/swagger_client/models/subscription_trial_body.rb +242 -0
  123. data/lib/swagger_client/models/voucher_code.rb +211 -0
  124. data/lib/swagger_client/version.rb +14 -0
  125. data/lib/swagger_client.rb +95 -0
  126. data/spec/api/checkout_api_spec.rb +46 -0
  127. data/spec/api/customers_api_spec.rb +241 -0
  128. data/spec/api/invoices_api_spec.rb +70 -0
  129. data/spec/api/payment_details_api_spec.rb +134 -0
  130. data/spec/api/payments_api_spec.rb +124 -0
  131. data/spec/api/prices_api_spec.rb +61 -0
  132. data/spec/api/products_api_spec.rb +84 -0
  133. data/spec/api/receipt_api_spec.rb +46 -0
  134. data/spec/api/refunds_api_spec.rb +75 -0
  135. data/spec/api/subscriptions_api_spec.rb +200 -0
  136. data/spec/api_client_spec.rb +225 -0
  137. data/spec/base_object_spec.rb +109 -0
  138. data/spec/configuration_spec.rb +41 -0
  139. data/spec/models/address_spec.rb +76 -0
  140. data/spec/models/billing_admin_spec.rb +46 -0
  141. data/spec/models/checkout_body_spec.rb +70 -0
  142. data/spec/models/checkout_items_spec.rb +64 -0
  143. data/spec/models/checkout_subscriptions_spec.rb +52 -0
  144. data/spec/models/customer_spec.rb +114 -0
  145. data/spec/models/error_spec.rb +46 -0
  146. data/spec/models/feature_spec.rb +58 -0
  147. data/spec/models/frontend_token_spec.rb +40 -0
  148. data/spec/models/inline_response_200_10_spec.rb +52 -0
  149. data/spec/models/inline_response_200_11_spec.rb +40 -0
  150. data/spec/models/inline_response_200_12_spec.rb +50 -0
  151. data/spec/models/inline_response_200_1_spec.rb +52 -0
  152. data/spec/models/inline_response_200_2_spec.rb +52 -0
  153. data/spec/models/inline_response_200_3_spec.rb +52 -0
  154. data/spec/models/inline_response_200_4_spec.rb +52 -0
  155. data/spec/models/inline_response_200_5_spec.rb +52 -0
  156. data/spec/models/inline_response_200_6_spec.rb +52 -0
  157. data/spec/models/inline_response_200_7_data_spec.rb +86 -0
  158. data/spec/models/inline_response_200_7_receipts_spec.rb +52 -0
  159. data/spec/models/inline_response_200_7_spec.rb +52 -0
  160. data/spec/models/inline_response_200_8_spec.rb +52 -0
  161. data/spec/models/inline_response_200_9_spec.rb +52 -0
  162. data/spec/models/inline_response_200_spec.rb +52 -0
  163. data/spec/models/inline_response_201_lines_spec.rb +82 -0
  164. data/spec/models/inline_response_201_spec.rb +88 -0
  165. data/spec/models/inline_response_400_spec.rb +40 -0
  166. data/spec/models/invoice_lines_spec.rb +70 -0
  167. data/spec/models/invoice_spec.rb +124 -0
  168. data/spec/models/issue_refund_payment_spec.rb +52 -0
  169. data/spec/models/limit_spec.rb +46 -0
  170. data/spec/models/payment_details_spec.rb +82 -0
  171. data/spec/models/price_spec.rb +86 -0
  172. data/spec/models/product_spec.rb +58 -0
  173. data/spec/models/product_tax_type_spec.rb +52 -0
  174. data/spec/models/refund_spec.rb +98 -0
  175. data/spec/models/seats_add_body_spec.rb +40 -0
  176. data/spec/models/seats_remove_body_spec.rb +40 -0
  177. data/spec/models/subscription_id_cancel_body_spec.rb +66 -0
  178. data/spec/models/subscription_id_extend_body_spec.rb +40 -0
  179. data/spec/models/subscription_id_plan_body_spec.rb +56 -0
  180. data/spec/models/subscription_id_price_body_spec.rb +50 -0
  181. data/spec/models/subscription_plan_spec.rb +118 -0
  182. data/spec/models/subscription_spec.rb +106 -0
  183. data/spec/models/subscription_start_body_spec.rb +86 -0
  184. data/spec/models/subscription_trial_body_spec.rb +58 -0
  185. data/spec/models/voucher_code_spec.rb +40 -0
  186. data/spec/spec_helper.rb +110 -0
  187. metadata +349 -0
@@ -0,0 +1,270 @@
1
+ =begin
2
+ #BillaBear
3
+
4
+ #The REST API provided by BillaBear
5
+
6
+ OpenAPI spec version: 1.0.0
7
+ Contact: support@billabear.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 3.0.56
10
+ =end
11
+
12
+ require 'date'
13
+
14
+ module SwaggerClient
15
+ class SubscriptionIdPlanBody
16
+ attr_accessor :_when
17
+
18
+ # The ID for the subscription plan to be used
19
+ attr_accessor :plan
20
+
21
+ # The ID for the price to be used
22
+ attr_accessor :price
23
+
24
+ class EnumAttributeValidator
25
+ attr_reader :datatype
26
+ attr_reader :allowable_values
27
+
28
+ def initialize(datatype, allowable_values)
29
+ @allowable_values = allowable_values.map do |value|
30
+ case datatype.to_s
31
+ when /Integer/i
32
+ value.to_i
33
+ when /Float/i
34
+ value.to_f
35
+ else
36
+ value
37
+ end
38
+ end
39
+ end
40
+
41
+ def valid?(value)
42
+ !value || allowable_values.include?(value)
43
+ end
44
+ end
45
+
46
+ # Attribute mapping from ruby-style variable name to JSON key.
47
+ def self.attribute_map
48
+ {
49
+ :'_when' => :'when',
50
+ :'plan' => :'plan',
51
+ :'price' => :'price'
52
+ }
53
+ end
54
+
55
+ # Attribute type mapping.
56
+ def self.openapi_types
57
+ {
58
+ :'_when' => :'Object',
59
+ :'plan' => :'Object',
60
+ :'price' => :'Object'
61
+ }
62
+ end
63
+
64
+ # List of attributes with nullable: true
65
+ def self.openapi_nullable
66
+ Set.new([
67
+ ])
68
+ end
69
+
70
+ # Initializes the object
71
+ # @param [Hash] attributes Model attributes in the form of hash
72
+ def initialize(attributes = {})
73
+ if (!attributes.is_a?(Hash))
74
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SwaggerClient::SubscriptionIdPlanBody` initialize method"
75
+ end
76
+
77
+ # check to see if the attribute exists and convert string to symbol for hash key
78
+ attributes = attributes.each_with_object({}) { |(k, v), h|
79
+ if (!self.class.attribute_map.key?(k.to_sym))
80
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SwaggerClient::SubscriptionIdPlanBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
81
+ end
82
+ h[k.to_sym] = v
83
+ }
84
+
85
+ if attributes.key?(:'_when')
86
+ self._when = attributes[:'_when']
87
+ end
88
+
89
+ if attributes.key?(:'plan')
90
+ self.plan = attributes[:'plan']
91
+ end
92
+
93
+ if attributes.key?(:'price')
94
+ self.price = attributes[:'price']
95
+ end
96
+ end
97
+
98
+ # Show invalid properties with the reasons. Usually used together with valid?
99
+ # @return Array for valid properties with the reasons
100
+ def list_invalid_properties
101
+ invalid_properties = Array.new
102
+ if @_when.nil?
103
+ invalid_properties.push('invalid value for "_when", _when cannot be nil.')
104
+ end
105
+
106
+ if @price.nil?
107
+ invalid_properties.push('invalid value for "price", price cannot be nil.')
108
+ end
109
+
110
+ invalid_properties
111
+ end
112
+
113
+ # Check to see if the all the properties in the model are valid
114
+ # @return true if the model is valid
115
+ def valid?
116
+ return false if @_when.nil?
117
+ _when_validator = EnumAttributeValidator.new('Object', ['instantly', 'next-cycle'])
118
+ return false unless _when_validator.valid?(@_when)
119
+ return false if @price.nil?
120
+ true
121
+ end
122
+
123
+ # Custom attribute writer method checking allowed values (enum).
124
+ # @param [Object] _when Object to be assigned
125
+ def _when=(_when)
126
+ validator = EnumAttributeValidator.new('Object', ['instantly', 'next-cycle'])
127
+ unless validator.valid?(_when)
128
+ fail ArgumentError, "invalid value for \"_when\", must be one of #{validator.allowable_values}."
129
+ end
130
+ @_when = _when
131
+ end
132
+
133
+ # Checks equality by comparing each attribute.
134
+ # @param [Object] Object to be compared
135
+ def ==(o)
136
+ return true if self.equal?(o)
137
+ self.class == o.class &&
138
+ _when == o._when &&
139
+ plan == o.plan &&
140
+ price == o.price
141
+ end
142
+
143
+ # @see the `==` method
144
+ # @param [Object] Object to be compared
145
+ def eql?(o)
146
+ self == o
147
+ end
148
+
149
+ # Calculates hash code according to all attributes.
150
+ # @return [Integer] Hash code
151
+ def hash
152
+ [_when, plan, price].hash
153
+ end
154
+
155
+ # Builds the object from hash
156
+ # @param [Hash] attributes Model attributes in the form of hash
157
+ # @return [Object] Returns the model itself
158
+ def self.build_from_hash(attributes)
159
+ new.build_from_hash(attributes)
160
+ end
161
+
162
+ # Builds the object from hash
163
+ # @param [Hash] attributes Model attributes in the form of hash
164
+ # @return [Object] Returns the model itself
165
+ def build_from_hash(attributes)
166
+ return nil unless attributes.is_a?(Hash)
167
+ self.class.openapi_types.each_pair do |key, type|
168
+ if type =~ /\AArray<(.*)>/i
169
+ # check to ensure the input is an array given that the attribute
170
+ # is documented as an array but the input is not
171
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
172
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
173
+ end
174
+ elsif !attributes[self.class.attribute_map[key]].nil?
175
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
176
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
177
+ self.send("#{key}=", nil)
178
+ end
179
+ end
180
+
181
+ self
182
+ end
183
+
184
+ # Deserializes the data based on type
185
+ # @param string type Data type
186
+ # @param string value Value to be deserialized
187
+ # @return [Object] Deserialized data
188
+ def _deserialize(type, value)
189
+ case type.to_sym
190
+ when :DateTime
191
+ DateTime.parse(value)
192
+ when :Date
193
+ Date.parse(value)
194
+ when :String
195
+ value.to_s
196
+ when :Integer
197
+ value.to_i
198
+ when :Float
199
+ value.to_f
200
+ when :Boolean
201
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
202
+ true
203
+ else
204
+ false
205
+ end
206
+ when :Object
207
+ # generic object (usually a Hash), return directly
208
+ value
209
+ when /\AArray<(?<inner_type>.+)>\z/
210
+ inner_type = Regexp.last_match[:inner_type]
211
+ value.map { |v| _deserialize(inner_type, v) }
212
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
213
+ k_type = Regexp.last_match[:k_type]
214
+ v_type = Regexp.last_match[:v_type]
215
+ {}.tap do |hash|
216
+ value.each do |k, v|
217
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
218
+ end
219
+ end
220
+ else # model
221
+ SwaggerClient.const_get(type).build_from_hash(value)
222
+ end
223
+ end
224
+
225
+ # Returns the string representation of the object
226
+ # @return [String] String presentation of the object
227
+ def to_s
228
+ to_hash.to_s
229
+ end
230
+
231
+ # to_body is an alias to to_hash (backward compatibility)
232
+ # @return [Hash] Returns the object in the form of hash
233
+ def to_body
234
+ to_hash
235
+ end
236
+
237
+ # Returns the object in the form of hash
238
+ # @return [Hash] Returns the object in the form of hash
239
+ def to_hash
240
+ hash = {}
241
+ self.class.attribute_map.each_pair do |attr, param|
242
+ value = self.send(attr)
243
+ if value.nil?
244
+ is_nullable = self.class.openapi_nullable.include?(attr)
245
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
246
+ end
247
+
248
+ hash[param] = _to_hash(value)
249
+ end
250
+ hash
251
+ end
252
+
253
+ # Outputs non-array value in the form of hash
254
+ # For object, use to_hash. Otherwise, just return the value
255
+ # @param [Object] value Any valid value
256
+ # @return [Hash] Returns the value in the form of hash
257
+ def _to_hash(value)
258
+ if value.is_a?(Array)
259
+ value.compact.map { |v| _to_hash(v) }
260
+ elsif value.is_a?(Hash)
261
+ {}.tap do |hash|
262
+ value.each { |k, v| hash[k] = _to_hash(v) }
263
+ end
264
+ elsif value.respond_to? :to_hash
265
+ value.to_hash
266
+ else
267
+ value
268
+ end
269
+ end end
270
+ end
@@ -0,0 +1,259 @@
1
+ =begin
2
+ #BillaBear
3
+
4
+ #The REST API provided by BillaBear
5
+
6
+ OpenAPI spec version: 1.0.0
7
+ Contact: support@billabear.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 3.0.56
10
+ =end
11
+
12
+ require 'date'
13
+
14
+ module SwaggerClient
15
+ class SubscriptionIdPriceBody
16
+ attr_accessor :price
17
+
18
+ attr_accessor :_when
19
+
20
+ class EnumAttributeValidator
21
+ attr_reader :datatype
22
+ attr_reader :allowable_values
23
+
24
+ def initialize(datatype, allowable_values)
25
+ @allowable_values = allowable_values.map do |value|
26
+ case datatype.to_s
27
+ when /Integer/i
28
+ value.to_i
29
+ when /Float/i
30
+ value.to_f
31
+ else
32
+ value
33
+ end
34
+ end
35
+ end
36
+
37
+ def valid?(value)
38
+ !value || allowable_values.include?(value)
39
+ end
40
+ end
41
+
42
+ # Attribute mapping from ruby-style variable name to JSON key.
43
+ def self.attribute_map
44
+ {
45
+ :'price' => :'price',
46
+ :'_when' => :'when'
47
+ }
48
+ end
49
+
50
+ # Attribute type mapping.
51
+ def self.openapi_types
52
+ {
53
+ :'price' => :'Object',
54
+ :'_when' => :'Object'
55
+ }
56
+ end
57
+
58
+ # List of attributes with nullable: true
59
+ def self.openapi_nullable
60
+ Set.new([
61
+ ])
62
+ end
63
+
64
+ # Initializes the object
65
+ # @param [Hash] attributes Model attributes in the form of hash
66
+ def initialize(attributes = {})
67
+ if (!attributes.is_a?(Hash))
68
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SwaggerClient::SubscriptionIdPriceBody` initialize method"
69
+ end
70
+
71
+ # check to see if the attribute exists and convert string to symbol for hash key
72
+ attributes = attributes.each_with_object({}) { |(k, v), h|
73
+ if (!self.class.attribute_map.key?(k.to_sym))
74
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SwaggerClient::SubscriptionIdPriceBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
75
+ end
76
+ h[k.to_sym] = v
77
+ }
78
+
79
+ if attributes.key?(:'price')
80
+ self.price = attributes[:'price']
81
+ end
82
+
83
+ if attributes.key?(:'_when')
84
+ self._when = attributes[:'_when']
85
+ end
86
+ end
87
+
88
+ # Show invalid properties with the reasons. Usually used together with valid?
89
+ # @return Array for valid properties with the reasons
90
+ def list_invalid_properties
91
+ invalid_properties = Array.new
92
+ if @price.nil?
93
+ invalid_properties.push('invalid value for "price", price cannot be nil.')
94
+ end
95
+
96
+ if @_when.nil?
97
+ invalid_properties.push('invalid value for "_when", _when cannot be nil.')
98
+ end
99
+
100
+ invalid_properties
101
+ end
102
+
103
+ # Check to see if the all the properties in the model are valid
104
+ # @return true if the model is valid
105
+ def valid?
106
+ return false if @price.nil?
107
+ return false if @_when.nil?
108
+ _when_validator = EnumAttributeValidator.new('Object', ['next_cycle', 'instantly'])
109
+ return false unless _when_validator.valid?(@_when)
110
+ true
111
+ end
112
+
113
+ # Custom attribute writer method checking allowed values (enum).
114
+ # @param [Object] _when Object to be assigned
115
+ def _when=(_when)
116
+ validator = EnumAttributeValidator.new('Object', ['next_cycle', 'instantly'])
117
+ unless validator.valid?(_when)
118
+ fail ArgumentError, "invalid value for \"_when\", must be one of #{validator.allowable_values}."
119
+ end
120
+ @_when = _when
121
+ end
122
+
123
+ # Checks equality by comparing each attribute.
124
+ # @param [Object] Object to be compared
125
+ def ==(o)
126
+ return true if self.equal?(o)
127
+ self.class == o.class &&
128
+ price == o.price &&
129
+ _when == o._when
130
+ end
131
+
132
+ # @see the `==` method
133
+ # @param [Object] Object to be compared
134
+ def eql?(o)
135
+ self == o
136
+ end
137
+
138
+ # Calculates hash code according to all attributes.
139
+ # @return [Integer] Hash code
140
+ def hash
141
+ [price, _when].hash
142
+ end
143
+
144
+ # Builds the object from hash
145
+ # @param [Hash] attributes Model attributes in the form of hash
146
+ # @return [Object] Returns the model itself
147
+ def self.build_from_hash(attributes)
148
+ new.build_from_hash(attributes)
149
+ end
150
+
151
+ # Builds the object from hash
152
+ # @param [Hash] attributes Model attributes in the form of hash
153
+ # @return [Object] Returns the model itself
154
+ def build_from_hash(attributes)
155
+ return nil unless attributes.is_a?(Hash)
156
+ self.class.openapi_types.each_pair do |key, type|
157
+ if type =~ /\AArray<(.*)>/i
158
+ # check to ensure the input is an array given that the attribute
159
+ # is documented as an array but the input is not
160
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
161
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
162
+ end
163
+ elsif !attributes[self.class.attribute_map[key]].nil?
164
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
165
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
166
+ self.send("#{key}=", nil)
167
+ end
168
+ end
169
+
170
+ self
171
+ end
172
+
173
+ # Deserializes the data based on type
174
+ # @param string type Data type
175
+ # @param string value Value to be deserialized
176
+ # @return [Object] Deserialized data
177
+ def _deserialize(type, value)
178
+ case type.to_sym
179
+ when :DateTime
180
+ DateTime.parse(value)
181
+ when :Date
182
+ Date.parse(value)
183
+ when :String
184
+ value.to_s
185
+ when :Integer
186
+ value.to_i
187
+ when :Float
188
+ value.to_f
189
+ when :Boolean
190
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
191
+ true
192
+ else
193
+ false
194
+ end
195
+ when :Object
196
+ # generic object (usually a Hash), return directly
197
+ value
198
+ when /\AArray<(?<inner_type>.+)>\z/
199
+ inner_type = Regexp.last_match[:inner_type]
200
+ value.map { |v| _deserialize(inner_type, v) }
201
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
202
+ k_type = Regexp.last_match[:k_type]
203
+ v_type = Regexp.last_match[:v_type]
204
+ {}.tap do |hash|
205
+ value.each do |k, v|
206
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
207
+ end
208
+ end
209
+ else # model
210
+ SwaggerClient.const_get(type).build_from_hash(value)
211
+ end
212
+ end
213
+
214
+ # Returns the string representation of the object
215
+ # @return [String] String presentation of the object
216
+ def to_s
217
+ to_hash.to_s
218
+ end
219
+
220
+ # to_body is an alias to to_hash (backward compatibility)
221
+ # @return [Hash] Returns the object in the form of hash
222
+ def to_body
223
+ to_hash
224
+ end
225
+
226
+ # Returns the object in the form of hash
227
+ # @return [Hash] Returns the object in the form of hash
228
+ def to_hash
229
+ hash = {}
230
+ self.class.attribute_map.each_pair do |attr, param|
231
+ value = self.send(attr)
232
+ if value.nil?
233
+ is_nullable = self.class.openapi_nullable.include?(attr)
234
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
235
+ end
236
+
237
+ hash[param] = _to_hash(value)
238
+ end
239
+ hash
240
+ end
241
+
242
+ # Outputs non-array value in the form of hash
243
+ # For object, use to_hash. Otherwise, just return the value
244
+ # @param [Object] value Any valid value
245
+ # @return [Hash] Returns the value in the form of hash
246
+ def _to_hash(value)
247
+ if value.is_a?(Array)
248
+ value.compact.map { |v| _to_hash(v) }
249
+ elsif value.is_a?(Hash)
250
+ {}.tap do |hash|
251
+ value.each { |k, v| hash[k] = _to_hash(v) }
252
+ end
253
+ elsif value.respond_to? :to_hash
254
+ value.to_hash
255
+ else
256
+ value
257
+ end
258
+ end end
259
+ end