togai_client 1.0.0 → 1.0.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 (72) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/docs/AccountsApi.md +1 -1
  4. data/docs/AssociatePricePlanRequest.md +4 -4
  5. data/docs/Bundle.md +22 -0
  6. data/docs/CreatePricePlanRequest.md +2 -4
  7. data/docs/EventPipelineInfoPricePlansInner.md +2 -0
  8. data/docs/EventSchemaListData.md +2 -2
  9. data/docs/EventSchemaListDataAllOf.md +2 -2
  10. data/docs/GetEventResponse.md +1 -1
  11. data/docs/PlanOverride.md +2 -2
  12. data/docs/PricePlan.md +0 -2
  13. data/docs/PricePlanDetails.md +20 -0
  14. data/docs/PricePlanDetailsOverride.md +20 -0
  15. data/docs/PricePlanListData.md +2 -4
  16. data/docs/PricePlanPaginatedResponse.md +1 -1
  17. data/docs/PricePlansApi.md +1 -1
  18. data/docs/PriceType.md +15 -0
  19. data/docs/{PricingCycle.md → PricingCycleConfig.md} +3 -3
  20. data/docs/{PricingCycleStartOffset.md → PricingCycleConfigStartOffset.md} +2 -2
  21. data/docs/PricingModel.md +15 -0
  22. data/docs/PricingSchedule.md +2 -2
  23. data/docs/RateCard.md +6 -6
  24. data/docs/RateCardBundleAggregation.md +15 -0
  25. data/docs/RateCardType.md +15 -0
  26. data/docs/RateConfigBundle.md +20 -0
  27. data/docs/RateConfigUsage.md +20 -0
  28. data/docs/SlabBundle.md +24 -0
  29. data/docs/{UsageStrategy.md → SlabUsage.md} +6 -2
  30. data/docs/UpdatePricePlanRequest.md +2 -4
  31. data/examples/example.rb +222 -0
  32. data/lib/togai_client/models/associate_price_plan_request.rb +17 -7
  33. data/lib/togai_client/models/{bundle_strategy.rb → bundle.rb} +34 -85
  34. data/lib/togai_client/models/create_customer_request.rb +0 -9
  35. data/lib/togai_client/models/create_customer_response.rb +0 -9
  36. data/lib/togai_client/models/create_price_plan_request.rb +10 -24
  37. data/lib/togai_client/models/customer.rb +0 -9
  38. data/lib/togai_client/models/event_pipeline_info_price_plans_inner.rb +15 -1
  39. data/lib/togai_client/models/event_schema_list_data.rb +7 -9
  40. data/lib/togai_client/models/event_schema_list_data_all_of.rb +7 -9
  41. data/lib/togai_client/models/get_event_response.rb +5 -0
  42. data/lib/togai_client/models/ingestion_status.rb +2 -2
  43. data/lib/togai_client/models/plan_override.rb +7 -7
  44. data/lib/togai_client/models/price_plan.rb +1 -15
  45. data/lib/togai_client/models/price_plan_details.rb +259 -0
  46. data/lib/togai_client/models/price_plan_details_override.rb +245 -0
  47. data/lib/togai_client/models/price_plan_list_data.rb +10 -25
  48. data/lib/togai_client/models/price_plan_paginated_response.rb +5 -0
  49. data/lib/togai_client/models/price_type.rb +38 -0
  50. data/lib/togai_client/models/{pricing_cycle.rb → pricing_cycle_config.rb} +4 -4
  51. data/lib/togai_client/models/{pricing_cycle_start_offset.rb → pricing_cycle_config_start_offset.rb} +3 -3
  52. data/lib/togai_client/models/pricing_model.rb +37 -0
  53. data/lib/togai_client/models/pricing_schedule.rb +7 -7
  54. data/lib/togai_client/models/rate_card.rb +32 -59
  55. data/lib/togai_client/models/rate_card_bundle_aggregation.rb +39 -0
  56. data/lib/togai_client/models/rate_card_type.rb +37 -0
  57. data/lib/togai_client/models/{bundle_strategy_usage_meters_value.rb → rate_config_bundle.rb} +28 -13
  58. data/lib/togai_client/models/{rate_card_usage_value.rb → rate_config_usage.rb} +15 -98
  59. data/lib/togai_client/models/signup_request.rb +0 -11
  60. data/lib/togai_client/models/slab_bundle.rb +264 -0
  61. data/lib/togai_client/models/{usage_strategy.rb → slab_usage.rb} +30 -5
  62. data/lib/togai_client/models/update_customer_request.rb +0 -9
  63. data/lib/togai_client/models/update_price_plan_request.rb +7 -16
  64. data/lib/togai_client/models/user_details.rb +0 -11
  65. data/lib/togai_client/version.rb +1 -1
  66. data/lib/togai_client.rb +13 -7
  67. metadata +36 -23
  68. data/docs/BundleStrategy.md +0 -24
  69. data/docs/BundleStrategyUsageMetersValue.md +0 -18
  70. data/docs/RateCardBundle.md +0 -22
  71. data/docs/RateCardUsageValue.md +0 -24
  72. data/lib/togai_client/models/rate_card_bundle.rb +0 -328
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: togai_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Togai Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-09 00:00:00.000000000 Z
11
+ date: 2022-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -34,22 +34,22 @@ dependencies:
34
34
  name: rspec
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: 3.6.0
40
37
  - - "~>"
