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,294 @@
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
+ class Computation
18
+ # Optional identifier describing the matcher and computation pair
19
+ attr_accessor :id
20
+
21
+ # Condition to be applied on event. Upon matching it the corresponding computation will be considered for usage_meter unit calculation. The result of the matcher needs to be truthy (https://jsonlogic.com/truthy.html) in order to be considered as a match.
22
+ attr_accessor :matcher
23
+
24
+ # Computation to be applied on an event if it matches the matcher In case of a COUNT aggregation type, computation should be passed as '1'
25
+ attr_accessor :computation
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'id' => :'id',
31
+ :'matcher' => :'matcher',
32
+ :'computation' => :'computation'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'id' => :'String',
45
+ :'matcher' => :'String',
46
+ :'computation' => :'String'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TogaiClient::Computation` initialize method"
61
+ end
62
+
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ attributes = attributes.each_with_object({}) { |(k, v), h|
65
+ if (!self.class.attribute_map.key?(k.to_sym))
66
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TogaiClient::Computation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
67
+ end
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:'id')
72
+ self.id = attributes[:'id']
73
+ end
74
+
75
+ if attributes.key?(:'matcher')
76
+ self.matcher = attributes[:'matcher']
77
+ end
78
+
79
+ if attributes.key?(:'computation')
80
+ self.computation = attributes[:'computation']
81
+ end
82
+ end
83
+
84
+ # Show invalid properties with the reasons. Usually used together with valid?
85
+ # @return Array for valid properties with the reasons
86
+ def list_invalid_properties
87
+ invalid_properties = Array.new
88
+ if !@id.nil? && @id.to_s.length > 50
89
+ invalid_properties.push('invalid value for "id", the character length must be smaller than or equal to 50.')
90
+ end
91
+
92
+ if !@matcher.nil? && @matcher.to_s.length > 1500
93
+ invalid_properties.push('invalid value for "matcher", the character length must be smaller than or equal to 1500.')
94
+ end
95
+
96
+ if @computation.nil?
97
+ invalid_properties.push('invalid value for "computation", computation cannot be nil.')
98
+ end
99
+
100
+ if @computation.to_s.length > 500
101
+ invalid_properties.push('invalid value for "computation", the character length must be smaller than or equal to 500.')
102
+ end
103
+
104
+ invalid_properties
105
+ end
106
+
107
+ # Check to see if the all the properties in the model are valid
108
+ # @return true if the model is valid
109
+ def valid?
110
+ return false if !@id.nil? && @id.to_s.length > 50
111
+ return false if !@matcher.nil? && @matcher.to_s.length > 1500
112
+ return false if @computation.nil?
113
+ return false if @computation.to_s.length > 500
114
+ true
115
+ end
116
+
117
+ # Custom attribute writer method with validation
118
+ # @param [Object] id Value to be assigned
119
+ def id=(id)
120
+ if !id.nil? && id.to_s.length > 50
121
+ fail ArgumentError, 'invalid value for "id", the character length must be smaller than or equal to 50.'
122
+ end
123
+
124
+ @id = id
125
+ end
126
+
127
+ # Custom attribute writer method with validation
128
+ # @param [Object] matcher Value to be assigned
129
+ def matcher=(matcher)
130
+ if !matcher.nil? && matcher.to_s.length > 1500
131
+ fail ArgumentError, 'invalid value for "matcher", the character length must be smaller than or equal to 1500.'
132
+ end
133
+
134
+ @matcher = matcher
135
+ end
136
+
137
+ # Custom attribute writer method with validation
138
+ # @param [Object] computation Value to be assigned
139
+ def computation=(computation)
140
+ if computation.nil?
141
+ fail ArgumentError, 'computation cannot be nil'
142
+ end
143
+
144
+ if computation.to_s.length > 500
145
+ fail ArgumentError, 'invalid value for "computation", the character length must be smaller than or equal to 500.'
146
+ end
147
+
148
+ @computation = computation
149
+ end
150
+
151
+ # Checks equality by comparing each attribute.
152
+ # @param [Object] Object to be compared
153
+ def ==(o)
154
+ return true if self.equal?(o)
155
+ self.class == o.class &&
156
+ id == o.id &&
157
+ matcher == o.matcher &&
158
+ computation == o.computation
159
+ end
160
+
161
+ # @see the `==` method
162
+ # @param [Object] Object to be compared
163
+ def eql?(o)
164
+ self == o
165
+ end
166
+
167
+ # Calculates hash code according to all attributes.
168
+ # @return [Integer] Hash code
169
+ def hash
170
+ [id, matcher, computation].hash
171
+ end
172
+
173
+ # Builds the object from hash
174
+ # @param [Hash] attributes Model attributes in the form of hash
175
+ # @return [Object] Returns the model itself
176
+ def self.build_from_hash(attributes)
177
+ new.build_from_hash(attributes)
178
+ end
179
+
180
+ # Builds the object from hash
181
+ # @param [Hash] attributes Model attributes in the form of hash
182
+ # @return [Object] Returns the model itself
183
+ def build_from_hash(attributes)
184
+ return nil unless attributes.is_a?(Hash)
185
+ attributes = attributes.transform_keys(&:to_sym)
186
+ self.class.openapi_types.each_pair do |key, type|
187
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
188
+ self.send("#{key}=", nil)
189
+ elsif type =~ /\AArray<(.*)>/i
190
+ # check to ensure the input is an array given that the attribute
191
+ # is documented as an array but the input is not
192
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
193
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
194
+ end
195
+ elsif !attributes[self.class.attribute_map[key]].nil?
196
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
197
+ end
198
+ end
199
+
200
+ self
201
+ end
202
+
203
+ # Deserializes the data based on type
204
+ # @param string type Data type
205
+ # @param string value Value to be deserialized
206
+ # @return [Object] Deserialized data
207
+ def _deserialize(type, value)
208
+ case type.to_sym
209
+ when :Time
210
+ Time.parse(value)
211
+ when :Date
212
+ Date.parse(value)
213
+ when :String
214
+ value.to_s
215
+ when :Integer
216
+ value.to_i
217
+ when :Float
218
+ value.to_f
219
+ when :Boolean
220
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
221
+ true
222
+ else
223
+ false
224
+ end
225
+ when :Object
226
+ # generic object (usually a Hash), return directly
227
+ value
228
+ when /\AArray<(?<inner_type>.+)>\z/
229
+ inner_type = Regexp.last_match[:inner_type]
230
+ value.map { |v| _deserialize(inner_type, v) }
231
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
232
+ k_type = Regexp.last_match[:k_type]
233
+ v_type = Regexp.last_match[:v_type]
234
+ {}.tap do |hash|
235
+ value.each do |k, v|
236
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
237
+ end
238
+ end
239
+ else # model
240
+ # models (e.g. Pet) or oneOf
241
+ klass = TogaiClient.const_get(type)
242
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
243
+ end
244
+ end
245
+
246
+ # Returns the string representation of the object
247
+ # @return [String] String presentation of the object
248
+ def to_s
249
+ to_hash.to_s
250
+ end
251
+
252
+ # to_body is an alias to to_hash (backward compatibility)
253
+ # @return [Hash] Returns the object in the form of hash
254
+ def to_body
255
+ to_hash
256
+ end
257
+
258
+ # Returns the object in the form of hash
259
+ # @return [Hash] Returns the object in the form of hash
260
+ def to_hash
261
+ hash = {}
262
+ self.class.attribute_map.each_pair do |attr, param|
263
+ value = self.send(attr)
264
+ if value.nil?
265
+ is_nullable = self.class.openapi_nullable.include?(attr)
266
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
267
+ end
268
+
269
+ hash[param] = _to_hash(value)
270
+ end
271
+ hash
272
+ end
273
+
274
+ # Outputs non-array value in the form of hash
275
+ # For object, use to_hash. Otherwise, just return the value
276
+ # @param [Object] value Any valid value
277
+ # @return [Hash] Returns the value in the form of hash
278
+ def _to_hash(value)
279
+ if value.is_a?(Array)
280
+ value.compact.map { |v| _to_hash(v) }
281
+ elsif value.is_a?(Hash)
282
+ {}.tap do |hash|
283
+ value.each { |k, v| hash[k] = _to_hash(v) }
284
+ end
285
+ elsif value.respond_to? :to_hash
286
+ value.to_hash
287
+ else
288
+ value
289
+ end
290
+ end
291
+
292
+ end
293
+
294
+ end
@@ -0,0 +1,324 @@
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
+ # Payload to create account
18
+ class CreateAccountRequest
19
+ # Identifier of the account
20
+ attr_accessor :id
21
+
22
+ # Name of the customer
23
+ attr_accessor :name
24
+
25
+ # list of aliases for the account. Can be used interchangeably with 'id' for event ingestion.
26
+ attr_accessor :aliases
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'id' => :'id',
32
+ :'name' => :'name',
33
+ :'aliases' => :'aliases'
34
+ }
35
+ end
36
+
37
+ # Returns all the JSON keys this model knows about
38
+ def self.acceptable_attributes
39
+ attribute_map.values
40
+ end
41
+
42
+ # Attribute type mapping.
43
+ def self.openapi_types
44
+ {
45
+ :'id' => :'String',
46
+ :'name' => :'String',
47
+ :'aliases' => :'Array<String>'
48
+ }
49
+ end
50
+
51
+ # List of attributes with nullable: true
52
+ def self.openapi_nullable
53
+ Set.new([
54
+ ])
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TogaiClient::CreateAccountRequest` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TogaiClient::CreateAccountRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'id')
73
+ self.id = attributes[:'id']
74
+ end
75
+
76
+ if attributes.key?(:'name')
77
+ self.name = attributes[:'name']
78
+ end
79
+
80
+ if attributes.key?(:'aliases')
81
+ if (value = attributes[:'aliases']).is_a?(Array)
82
+ self.aliases = value
83
+ end
84
+ end
85
+ end
86
+
87
+ # Show invalid properties with the reasons. Usually used together with valid?
88
+ # @return Array for valid properties with the reasons
89
+ def list_invalid_properties
90
+ invalid_properties = Array.new
91
+ if @id.nil?
92
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
93
+ end
94
+
95
+ if @id.to_s.length > 50
96
+ invalid_properties.push('invalid value for "id", the character length must be smaller than or equal to 50.')
97
+ end
98
+
99
+ if @name.nil?
100
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
101
+ end
102
+
103
+ if @name.to_s.length > 255
104
+ invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 255.')
105
+ end
106
+
107
+ if @name.to_s.length < 3
108
+ invalid_properties.push('invalid value for "name", the character length must be great than or equal to 3.')
109
+ end
110
+
111
+ if !@aliases.nil? && @aliases.length > 10
112
+ invalid_properties.push('invalid value for "aliases", number of items must be less than or equal to 10.')
113
+ end
114
+
115
+ if !@aliases.nil? && @aliases.length < 0
116
+ invalid_properties.push('invalid value for "aliases", number of items must be greater than or equal to 0.')
117
+ end
118
+
119
+ invalid_properties
120
+ end
121
+
122
+ # Check to see if the all the properties in the model are valid
123
+ # @return true if the model is valid
124
+ def valid?
125
+ return false if @id.nil?
126
+ return false if @id.to_s.length > 50
127
+ return false if @name.nil?
128
+ return false if @name.to_s.length > 255
129
+ return false if @name.to_s.length < 3
130
+ return false if !@aliases.nil? && @aliases.length > 10
131
+ return false if !@aliases.nil? && @aliases.length < 0
132
+ true
133
+ end
134
+
135
+ # Custom attribute writer method with validation
136
+ # @param [Object] id Value to be assigned
137
+ def id=(id)
138
+ if id.nil?
139
+ fail ArgumentError, 'id cannot be nil'
140
+ end
141
+
142
+ if id.to_s.length > 50
143
+ fail ArgumentError, 'invalid value for "id", the character length must be smaller than or equal to 50.'
144
+ end
145
+
146
+ @id = id
147
+ end
148
+
149
+ # Custom attribute writer method with validation
150
+ # @param [Object] name Value to be assigned
151
+ def name=(name)
152
+ if name.nil?
153
+ fail ArgumentError, 'name cannot be nil'
154
+ end
155
+
156
+ if name.to_s.length > 255
157
+ fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 255.'
158
+ end
159
+
160
+ if name.to_s.length < 3
161
+ fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 3.'
162
+ end
163
+
164
+ @name = name
165
+ end
166
+
167
+ # Custom attribute writer method with validation
168
+ # @param [Object] aliases Value to be assigned
169
+ def aliases=(aliases)
170
+ if !aliases.nil? && aliases.length > 10
171
+ fail ArgumentError, 'invalid value for "aliases", number of items must be less than or equal to 10.'
172
+ end
173
+
174
+ if !aliases.nil? && aliases.length < 0
175
+ fail ArgumentError, 'invalid value for "aliases", number of items must be greater than or equal to 0.'
176
+ end
177
+
178
+ @aliases = aliases
179
+ end
180
+
181
+ # Checks equality by comparing each attribute.
182
+ # @param [Object] Object to be compared
183
+ def ==(o)
184
+ return true if self.equal?(o)
185
+ self.class == o.class &&
186
+ id == o.id &&
187
+ name == o.name &&
188
+ aliases == o.aliases
189
+ end
190
+
191
+ # @see the `==` method
192
+ # @param [Object] Object to be compared
193
+ def eql?(o)
194
+ self == o
195
+ end
196
+
197
+ # Calculates hash code according to all attributes.
198
+ # @return [Integer] Hash code
199
+ def hash
200
+ [id, name, aliases].hash
201
+ end
202
+
203
+ # Builds the object from hash
204
+ # @param [Hash] attributes Model attributes in the form of hash
205
+ # @return [Object] Returns the model itself
206
+ def self.build_from_hash(attributes)
207
+ new.build_from_hash(attributes)
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 build_from_hash(attributes)
214
+ return nil unless attributes.is_a?(Hash)
215
+ attributes = attributes.transform_keys(&:to_sym)
216
+ self.class.openapi_types.each_pair do |key, type|
217
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
218
+ self.send("#{key}=", nil)
219
+ elsif type =~ /\AArray<(.*)>/i
220
+ # check to ensure the input is an array given that the attribute
221
+ # is documented as an array but the input is not
222
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
223
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
224
+ end
225
+ elsif !attributes[self.class.attribute_map[key]].nil?
226
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
227
+ end
228
+ end
229
+
230
+ self
231
+ end
232
+
233
+ # Deserializes the data based on type
234
+ # @param string type Data type
235
+ # @param string value Value to be deserialized
236
+ # @return [Object] Deserialized data
237
+ def _deserialize(type, value)
238
+ case type.to_sym
239
+ when :Time
240
+ Time.parse(value)
241
+ when :Date
242
+ Date.parse(value)
243
+ when :String
244
+ value.to_s
245
+ when :Integer
246
+ value.to_i
247
+ when :Float
248
+ value.to_f
249
+ when :Boolean
250
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
251
+ true
252
+ else
253
+ false
254
+ end
255
+ when :Object
256
+ # generic object (usually a Hash), return directly
257
+ value
258
+ when /\AArray<(?<inner_type>.+)>\z/
259
+ inner_type = Regexp.last_match[:inner_type]
260
+ value.map { |v| _deserialize(inner_type, v) }
261
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
262
+ k_type = Regexp.last_match[:k_type]
263
+ v_type = Regexp.last_match[:v_type]
264
+ {}.tap do |hash|
265
+ value.each do |k, v|
266
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
267
+ end
268
+ end
269
+ else # model
270
+ # models (e.g. Pet) or oneOf
271
+ klass = TogaiClient.const_get(type)
272
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
273
+ end
274
+ end
275
+
276
+ # Returns the string representation of the object
277
+ # @return [String] String presentation of the object
278
+ def to_s
279
+ to_hash.to_s
280
+ end
281
+
282
+ # to_body is an alias to to_hash (backward compatibility)
283
+ # @return [Hash] Returns the object in the form of hash
284
+ def to_body
285
+ to_hash
286
+ end
287
+
288
+ # Returns the object in the form of hash
289
+ # @return [Hash] Returns the object in the form of hash
290
+ def to_hash
291
+ hash = {}
292
+ self.class.attribute_map.each_pair do |attr, param|
293
+ value = self.send(attr)
294
+ if value.nil?
295
+ is_nullable = self.class.openapi_nullable.include?(attr)
296
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
297
+ end
298
+
299
+ hash[param] = _to_hash(value)
300
+ end
301
+ hash
302
+ end
303
+
304
+ # Outputs non-array value in the form of hash
305
+ # For object, use to_hash. Otherwise, just return the value
306
+ # @param [Object] value Any valid value
307
+ # @return [Hash] Returns the value in the form of hash
308
+ def _to_hash(value)
309
+ if value.is_a?(Array)
310
+ value.compact.map { |v| _to_hash(v) }
311
+ elsif value.is_a?(Hash)
312
+ {}.tap do |hash|
313
+ value.each { |k, v| hash[k] = _to_hash(v) }
314
+ end
315
+ elsif value.respond_to? :to_hash
316
+ value.to_hash
317
+ else
318
+ value
319
+ end
320
+ end
321
+
322
+ end
323
+
324
+ end