togai_client 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 +61 -0
  4. data/Rakefile +10 -0
  5. data/docs/Account.md +24 -0
  6. data/docs/AccountAliases.md +20 -0
  7. data/docs/AccountPaginatedResponse.md +22 -0
  8. data/docs/AccountsApi.md +595 -0
  9. data/docs/AddAccountAliasesRequest.md +18 -0
  10. data/docs/AssociatePricePlanRequest.md +24 -0
  11. data/docs/AssociatePricePlanResponse.md +22 -0
  12. data/docs/BaseSuccessResponse.md +18 -0
  13. data/docs/BundleStrategy.md +24 -0
  14. data/docs/BundleStrategyUsageMetersValue.md +18 -0
  15. data/docs/Computation.md +31 -0
  16. data/docs/CreateAccountRequest.md +22 -0
  17. data/docs/CreateCustomerRequest.md +26 -0
  18. data/docs/CreateCustomerResponse.md +26 -0
  19. data/docs/CreateEventSchemaRequest.md +24 -0
  20. data/docs/CreatePricePlanRequest.md +24 -0
  21. data/docs/CreateUsageMeterRequest.md +26 -0
  22. data/docs/Customer.md +30 -0
  23. data/docs/CustomerPaginatedResponse.md +22 -0
  24. data/docs/CustomersApi.md +363 -0
  25. data/docs/DimensionsSchema.md +18 -0
  26. data/docs/ErrorResponse.md +18 -0
  27. data/docs/Event.md +28 -0
  28. data/docs/EventAttribute.md +22 -0
  29. data/docs/EventAttributeSchema.md +20 -0
  30. data/docs/EventIngestionApi.md +146 -0
  31. data/docs/EventManagementApi.md +159 -0
  32. data/docs/EventPipelineInfo.md +26 -0
  33. data/docs/EventPipelineInfoAccount.md +20 -0
  34. data/docs/EventPipelineInfoCustomer.md +20 -0
  35. data/docs/EventPipelineInfoEventSchema.md +20 -0
  36. data/docs/EventPipelineInfoPricePlansInner.md +26 -0
  37. data/docs/EventPipelineInfoUsageMetersInner.md +24 -0
  38. data/docs/EventSchema.md +32 -0
  39. data/docs/EventSchemaListData.md +34 -0
  40. data/docs/EventSchemaListDataAllOf.md +18 -0
  41. data/docs/EventSchemaListPaginatedResponse.md +22 -0
  42. data/docs/EventSchemaVersionsResponse.md +18 -0
  43. data/docs/EventSchemasApi.md +581 -0
  44. data/docs/EventWithStatus.md +20 -0
  45. data/docs/EventWithStatusAndEventPipelineInfo.md +22 -0
  46. data/docs/EventWithStatusAndEventPipelineInfoAllOf.md +18 -0
  47. data/docs/GetEventResponse.md +18 -0
  48. data/docs/GetEventsResponse.md +20 -0
  49. data/docs/GetMetricsRequest.md +22 -0
  50. data/docs/GetMetricsResponse.md +18 -0
  51. data/docs/IngestBatchEventRequest.md +18 -0
  52. data/docs/IngestBatchEventResponse.md +18 -0
  53. data/docs/IngestError.md +20 -0
  54. data/docs/IngestEventRequest.md +18 -0
  55. data/docs/IngestEventResponse.md +18 -0
  56. data/docs/IngestionStatus.md +20 -0
  57. data/docs/MetricDataPoints.md +22 -0
  58. data/docs/MetricDataPointsGroupedBy.md +20 -0
  59. data/docs/MetricName.md +15 -0
  60. data/docs/MetricQuery.md +26 -0
  61. data/docs/MetricQueryFilterEntry.md +20 -0
  62. data/docs/MetricQueryResponse.md +22 -0
  63. data/docs/MetricsApi.md +79 -0
  64. data/docs/PaginationOptions.md +20 -0
  65. data/docs/PlanOverride.md +24 -0
  66. data/docs/PricePlan.md +26 -0
  67. data/docs/PricePlanListData.md +32 -0
  68. data/docs/PricePlanPaginatedResponse.md +22 -0
  69. data/docs/PricePlansApi.md +363 -0
  70. data/docs/PricingCycle.md +24 -0
  71. data/docs/PricingCycleStartOffset.md +20 -0
  72. data/docs/PricingSchedule.md +22 -0
  73. data/docs/RateCard.md +22 -0
  74. data/docs/RateCardBundle.md +22 -0
  75. data/docs/RateCardUsageValue.md +24 -0
  76. data/docs/RemoveAccountAliasesRequest.md +18 -0
  77. data/docs/SignupRequest.md +22 -0
  78. data/docs/SignupResponse.md +20 -0
  79. data/docs/StatusResponse.md +24 -0
  80. data/docs/StatusResponseHeaders.md +18 -0
  81. data/docs/UpdateAccountRequest.md +18 -0
  82. data/docs/UpdateCustomerRequest.md +22 -0
  83. data/docs/UpdateEventSchemaRequest.md +22 -0
  84. data/docs/UpdatePricePlanRequest.md +22 -0
  85. data/docs/UpdateUsageMeterRequest.md +24 -0
  86. data/docs/UsageMeter.md +34 -0
  87. data/docs/UsageMeterPaginatedResponse.md +22 -0
  88. data/docs/UsageMetersApi.md +521 -0
  89. data/docs/UsageStrategy.md +22 -0
  90. data/docs/UserDetails.md +26 -0
  91. data/git_push.sh +57 -0
  92. data/lib/togai_client/api/accounts_api.rb +679 -0
  93. data/lib/togai_client/api/customers_api.rb +365 -0
  94. data/lib/togai_client/api/event_ingestion_api.rb +158 -0
  95. data/lib/togai_client/api/event_management_api.rb +164 -0
  96. data/lib/togai_client/api/event_schemas_api.rb +579 -0
  97. data/lib/togai_client/api/metrics_api.rb +86 -0
  98. data/lib/togai_client/api/price_plans_api.rb +365 -0
  99. data/lib/togai_client/api/usage_meters_api.rb +572 -0
  100. data/lib/togai_client/api_client.rb +392 -0
  101. data/lib/togai_client/api_error.rb +57 -0
  102. data/lib/togai_client/configuration.rb +287 -0
  103. data/lib/togai_client/models/account.rb +373 -0
  104. data/lib/togai_client/models/account_aliases.rb +277 -0
  105. data/lib/togai_client/models/account_paginated_response.rb +239 -0
  106. data/lib/togai_client/models/add_account_aliases_request.rb +247 -0
  107. data/lib/togai_client/models/associate_price_plan_request.rb +274 -0
  108. data/lib/togai_client/models/associate_price_plan_response.rb +275 -0
  109. data/lib/togai_client/models/base_success_response.rb +224 -0
  110. data/lib/togai_client/models/bundle_strategy.rb +325 -0
  111. data/lib/togai_client/models/bundle_strategy_usage_meters_value.rb +224 -0
  112. data/lib/togai_client/models/computation.rb +294 -0
  113. data/lib/togai_client/models/create_account_request.rb +324 -0
  114. data/lib/togai_client/models/create_customer_request.rb +374 -0
  115. data/lib/togai_client/models/create_customer_response.rb +373 -0
  116. data/lib/togai_client/models/create_event_schema_request.rb +351 -0
  117. data/lib/togai_client/models/create_price_plan_request.rb +298 -0
  118. data/lib/togai_client/models/create_usage_meter_request.rb +368 -0
  119. data/lib/togai_client/models/customer.rb +442 -0
  120. data/lib/togai_client/models/customer_paginated_response.rb +239 -0
  121. data/lib/togai_client/models/dimensions_schema.rb +256 -0
  122. data/lib/togai_client/models/error_response.rb +244 -0
  123. data/lib/togai_client/models/event.rb +379 -0
  124. data/lib/togai_client/models/event_attribute.rb +304 -0
  125. data/lib/togai_client/models/event_attribute_schema.rb +281 -0
  126. data/lib/togai_client/models/event_pipeline_info.rb +260 -0
  127. data/lib/togai_client/models/event_pipeline_info_account.rb +238 -0
  128. data/lib/togai_client/models/event_pipeline_info_customer.rb +238 -0
  129. data/lib/togai_client/models/event_pipeline_info_event_schema.rb +238 -0
  130. data/lib/togai_client/models/event_pipeline_info_price_plans_inner.rb +283 -0
  131. data/lib/togai_client/models/event_pipeline_info_usage_meters_inner.rb +295 -0
  132. data/lib/togai_client/models/event_schema.rb +438 -0
  133. data/lib/togai_client/models/event_schema_list_data.rb +456 -0
  134. data/lib/togai_client/models/event_schema_list_data_all_of.rb +221 -0
  135. data/lib/togai_client/models/event_schema_list_paginated_response.rb +239 -0
  136. data/lib/togai_client/models/event_schema_versions_response.rb +227 -0
  137. data/lib/togai_client/models/event_with_status.rb +239 -0
  138. data/lib/togai_client/models/event_with_status_and_event_pipeline_info.rb +255 -0
  139. data/lib/togai_client/models/event_with_status_and_event_pipeline_info_all_of.rb +219 -0
  140. data/lib/togai_client/models/get_event_response.rb +222 -0
  141. data/lib/togai_client/models/get_events_response.rb +279 -0
  142. data/lib/togai_client/models/get_metrics_request.rb +265 -0
  143. data/lib/togai_client/models/get_metrics_response.rb +227 -0
  144. data/lib/togai_client/models/ingest_batch_event_request.rb +255 -0
  145. data/lib/togai_client/models/ingest_batch_event_response.rb +245 -0
  146. data/lib/togai_client/models/ingest_error.rb +229 -0
  147. data/lib/togai_client/models/ingest_event_request.rb +220 -0
  148. data/lib/togai_client/models/ingest_event_response.rb +244 -0
  149. data/lib/togai_client/models/ingestion_status.rb +284 -0
  150. data/lib/togai_client/models/metric_data_points.rb +289 -0
  151. data/lib/togai_client/models/metric_data_points_grouped_by.rb +238 -0
  152. data/lib/togai_client/models/metric_name.rb +38 -0
  153. data/lib/togai_client/models/metric_query.rb +331 -0
  154. data/lib/togai_client/models/metric_query_filter_entry.rb +241 -0
  155. data/lib/togai_client/models/metric_query_response.rb +255 -0
  156. data/lib/togai_client/models/pagination_options.rb +262 -0
  157. data/lib/togai_client/models/plan_override.rb +262 -0
  158. data/lib/togai_client/models/price_plan.rb +349 -0
  159. data/lib/togai_client/models/price_plan_list_data.rb +393 -0
  160. data/lib/togai_client/models/price_plan_paginated_response.rb +239 -0
  161. data/lib/togai_client/models/pricing_cycle.rb +313 -0
  162. data/lib/togai_client/models/pricing_cycle_start_offset.rb +241 -0
  163. data/lib/togai_client/models/pricing_schedule.rb +248 -0
  164. data/lib/togai_client/models/rate_card.rb +279 -0
  165. data/lib/togai_client/models/rate_card_bundle.rb +328 -0
  166. data/lib/togai_client/models/rate_card_usage_value.rb +343 -0
  167. data/lib/togai_client/models/remove_account_aliases_request.rb +247 -0
  168. data/lib/togai_client/models/signup_request.rb +293 -0
  169. data/lib/togai_client/models/signup_response.rb +260 -0
  170. data/lib/togai_client/models/status_response.rb +246 -0
  171. data/lib/togai_client/models/status_response_headers.rb +219 -0
  172. data/lib/togai_client/models/update_account_request.rb +245 -0
  173. data/lib/togai_client/models/update_customer_request.rb +304 -0
  174. data/lib/togai_client/models/update_event_schema_request.rb +306 -0
  175. data/lib/togai_client/models/update_price_plan_request.rb +254 -0
  176. data/lib/togai_client/models/update_usage_meter_request.rb +323 -0
  177. data/lib/togai_client/models/usage_meter.rb +440 -0
  178. data/lib/togai_client/models/usage_meter_paginated_response.rb +239 -0
  179. data/lib/togai_client/models/usage_strategy.rb +281 -0
  180. data/lib/togai_client/models/user_details.rb +380 -0
  181. data/lib/togai_client/version.rb +15 -0
  182. data/lib/togai_client.rb +125 -0
  183. data/spec/api_client_spec.rb +226 -0
  184. data/spec/configuration_spec.rb +42 -0
  185. data/spec/spec_helper.rb +111 -0
  186. data/togai_client.gemspec +38 -0
  187. metadata +271 -0