41
38
  - !ruby/object:Gem::Version
42
39
  version: '3.6'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 3.6.0
43
43
  type: :development
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: 3.6.0
50
47
  - - "~>"
51
48
  - !ruby/object:Gem::Version
52
49
  version: '3.6'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 3.6.0
53
53
  description: A ruby client library for Togai APIs
54
54
  email:
55
55
  - engg@togai.com
@@ -68,8 +68,7 @@ files:
68
68
  - docs/AssociatePricePlanRequest.md
69
69
  - docs/AssociatePricePlanResponse.md
70
70
  - docs/BaseSuccessResponse.md
71
- - docs/BundleStrategy.md
72
- - docs/BundleStrategyUsageMetersValue.md
71
+ - docs/Bundle.md
73
72
  - docs/Computation.md
74
73
  - docs/CreateAccountRequest.md
75
74
  - docs/CreateCustomerRequest.md
@@ -122,18 +121,26 @@ files:
122
121
  - docs/PaginationOptions.md
123
122
  - docs/PlanOverride.md
124
123
  - docs/PricePlan.md
124
+ - docs/PricePlanDetails.md
125
+ - docs/PricePlanDetailsOverride.md
125
126
  - docs/PricePlanListData.md
126
127
  - docs/PricePlanPaginatedResponse.md
127
128
  - docs/PricePlansApi.md
128
- - docs/PricingCycle.md
129
- - docs/PricingCycleStartOffset.md
129
+ - docs/PriceType.md
130
+ - docs/PricingCycleConfig.md
131
+ - docs/PricingCycleConfigStartOffset.md
132
+ - docs/PricingModel.md
130
133
  - docs/PricingSchedule.md
131
134
  - docs/RateCard.md
132
- - docs/RateCardBundle.md
133
- - docs/RateCardUsageValue.md
135
+ - docs/RateCardBundleAggregation.md
136
+ - docs/RateCardType.md
137
+ - docs/RateConfigBundle.md
138
+ - docs/RateConfigUsage.md
134
139
  - docs/RemoveAccountAliasesRequest.md
135
140
  - docs/SignupRequest.md
136
141
  - docs/SignupResponse.md
142
+ - docs/SlabBundle.md
143
+ - docs/SlabUsage.md
137
144
  - docs/StatusResponse.md
138
145
  - docs/StatusResponseHeaders.md
139
146
  - docs/UpdateAccountRequest.md
@@ -144,8 +151,8 @@ files:
144
151
  - docs/UsageMeter.md
145
152
  - docs/UsageMeterPaginatedResponse.md
146
153
  - docs/UsageMetersApi.md
147
- - docs/UsageStrategy.md
148
154
  - docs/UserDetails.md
155
+ - examples/example.rb
149
156
  - git_push.sh
150
157
  - lib/togai_client.rb
151
158
  - lib/togai_client/api/accounts_api.rb
@@ -166,8 +173,7 @@ files:
166
173
  - lib/togai_client/models/associate_price_plan_request.rb
167
174
  - lib/togai_client/models/associate_price_plan_response.rb
168
175
  - lib/togai_client/models/base_success_response.rb
169
- - lib/togai_client/models/bundle_strategy.rb
170
- - lib/togai_client/models/bundle_strategy_usage_meters_value.rb
176
+ - lib/togai_client/models/bundle.rb
171
177
  - lib/togai_client/models/computation.rb
172
178
  - lib/togai_client/models/create_account_request.rb
173
179
  - lib/togai_client/models/create_customer_request.rb
@@ -215,17 +221,25 @@ files:
215
221
  - lib/togai_client/models/pagination_options.rb
216
222
  - lib/togai_client/models/plan_override.rb
217
223
  - lib/togai_client/models/price_plan.rb
224
+ - lib/togai_client/models/price_plan_details.rb
225
+ - lib/togai_client/models/price_plan_details_override.rb
218
226
  - lib/togai_client/models/price_plan_list_data.rb
219
227
  - lib/togai_client/models/price_plan_paginated_response.rb
220
- - lib/togai_client/models/pricing_cycle.rb
221
- - lib/togai_client/models/pricing_cycle_start_offset.rb
228
+ - lib/togai_client/models/price_type.rb
229
+ - lib/togai_client/models/pricing_cycle_config.rb
230
+ - lib/togai_client/models/pricing_cycle_config_start_offset.rb
231
+ - lib/togai_client/models/pricing_model.rb
222
232
  - lib/togai_client/models/pricing_schedule.rb
223
233
  - lib/togai_client/models/rate_card.rb
224
- - lib/togai_client/models/rate_card_bundle.rb
225
- - lib/togai_client/models/rate_card_usage_value.rb
234
+ - lib/togai_client/models/rate_card_bundle_aggregation.rb
235
+ - lib/togai_client/models/rate_card_type.rb
236
+ - lib/togai_client/models/rate_config_bundle.rb
237
+ - lib/togai_client/models/rate_config_usage.rb
226
238
  - lib/togai_client/models/remove_account_aliases_request.rb
227
239
  - lib/togai_client/models/signup_request.rb
228
240
  - lib/togai_client/models/signup_response.rb
241
+ - lib/togai_client/models/slab_bundle.rb
242
+ - lib/togai_client/models/slab_usage.rb
229
243
  - lib/togai_client/models/status_response.rb
230
244
  - lib/togai_client/models/status_response_headers.rb
231
245
  - lib/togai_client/models/update_account_request.rb
@@ -235,7 +249,6 @@ files:
235
249
  - lib/togai_client/models/update_usage_meter_request.rb
236
250
  - lib/togai_client/models/usage_meter.rb
237
251
  - lib/togai_client/models/usage_meter_paginated_response.rb
238
- - lib/togai_client/models/usage_strategy.rb
239
252
  - lib/togai_client/models/user_details.rb
240
253
  - lib/togai_client/version.rb
241
254
  - spec/api_client_spec.rb
@@ -261,7 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
274
  - !ruby/object:Gem::Version
262
275
  version: '0'
263
276
  requirements: []
264
- rubygems_version: 3.0.3.1
277
+ rubygems_version: 3.3.7
265
278
  signing_key:
266
279
  specification_version: 4
267
280
  summary: Togai Apis Ruby Gem