@@ -0,0 +1,351 @@
1
+ =begin
2
+ #Togai Apis
3
+
4
+ #APIs for Togai App
5
+
6
+ The version of the OpenAPI document: 1.0
7
+ Contact: engg@togai.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.1.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module TogaiClient
17
+ # Request to create event schema
18
+ class CreateEventSchemaRequest
19
+ # Name of the event. Must be unique for an organization.
20
+ attr_accessor :name
21
+
22
+ # Description of the event
23
+ attr_accessor :description
24
+
25
+ attr_accessor :attributes
26
+
27
+ attr_accessor :dimensions
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'name' => :'name',
33
+ :'description' => :'description',
34
+ :'attributes' => :'attributes',
35
+ :'dimensions' => :'dimensions'
36
+ }
37
+ end
38
+
39
+ # Returns all the JSON keys this model knows about
40
+ def self.acceptable_attributes
41
+ attribute_map.values
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.openapi_types
46
+ {
47
+ :'name' => :'String',
48
+ :'description' => :'String',
49
+ :'attributes' => :'Array<EventAttributeSchema>',
50
+ :'dimensions' => :'Array<DimensionsSchema>'
51
+ }
52
+ end
53
+
54
+ # List of attributes with nullable: true
55
+ def self.openapi_nullable
56
+ Set.new([
57
+ ])
58
+ end
59
+
60
+ # Initializes the object
61
+ # @param [Hash] attributes Model attributes in the form of hash
62
+ def initialize(attributes = {})
63
+ if (!attributes.is_a?(Hash))
64
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TogaiClient::CreateEventSchemaRequest` initialize method"
65
+ end
66
+
67
+ # check to see if the attribute exists and convert string to symbol for hash key
68
+ attributes = attributes.each_with_object({}) { |(k, v), h|
69
+ if (!self.class.attribute_map.key?(k.to_sym))
70
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TogaiClient::CreateEventSchemaRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
71
+ end
72
+ h[k.to_sym] = v
73
+ }
74
+
75
+ if attributes.key?(:'name')
76
+ self.name = attributes[:'name']
77
+ end
78
+
79
+ if attributes.key?(:'description')
80
+ self.description = attributes[:'description']
81
+ end
82
+
83
+ if attributes.key?(:'attributes')
84
+ if (value = attributes[:'attributes']).is_a?(Array)
85
+ self.attributes = value
86
+ end
87
+ end
88
+
89
+ if attributes.key?(:'dimensions')
90
+ if (value = attributes[:'dimensions']).is_a?(Array)
91
+ self.dimensions = value
92
+ end
93
+ end
94
+ end
95
+
96
+ # Show invalid properties with the reasons. Usually used together with valid?
97
+ # @return Array for valid properties with the reasons
98
+ def list_invalid_properties
99
+ invalid_properties = Array.new
100
+ if @name.nil?
101
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
102
+ end
103
+
104
+ if @name.to_s.length > 50
105
+ invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 50.')
106
+ end
107
+
108
+ pattern = Regexp.new(/^[\sa-zA-Z0-9_-]*$/)
109
+ if @name !~ pattern
110
+ invalid_properties.push("invalid value for \"name\", must conform to the pattern #{pattern}.")
111
+ end
112
+
113
+ if !@description.nil? && @description.to_s.length > 255
114
+ invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 255.')
115
+ end
116
+
117
+ if @attributes.nil?
118
+ invalid_properties.push('invalid value for "attributes", attributes cannot be nil.')
119
+ end
120
+
121
+ if @attributes.length > 50
122
+ invalid_properties.push('invalid value for "attributes", number of items must be less than or equal to 50.')
123
+ end
124
+
125
+ if @dimensions.nil?
126
+ invalid_properties.push('invalid value for "dimensions", dimensions cannot be nil.')
127
+ end
128
+
129
+ if @dimensions.length > 50
130
+ invalid_properties.push('invalid value for "dimensions", number of items must be less than or equal to 50.')
131
+ end
132
+
133
+ invalid_properties
134
+ end
135
+
136
+ # Check to see if the all the properties in the model are valid
137
+ # @return true if the model is valid
138
+ def valid?
139
+ return false if @name.nil?
140
+ return false if @name.to_s.length > 50
141
+ return false if @name !~ Regexp.new(/^[\sa-zA-Z0-9_-]*$/)
142
+ return false if !@description.nil? && @description.to_s.length > 255
143
+ return false if @attributes.nil?
144
+ return false if @attributes.length > 50
145
+ return false if @dimensions.nil?
146
+ return false if @dimensions.length > 50
147
+ true
148
+ end
149
+
150
+ # Custom attribute writer method with validation
151
+ # @param [Object] name Value to be assigned
152
+ def name=(name)
153
+ if name.nil?
154
+ fail ArgumentError, 'name cannot be nil'
155
+ end
156
+
157
+ if name.to_s.length > 50
158
+ fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 50.'
159
+ end
160
+
161
+ pattern = Regexp.new(/^[\sa-zA-Z0-9_-]*$/)
162
+ if name !~ pattern
163
+ fail ArgumentError, "invalid value for \"name\", must conform to the pattern #{pattern}."
164
+ end
165
+
166
+ @name = name
167
+ end
168
+
169
+ # Custom attribute writer method with validation
170
+ # @param [Object] description Value to be assigned
171
+ def description=(description)
172
+ if !description.nil? && description.to_s.length > 255
173
+ fail ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 255.'
174
+ end
175
+
176
+ @description = description
177
+ end
178
+
179
+ # Custom attribute writer method with validation
180
+ # @param [Object] attributes Value to be assigned
181
+ def attributes=(attributes)
182
+ if attributes.nil?
183
+ fail ArgumentError, 'attributes cannot be nil'
184
+ end
185
+
186
+ if attributes.length > 50
187
+ fail ArgumentError, 'invalid value for "attributes", number of items must be less than or equal to 50.'
188
+ end
189
+
190
+ @attributes = attributes
191
+ end
192
+
193
+ # Custom attribute writer method with validation
194
+ # @param [Object] dimensions Value to be assigned
195
+ def dimensions=(dimensions)
196
+ if dimensions.nil?
197
+ fail ArgumentError, 'dimensions cannot be nil'
198
+ end
199
+
200
+ if dimensions.length > 50
201
+ fail ArgumentError, 'invalid value for "dimensions", number of items must be less than or equal to 50.'
202
+ end
203
+
204
+ @dimensions = dimensions
205
+ end
206
+
207
+ # Checks equality by comparing each attribute.
208
+ # @param [Object] Object to be compared
209
+ def ==(o)
210
+ return true if self.equal?(o)
211
+ self.class == o.class &&
212
+ name == o.name &&
213
+ description == o.description &&
214
+ attributes == o.attributes &&
215
+ dimensions == o.dimensions
216
+ end
217
+
218
+ # @see the `==` method
219
+ # @param [Object] Object to be compared
220
+ def eql?(o)
221
+ self == o
222
+ end
223
+
224
+ # Calculates hash code according to all attributes.
225
+ # @return [Integer] Hash code
226
+ def hash
227
+ [name, description, attributes, dimensions].hash
228
+ end
229
+
230
+ # Builds the object from hash
231
+ # @param [Hash] attributes Model attributes in the form of hash
232
+ # @return [Object] Returns the model itself
233
+ def self.build_from_hash(attributes)
234
+ new.build_from_hash(attributes)
235
+ end
236
+
237
+ # Builds the object from hash
238
+ # @param [Hash] attributes Model attributes in the form of hash
239
+ # @return [Object] Returns the model itself
240
+ def build_from_hash(attributes)
241
+ return nil unless attributes.is_a?(Hash)
242
+ attributes = attributes.transform_keys(&:to_sym)
243
+ self.class.openapi_types.each_pair do |key, type|
244
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
245
+ self.send("#{key}=", nil)
246
+ elsif type =~ /\AArray<(.*)>/i
247
+ # check to ensure the input is an array given that the attribute
248
+ # is documented as an array but the input is not
249
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
250
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
251
+ end
252
+ elsif !attributes[self.class.attribute_map[key]].nil?
253
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
254
+ end
255
+ end
256
+
257
+ self
258
+ end
259
+
260
+ # Deserializes the data based on type
261
+ # @param string type Data type
262
+ # @param string value Value to be deserialized
263
+ # @return [Object] Deserialized data
264
+ def _deserialize(type, value)
265
+ case type.to_sym
266
+ when :Time
267
+ Time.parse(value)
268
+ when :Date
269
+ Date.parse(value)
270
+ when :String
271
+ value.to_s
272
+ when :Integer
273
+ value.to_i
274
+ when :Float
275
+ value.to_f
276
+ when :Boolean
277
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
278
+ true
279
+ else
280
+ false
281
+ end
282
+ when :Object
283
+ # generic object (usually a Hash), return directly
284
+ value
285
+ when /\AArray<(?<inner_type>.+)>\z/
286
+ inner_type = Regexp.last_match[:inner_type]
287
+ value.map { |v| _deserialize(inner_type, v) }
288
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
289
+ k_type = Regexp.last_match[:k_type]
290
+ v_type = Regexp.last_match[:v_type]
291
+ {}.tap do |hash|
292
+ value.each do |k, v|
293
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
294
+ end
295
+ end
296
+ else # model
297
+ # models (e.g. Pet) or oneOf
298
+ klass = TogaiClient.const_get(type)
299
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
300
+ end
301
+ end
302
+
303
+ # Returns the string representation of the object
304
+ # @return [String] String presentation of the object
305
+ def to_s
306
+ to_hash.to_s
307
+ end
308
+
309
+ # to_body is an alias to to_hash (backward compatibility)
310
+ # @return [Hash] Returns the object in the form of hash
311
+ def to_body
312
+ to_hash
313
+ end
314
+
315
+ # Returns the object in the form of hash
316
+ # @return [Hash] Returns the object in the form of hash
317
+ def to_hash
318
+ hash = {}
319
+ self.class.attribute_map.each_pair do |attr, param|
320
+ value = self.send(attr)
321
+ if value.nil?
322
+ is_nullable = self.class.openapi_nullable.include?(attr)
323
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
324
+ end
325
+
326
+ hash[param] = _to_hash(value)
327
+ end
328
+ hash
329
+ end
330
+
331
+ # Outputs non-array value in the form of hash
332
+ # For object, use to_hash. Otherwise, just return the value
333
+ # @param [Object] value Any valid value
334
+ # @return [Hash] Returns the value in the form of hash
335
+ def _to_hash(value)
336
+ if value.is_a?(Array)
337
+ value.compact.map { |v| _to_hash(v) }
338
+ elsif value.is_a?(Hash)
339
+ {}.tap do |hash|
340
+ value.each { |k, v| hash[k] = _to_hash(v) }
341
+ end
342
+ elsif value.respond_to? :to_hash
343
+ value.to_hash
344
+ else
345
+ value
346
+ end
347
+ end
348
+
349
+ end
350
+
351
+ end
@@ -0,0 +1,298 @@
1
+ =begin
2
+ #Togai Apis
3
+
4
+ #APIs for Togai App
5
+
6
+ The version of the OpenAPI document: 1.0
7
+ Contact: engg@togai.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.1.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module TogaiClient
17
+ # Request to create a price plan
18
+ class CreatePricePlanRequest
19
+ # Name of the price plan
20
+ attr_accessor :name
21
+
22
+ # Description of price plan
23
+ attr_accessor :description
24
+
25
+ attr_accessor :pricing_cycle
26
+
27
+ attr_accessor :rate_card
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'name' => :'name',
33
+ :'description' => :'description',
34
+ :'pricing_cycle' => :'pricingCycle',
35
+ :'rate_card' => :'rateCard'
36
+ }
37
+ end
38
+
39
+ # Returns all the JSON keys this model knows about
40
+ def self.acceptable_attributes
41
+ attribute_map.values
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.openapi_types
46
+ {
47
+ :'name' => :'String',
48
+ :'description' => :'String',
49
+ :'pricing_cycle' => :'PricingCycle',
50
+ :'rate_card' => :'RateCard'
51
+ }
52
+ end
53
+
54
+ # List of attributes with nullable: true
55
+ def self.openapi_nullable
56
+ Set.new([
57
+ ])
58
+ end
59
+
60
+ # Initializes the object
61
+ # @param [Hash] attributes Model attributes in the form of hash
62
+ def initialize(attributes = {})
63
+ if (!attributes.is_a?(Hash))
64
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TogaiClient::CreatePricePlanRequest` initialize method"
65
+ end
66
+
67
+ # check to see if the attribute exists and convert string to symbol for hash key
68
+ attributes = attributes.each_with_object({}) { |(k, v), h|
69
+ if (!self.class.attribute_map.key?(k.to_sym))
70
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TogaiClient::CreatePricePlanRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
71
+ end
72
+ h[k.to_sym] = v
73
+ }
74
+
75
+ if attributes.key?(:'name')
76
+ self.name = attributes[:'name']
77
+ end
78
+
79
+ if attributes.key?(:'description')
80
+ self.description = attributes[:'description']
81
+ end
82
+
83
+ if attributes.key?(:'pricing_cycle')
84
+ self.pricing_cycle = attributes[:'pricing_cycle']
85
+ end
86
+
87
+ if attributes.key?(:'rate_card')
88
+ self.rate_card = attributes[:'rate_card']
89
+ end
90
+ end
91
+
92
+ # Show invalid properties with the reasons. Usually used together with valid?
93
+ # @return Array for valid properties with the reasons
94
+ def list_invalid_properties
95
+ invalid_properties = Array.new
96
+ if @name.nil?
97
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
98
+ end
99
+
100
+ if @name.to_s.length > 50
101
+ invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 50.')
102
+ end
103
+
104
+ if !@description.nil? && @description.to_s.length > 255
105
+ invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 255.')
106
+ end
107
+
108
+ if @pricing_cycle.nil?
109
+ invalid_properties.push('invalid value for "pricing_cycle", pricing_cycle cannot be nil.')
110
+ end
111
+
112
+ if @rate_card.nil?
113
+ invalid_properties.push('invalid value for "rate_card", rate_card cannot be nil.')
114
+ end
115
+
116
+ invalid_properties
117
+ end
118
+
119
+ # Check to see if the all the properties in the model are valid
120
+ # @return true if the model is valid
121
+ def valid?
122
+ return false if @name.nil?
123
+ return false if @name.to_s.length > 50
124
+ return false if !@description.nil? && @description.to_s.length > 255
125
+ return false if @pricing_cycle.nil?
126
+ return false if @rate_card.nil?
127
+ true
128
+ end
129
+
130
+ # Custom attribute writer method with validation
131
+ # @param [Object] name Value to be assigned
132
+ def name=(name)
133
+ if name.nil?
134
+ fail ArgumentError, 'name cannot be nil'
135
+ end
136
+
137
+ if name.to_s.length > 50
138
+ fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 50.'
139
+ end
140
+
141
+ @name = name
142
+ end
143
+
144
+ # Custom attribute writer method with validation
145
+ # @param [Object] description Value to be assigned
146
+ def description=(description)
147
+ if !description.nil? && description.to_s.length > 255
148
+ fail ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 255.'
149
+ end
150
+
151
+ @description = description
152
+ end
153
+
154
+ # Checks equality by comparing each attribute.
155
+ # @param [Object] Object to be compared
156
+ def ==(o)
157
+ return true if self.equal?(o)
158
+ self.class == o.class &&
159
+ name == o.name &&
160
+ description == o.description &&
161
+ pricing_cycle == o.pricing_cycle &&
162
+ rate_card == o.rate_card
163
+ end
164
+
165
+ # @see the `==` method
166
+ # @param [Object] Object to be compared
167
+ def eql?(o)
168
+ self == o
169
+ end
170
+
171
+ # Calculates hash code according to all attributes.
172
+ # @return [Integer] Hash code
173
+ def hash
174
+ [name, description, pricing_cycle, rate_card].hash
175
+ end
176
+
177
+ # Builds the object from hash
178
+ # @param [Hash] attributes Model attributes in the form of hash
179
+ # @return [Object] Returns the model itself
180
+ def self.build_from_hash(attributes)
181
+ new.build_from_hash(attributes)
182
+ end
183
+
184
+ # Builds the object from hash
185
+ # @param [Hash] attributes Model attributes in the form of hash
186
+ # @return [Object] Returns the model itself
187
+ def build_from_hash(attributes)
188
+ return nil unless attributes.is_a?(Hash)
189
+ attributes = attributes.transform_keys(&:to_sym)
190
+ self.class.openapi_types.each_pair do |key, type|
191
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
192
+ self.send("#{key}=", nil)
193
+ elsif type =~ /\AArray<(.*)>/i
194
+ # check to ensure the input is an array given that the attribute
195
+ # is documented as an array but the input is not
196
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
197
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
198
+ end
199
+ elsif !attributes[self.class.attribute_map[key]].nil?
200
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
201
+ end
202
+ end
203
+
204
+ self
205
+ end
206
+
207
+ # Deserializes the data based on type
208
+ # @param string type Data type
209
+ # @param string value Value to be deserialized
210
+ # @return [Object] Deserialized data
211
+ def _deserialize(type, value)
212
+ case type.to_sym
213
+ when :Time
214
+ Time.parse(value)
215
+ when :Date
216
+ Date.parse(value)
217
+ when :String
218
+ value.to_s
219
+ when :Integer
220
+ value.to_i
221
+ when :Float
222
+ value.to_f
223
+ when :Boolean
224
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
225
+ true
226
+ else
227
+ false
228
+ end
229
+ when :Object
230
+ # generic object (usually a Hash), return directly
231
+ value
232
+ when /\AArray<(?<inner_type>.+)>\z/
233
+ inner_type = Regexp.last_match[:inner_type]
234
+ value.map { |v| _deserialize(inner_type, v) }
235
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
236
+ k_type = Regexp.last_match[:k_type]
237
+ v_type = Regexp.last_match[:v_type]
238
+ {}.tap do |hash|
239
+ value.each do |k, v|
240
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
241
+ end
242
+ end
243
+ else # model
244
+ # models (e.g. Pet) or oneOf
245
+ klass = TogaiClient.const_get(type)
246
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
247
+ end
248
+ end
249
+
250
+ # Returns the string representation of the object
251
+ # @return [String] String presentation of the object
252
+ def to_s
253
+ to_hash.to_s
254
+ end
255
+
256
+ # to_body is an alias to to_hash (backward compatibility)
257
+ # @return [Hash] Returns the object in the form of hash
258
+ def to_body
259
+ to_hash
260
+ end
261
+
262
+ # Returns the object in the form of hash
263
+ # @return [Hash] Returns the object in the form of hash
264
+ def to_hash
265
+ hash = {}
266
+ self.class.attribute_map.each_pair do |attr, param|
267
+ value = self.send(attr)
268
+ if value.nil?
269
+ is_nullable = self.class.openapi_nullable.include?(attr)
270
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
271
+ end
272
+
273
+ hash[param] = _to_hash(value)
274
+ end
275
+ hash
276
+ end
277
+
278
+ # Outputs non-array value in the form of hash
279
+ # For object, use to_hash. Otherwise, just return the value
280
+ # @param [Object] value Any valid value
281
+ # @return [Hash] Returns the value in the form of hash
282
+ def _to_hash(value)
283
+ if value.is_a?(Array)
284
+ value.compact.map { |v| _to_hash(v) }
285
+ elsif value.is_a?(Hash)
286
+ {}.tap do |hash|
287
+ value.each { |k, v| hash[k] = _to_hash(v) }
288
+ end
289
+ elsif value.respond_to? :to_hash
290
+ value.to_hash
291
+ else
292
+ value
293
+ end
294
+ end
295
+
296
+ end
297
+
298
+ end