@@ -1,24 +0,0 @@
1
- # TogaiClient::BundleStrategy
2
-
3
- ## Properties
4
-
5
- | Name | Type | Description | Notes |
6
- | ---- | ---- | ----------- | ----- |
7
- | **name** | **String** | | |
8
- | **rate** | **Float** | | |
9
- | **order** | **Integer** | | |
10
- | **usage_meters** | [**Hash<String, BundleStrategyUsageMetersValue>**](BundleStrategyUsageMetersValue.md) | | |
11
-
12
- ## Example
13
-
14
- ```ruby
15
- require 'togai_client'
16
-
17
- instance = TogaiClient::BundleStrategy.new(
18
- name: null,
19
- rate: null,
20
- order: null,
21
- usage_meters: null
22
- )
23
- ```
24
-
@@ -1,18 +0,0 @@
1
- # TogaiClient::BundleStrategyUsageMetersValue
2
-
3
- ## Properties
4
-
5
- | Name | Type | Description | Notes |
6
- | ---- | ---- | ----------- | ----- |
7
- | **start_after** | **Float** | | |
8
-
9
- ## Example
10
-
11
- ```ruby
12
- require 'togai_client'
13
-
14
- instance = TogaiClient::BundleStrategyUsageMetersValue.new(
15
- start_after: null
16
- )
17
- ```
18
-
@@ -1,22 +0,0 @@
1
- # TogaiClient::RateCardBundle
2
-
3
- ## Properties
4
-
5
- | Name | Type | Description | Notes |
6
- | ---- | ---- | ----------- | ----- |
7
- | **rate_strategy** | **String** | | |
8
- | **slab_strategy** | **String** | | |
9
- | **bundles** | [**Array<BundleStrategy>**](BundleStrategy.md) | | |
10
-
11
- ## Example
12
-
13
- ```ruby
14
- require 'togai_client'
15
-
16
- instance = TogaiClient::RateCardBundle.new(
17
- rate_strategy: null,
18
- slab_strategy: null,
19
- bundles: null
20
- )
21
- ```
22
-
@@ -1,24 +0,0 @@
1
- # TogaiClient::RateCardUsageValue
2
-
3
- ## Properties
4
-
5
- | Name | Type | Description | Notes |
6
- | ---- | ---- | ----------- | ----- |
7
- | **name** | **String** | | |
8
- | **rate_strategy** | **String** | | |
9
- | **slab_strategy** | **String** | | |
10
- | **slabs** | [**Array<UsageStrategy>**](UsageStrategy.md) | | |
11
-
12
- ## Example
13
-
14
- ```ruby
15
- require 'togai_client'
16
-
17
- instance = TogaiClient::RateCardUsageValue.new(
18
- name: null,
19
- rate_strategy: null,
20
- slab_strategy: null,
21
- slabs: null
22
- )
23
- ```
24
-
@@ -1,328 +0,0 @@
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 RateCardBundle
18
- attr_accessor :rate_strategy
19
-
20
- attr_accessor :slab_strategy
21
-
22
- attr_accessor :bundles
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
- :'rate_strategy' => :'rateStrategy',
50
- :'slab_strategy' => :'slabStrategy',
51
- :'bundles' => :'bundles'
52
- }
53
- end
54
-
55
- # Returns all the JSON keys this model knows about
56
- def self.acceptable_attributes
57
- attribute_map.values
58
- end
59
-
60
- # Attribute type mapping.
61
- def self.openapi_types
62
- {
63
- :'rate_strategy' => :'String',
64
- :'slab_strategy' => :'String',
65
- :'bundles' => :'Array<BundleStrategy>'
66
- }
67
- end
68
-
69
- # List of attributes with nullable: true
70
- def self.openapi_nullable
71
- Set.new([
72
- ])
73
- end
74
-
75
- # Initializes the object
76
- # @param [Hash] attributes Model attributes in the form of hash
77
- def initialize(attributes = {})
78
- if (!attributes.is_a?(Hash))
79
- fail ArgumentError, "The input argument (attributes) must be a hash in `TogaiClient::RateCardBundle` initialize method"
80
- end
81
-
82
- # check to see if the attribute exists and convert string to symbol for hash key
83
- attributes = attributes.each_with_object({}) { |(k, v), h|
84
- if (!self.class.attribute_map.key?(k.to_sym))
85
- fail ArgumentError, "`#{k}` is not a valid attribute in `TogaiClient::RateCardBundle`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
86
- end
87
- h[k.to_sym] = v
88
- }
89
-
90
- if attributes.key?(:'rate_strategy')
91
- self.rate_strategy = attributes[:'rate_strategy']
92
- end
93
-
94
- if attributes.key?(:'slab_strategy')
95
- self.slab_strategy = attributes[:'slab_strategy']
96
- end
97
-
98
- if attributes.key?(:'bundles')
99
- if (value = attributes[:'bundles']).is_a?(Array)
100
- self.bundles = value
101
- end
102
- end
103
- end
104
-
105
- # Show invalid properties with the reasons. Usually used together with valid?
106
- # @return Array for valid properties with the reasons
107
- def list_invalid_properties
108
- invalid_properties = Array.new
109
- if @rate_strategy.nil?
110
- invalid_properties.push('invalid value for "rate_strategy", rate_strategy cannot be nil.')
111
- end
112
-
113
- if @slab_strategy.nil?
114
- invalid_properties.push('invalid value for "slab_strategy", slab_strategy cannot be nil.')
115
- end
116
-
117
- if @bundles.nil?
118
- invalid_properties.push('invalid value for "bundles", bundles cannot be nil.')
119
- end
120
-
121
- if @bundles.length > 10
122
- invalid_properties.push('invalid value for "bundles", number of items must be less than or equal to 10.')
123
- end
124
-
125
- if @bundles.length < 1
126
- invalid_properties.push('invalid value for "bundles", number of items must be greater than or equal to 1.')
127
- end
128
-
129
- invalid_properties
130
- end
131
-
132
- # Check to see if the all the properties in the model are valid
133
- # @return true if the model is valid
134
- def valid?
135
- return false if @rate_strategy.nil?
136
- rate_strategy_validator = EnumAttributeValidator.new('String', ["FLAT"])
137
- return false unless rate_strategy_validator.valid?(@rate_strategy)
138
- return false if @slab_strategy.nil?
139
- slab_strategy_validator = EnumAttributeValidator.new('String', ["TIER"])
140
- return false unless slab_strategy_validator.valid?(@slab_strategy)
141
- return false if @bundles.nil?
142
- return false if @bundles.length > 10
143
- return false if @bundles.length < 1
144
- true
145
- end
146
-
147
- # Custom attribute writer method checking allowed values (enum).
148
- # @param [Object] rate_strategy Object to be assigned
149
- def rate_strategy=(rate_strategy)
150
- validator = EnumAttributeValidator.new('String', ["FLAT"])
151
- unless validator.valid?(rate_strategy)
152
- fail ArgumentError, "invalid value for \"rate_strategy\", must be one of #{validator.allowable_values}."
153
- end
154
- @rate_strategy = rate_strategy
155
- end
156
-
157
- # Custom attribute writer method checking allowed values (enum).
158
- # @param [Object] slab_strategy Object to be assigned
159
- def slab_strategy=(slab_strategy)
160
- validator = EnumAttributeValidator.new('String', ["TIER"])
161
- unless validator.valid?(slab_strategy)
162
- fail ArgumentError, "invalid value for \"slab_strategy\", must be one of #{validator.allowable_values}."
163
- end
164
- @slab_strategy = slab_strategy
165
- end
166
-
167
- # Custom attribute writer method with validation
168
- # @param [Object] bundles Value to be assigned
169
- def bundles=(bundles)
170
- if bundles.nil?
171
- fail ArgumentError, 'bundles cannot be nil'
172
- end
173
-
174
- if bundles.length > 10
175
- fail ArgumentError, 'invalid value for "bundles", number of items must be less than or equal to 10.'
176
- end
177
-
178
- if bundles.length < 1
179
- fail ArgumentError, 'invalid value for "bundles", number of items must be greater than or equal to 1.'
180
- end
181
-
182
- @bundles = bundles
183
- end
184
-
185
- # Checks equality by comparing each attribute.
186
- # @param [Object] Object to be compared
187
- def ==(o)
188
- return true if self.equal?(o)
189
- self.class == o.class &&
190
- rate_strategy == o.rate_strategy &&
191
- slab_strategy == o.slab_strategy &&
192
- bundles == o.bundles
193
- end
194
-
195
- # @see the `==` method
196
- # @param [Object] Object to be compared
197
- def eql?(o)
198
- self == o
199
- end
200
-
201
- # Calculates hash code according to all attributes.
202
- # @return [Integer] Hash code
203
- def hash
204
- [rate_strategy, slab_strategy, bundles].hash
205
- end
206
-
207
- # Builds the object from hash
208
- # @param [Hash] attributes Model attributes in the form of hash
209
- # @return [Object] Returns the model itself
210
- def self.build_from_hash(attributes)
211
- new.build_from_hash(attributes)
212
- end
213
-
214
- # Builds the object from hash
215
- # @param [Hash] attributes Model attributes in the form of hash
216
- # @return [Object] Returns the model itself
217
- def build_from_hash(attributes)
218
- return nil unless attributes.is_a?(Hash)
219
- attributes = attributes.transform_keys(&:to_sym)
220
- self.class.openapi_types.each_pair do |key, type|
221
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
222
- self.send("#{key}=", nil)
223
- elsif type =~ /\AArray<(.*)>/i
224
- # check to ensure the input is an array given that the attribute
225
- # is documented as an array but the input is not
226
- if attributes[self.class.attribute_map[key]].is_a?(Array)
227
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
228
- end
229
- elsif !attributes[self.class.attribute_map[key]].nil?
230
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
231
- end
232
- end
233
-
234
- self
235
- end
236
-
237
- # Deserializes the data based on type
238
- # @param string type Data type
239
- # @param string value Value to be deserialized
240
- # @return [Object] Deserialized data
241
- def _deserialize(type, value)
242
- case type.to_sym
243
- when :Time
244
- Time.parse(value)
245
- when :Date
246
- Date.parse(value)
247
- when :String
248
- value.to_s
249
- when :Integer
250
- value.to_i
251
- when :Float
252
- value.to_f
253
- when :Boolean
254
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
255
- true
256
- else
257
- false
258
- end
259
- when :Object
260
- # generic object (usually a Hash), return directly
261
- value
262
- when /\AArray<(?<inner_type>.+)>\z/
263
- inner_type = Regexp.last_match[:inner_type]
264
- value.map { |v| _deserialize(inner_type, v) }
265
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
266
- k_type = Regexp.last_match[:k_type]
267
- v_type = Regexp.last_match[:v_type]
268
- {}.tap do |hash|
269
- value.each do |k, v|
270
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
271
- end
272
- end
273
- else # model
274
- # models (e.g. Pet) or oneOf
275
- klass = TogaiClient.const_get(type)
276
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
277
- end
278
- end
279
-
280
- # Returns the string representation of the object
281
- # @return [String] String presentation of the object
282
- def to_s
283
- to_hash.to_s
284
- end
285
-
286
- # to_body is an alias to to_hash (backward compatibility)
287
- # @return [Hash] Returns the object in the form of hash
288
- def to_body
289
- to_hash
290
- end
291
-
292
- # Returns the object in the form of hash
293
- # @return [Hash] Returns the object in the form of hash
294
- def to_hash
295
- hash = {}
296
- self.class.attribute_map.each_pair do |attr, param|
297
- value = self.send(attr)
298
- if value.nil?
299
- is_nullable = self.class.openapi_nullable.include?(attr)
300
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
301
- end
302
-
303
- hash[param] = _to_hash(value)
304
- end
305
- hash
306
- end
307
-
308
- # Outputs non-array value in the form of hash
309
- # For object, use to_hash. Otherwise, just return the value
310
- # @param [Object] value Any valid value
311
- # @return [Hash] Returns the value in the form of hash
312
- def _to_hash(value)
313
- if value.is_a?(Array)
314
- value.compact.map { |v| _to_hash(v) }
315
- elsif value.is_a?(Hash)
316
- {}.tap do |hash|
317
- value.each { |k, v| hash[k] = _to_hash(v) }
318
- end
319
- elsif value.respond_to? :to_hash
320
- value.to_hash
321
- else
322
- value
323
- end
324
- end
325
-
326
- end
327
-
328
- end