phrase 2.23.0 → 2.24.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,323 @@
1
+ require 'cgi'
2
+
3
+ module Phrase
4
+ class LinkedKeysApi
5
+ attr_accessor :api_client
6
+
7
+ def initialize(api_client = ApiClient.default)
8
+ @api_client = api_client
9
+ end
10
+ # Batch unlink child keys from a parent key
11
+ # Unlinks multiple child keys from a given parent key in a single operation.
12
+ # @param project_id [String] Project ID
13
+ # @param id [String] Parent Translation Key ID
14
+ # @param key_links_batch_destroy_parameters [KeyLinksBatchDestroyParameters]
15
+ # @param [Hash] opts the optional parameters
16
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
17
+ # @option opts [Boolean] :unlink_parent Whether to unlink the parent key as well and unmark it as linked-key.
18
+ # @return [nil]
19
+ def key_links_batch_destroy(project_id, id, key_links_batch_destroy_parameters, opts = {})
20
+ data, _status_code, _headers = key_links_batch_destroy_with_http_info(project_id, id, key_links_batch_destroy_parameters, opts)
21
+ data
22
+ end
23
+
24
+ # Batch unlink child keys from a parent key
25
+ # Unlinks multiple child keys from a given parent key in a single operation.
26
+ # @param project_id [String] Project ID
27
+ # @param id [String] Parent Translation Key ID
28
+ # @param key_links_batch_destroy_parameters [KeyLinksBatchDestroyParameters]
29
+ # @param [Hash] opts the optional parameters
30
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
31
+ # @option opts [Boolean] :unlink_parent Whether to unlink the parent key as well and unmark it as linked-key.
32
+ # @return [Array<(Response, Integer, Hash)>] Response<(nil, response status code and response headers
33
+ def key_links_batch_destroy_with_http_info(project_id, id, key_links_batch_destroy_parameters, opts = {})
34
+ if @api_client.config.debugging
35
+ @api_client.config.logger.debug 'Calling API: LinkedKeysApi.key_links_batch_destroy ...'
36
+ end
37
+ # verify the required parameter 'project_id' is set
38
+ if @api_client.config.client_side_validation && project_id.nil?
39
+ fail ArgumentError, "Missing the required parameter 'project_id' when calling LinkedKeysApi.key_links_batch_destroy"
40
+ end
41
+ # verify the required parameter 'id' is set
42
+ if @api_client.config.client_side_validation && id.nil?
43
+ fail ArgumentError, "Missing the required parameter 'id' when calling LinkedKeysApi.key_links_batch_destroy"
44
+ end
45
+ # verify the required parameter 'key_links_batch_destroy_parameters' is set
46
+ if @api_client.config.client_side_validation && key_links_batch_destroy_parameters.nil?
47
+ fail ArgumentError, "Missing the required parameter 'key_links_batch_destroy_parameters' when calling LinkedKeysApi.key_links_batch_destroy"
48
+ end
49
+ # resource path
50
+ local_var_path = '/projects/{project_id}/keys/{id}/key_links'.sub('{' + 'project_id' + '}', CGI.escape(project_id.to_s)).sub('{' + 'id' + '}', CGI.escape(id.to_s))
51
+
52
+ # query parameters
53
+ query_params = opts[:query_params] || {}
54
+ query_params[:'unlink_parent'] = opts[:'unlink_parent'] if !opts[:'unlink_parent'].nil?
55
+
56
+ # header parameters
57
+ header_params = opts[:header_params] || {}
58
+ # HTTP header 'Accept' (if needed)
59
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
60
+ # HTTP header 'Content-Type'
61
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
62
+ header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
63
+
64
+ # form parameters
65
+ form_params = opts[:form_params] || {}
66
+
67
+ # http body (model)
68
+ post_body = opts[:body] || @api_client.object_to_http_body(key_links_batch_destroy_parameters)
69
+
70
+ # return_type
71
+ return_type = opts[:return_type]
72
+
73
+ # auth_names
74
+ auth_names = opts[:auth_names] || ['Basic', 'Token']
75
+
76
+ new_options = opts.merge(
77
+ :header_params => header_params,
78
+ :query_params => query_params,
79
+ :form_params => form_params,
80
+ :body => post_body,
81
+ :auth_names => auth_names,
82
+ :return_type => return_type
83
+ )
84
+
85
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
86
+ if @api_client.config.debugging
87
+ @api_client.config.logger.debug "API called: LinkedKeysApi#key_links_batch_destroy\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
88
+ end
89
+ response = ::Phrase::Response.new(data, headers)
90
+ return response, status_code, headers
91
+ end
92
+
93
+ # Link child keys to a parent key
94
+ # Creates links between a given parent key and one or more child keys.
95
+ # @param project_id [String] Project ID
96
+ # @param id [String] Parent Translation Key ID
97
+ # @param key_links_create_parameters [KeyLinksCreateParameters]
98
+ # @param [Hash] opts the optional parameters
99
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
100
+ # @return [KeyLink]
101
+ def key_links_create(project_id, id, key_links_create_parameters, opts = {})
102
+ data, _status_code, _headers = key_links_create_with_http_info(project_id, id, key_links_create_parameters, opts)
103
+ data
104
+ end
105
+
106
+ # Link child keys to a parent key
107
+ # Creates links between a given parent key and one or more child keys.
108
+ # @param project_id [String] Project ID
109
+ # @param id [String] Parent Translation Key ID
110
+ # @param key_links_create_parameters [KeyLinksCreateParameters]
111
+ # @param [Hash] opts the optional parameters
112
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
113
+ # @return [Array<(Response<(KeyLink)>, Integer, Hash)>] Response<(KeyLink)> data, response status code and response headers
114
+ def key_links_create_with_http_info(project_id, id, key_links_create_parameters, opts = {})
115
+ if @api_client.config.debugging
116
+ @api_client.config.logger.debug 'Calling API: LinkedKeysApi.key_links_create ...'
117
+ end
118
+ # verify the required parameter 'project_id' is set
119
+ if @api_client.config.client_side_validation && project_id.nil?
120
+ fail ArgumentError, "Missing the required parameter 'project_id' when calling LinkedKeysApi.key_links_create"
121
+ end
122
+ # verify the required parameter 'id' is set
123
+ if @api_client.config.client_side_validation && id.nil?
124
+ fail ArgumentError, "Missing the required parameter 'id' when calling LinkedKeysApi.key_links_create"
125
+ end
126
+ # verify the required parameter 'key_links_create_parameters' is set
127
+ if @api_client.config.client_side_validation && key_links_create_parameters.nil?
128
+ fail ArgumentError, "Missing the required parameter 'key_links_create_parameters' when calling LinkedKeysApi.key_links_create"
129
+ end
130
+ # resource path
131
+ local_var_path = '/projects/{project_id}/keys/{id}/key_links'.sub('{' + 'project_id' + '}', CGI.escape(project_id.to_s)).sub('{' + 'id' + '}', CGI.escape(id.to_s))
132
+
133
+ # query parameters
134
+ query_params = opts[:query_params] || {}
135
+
136
+ # header parameters
137
+ header_params = opts[:header_params] || {}
138
+ # HTTP header 'Accept' (if needed)
139
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
140
+ # HTTP header 'Content-Type'
141
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
142
+ header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
143
+
144
+ # form parameters
145
+ form_params = opts[:form_params] || {}
146
+
147
+ # http body (model)
148
+ post_body = opts[:body] || @api_client.object_to_http_body(key_links_create_parameters)
149
+
150
+ # return_type
151
+ return_type = opts[:return_type] || 'KeyLink'
152
+
153
+ # auth_names
154
+ auth_names = opts[:auth_names] || ['Basic', 'Token']
155
+
156
+ new_options = opts.merge(
157
+ :header_params => header_params,
158
+ :query_params => query_params,
159
+ :form_params => form_params,
160
+ :body => post_body,
161
+ :auth_names => auth_names,
162
+ :return_type => return_type
163
+ )
164
+
165
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
166
+ if @api_client.config.debugging
167
+ @api_client.config.logger.debug "API called: LinkedKeysApi#key_links_create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
168
+ end
169
+ response = ::Phrase::Response.new(data, headers)
170
+ return response, status_code, headers
171
+ end
172
+
173
+ # Unlink a child key from a parent key
174
+ # Unlinks a single child key from a given parent key.
175
+ # @param project_id [String] Project ID
176
+ # @param id [String] Parent Translation Key ID
177
+ # @param child_key_id [String] The ID of the child key to unlink.
178
+ # @param [Hash] opts the optional parameters
179
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
180
+ # @return [nil]
181
+ def key_links_destroy(project_id, id, child_key_id, opts = {})
182
+ data, _status_code, _headers = key_links_destroy_with_http_info(project_id, id, child_key_id, opts)
183
+ data
184
+ end
185
+
186
+ # Unlink a child key from a parent key
187
+ # Unlinks a single child key from a given parent key.
188
+ # @param project_id [String] Project ID
189
+ # @param id [String] Parent Translation Key ID
190
+ # @param child_key_id [String] The ID of the child key to unlink.
191
+ # @param [Hash] opts the optional parameters
192
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
193
+ # @return [Array<(Response, Integer, Hash)>] Response<(nil, response status code and response headers
194
+ def key_links_destroy_with_http_info(project_id, id, child_key_id, opts = {})
195
+ if @api_client.config.debugging
196
+ @api_client.config.logger.debug 'Calling API: LinkedKeysApi.key_links_destroy ...'
197
+ end
198
+ # verify the required parameter 'project_id' is set
199
+ if @api_client.config.client_side_validation && project_id.nil?
200
+ fail ArgumentError, "Missing the required parameter 'project_id' when calling LinkedKeysApi.key_links_destroy"
201
+ end
202
+ # verify the required parameter 'id' is set
203
+ if @api_client.config.client_side_validation && id.nil?
204
+ fail ArgumentError, "Missing the required parameter 'id' when calling LinkedKeysApi.key_links_destroy"
205
+ end
206
+ # verify the required parameter 'child_key_id' is set
207
+ if @api_client.config.client_side_validation && child_key_id.nil?
208
+ fail ArgumentError, "Missing the required parameter 'child_key_id' when calling LinkedKeysApi.key_links_destroy"
209
+ end
210
+ # resource path
211
+ local_var_path = '/projects/{project_id}/keys/{id}/key_links/{child_key_id}'.sub('{' + 'project_id' + '}', CGI.escape(project_id.to_s)).sub('{' + 'id' + '}', CGI.escape(id.to_s)).sub('{' + 'child_key_id' + '}', CGI.escape(child_key_id.to_s))
212
+
213
+ # query parameters
214
+ query_params = opts[:query_params] || {}
215
+
216
+ # header parameters
217
+ header_params = opts[:header_params] || {}
218
+ # HTTP header 'Accept' (if needed)
219
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
220
+ header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
221
+
222
+ # form parameters
223
+ form_params = opts[:form_params] || {}
224
+
225
+ # http body (model)
226
+ post_body = opts[:body]
227
+
228
+ # return_type
229
+ return_type = opts[:return_type]
230
+
231
+ # auth_names
232
+ auth_names = opts[:auth_names] || ['Basic', 'Token']
233
+
234
+ new_options = opts.merge(
235
+ :header_params => header_params,
236
+ :query_params => query_params,
237
+ :form_params => form_params,
238
+ :body => post_body,
239
+ :auth_names => auth_names,
240
+ :return_type => return_type
241
+ )
242
+
243
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
244
+ if @api_client.config.debugging
245
+ @api_client.config.logger.debug "API called: LinkedKeysApi#key_links_destroy\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
246
+ end
247
+ response = ::Phrase::Response.new(data, headers)
248
+ return response, status_code, headers
249
+ end
250
+
251
+ # Retrieve all child keys linked to a specific parent key
252
+ # Returns detailed information about a parent key, including its linked child keys.
253
+ # @param project_id [String] Project ID
254
+ # @param id [String] Parent Translation Key ID
255
+ # @param [Hash] opts the optional parameters
256
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
257
+ # @return [KeyLink]
258
+ def key_links_index(project_id, id, opts = {})
259
+ data, _status_code, _headers = key_links_index_with_http_info(project_id, id, opts)
260
+ data
261
+ end
262
+
263
+ # Retrieve all child keys linked to a specific parent key
264
+ # Returns detailed information about a parent key, including its linked child keys.
265
+ # @param project_id [String] Project ID
266
+ # @param id [String] Parent Translation Key ID
267
+ # @param [Hash] opts the optional parameters
268
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
269
+ # @return [Array<(Response<(KeyLink)>, Integer, Hash)>] Response<(KeyLink)> data, response status code and response headers
270
+ def key_links_index_with_http_info(project_id, id, opts = {})
271
+ if @api_client.config.debugging
272
+ @api_client.config.logger.debug 'Calling API: LinkedKeysApi.key_links_index ...'
273
+ end
274
+ # verify the required parameter 'project_id' is set
275
+ if @api_client.config.client_side_validation && project_id.nil?
276
+ fail ArgumentError, "Missing the required parameter 'project_id' when calling LinkedKeysApi.key_links_index"
277
+ end
278
+ # verify the required parameter 'id' is set
279
+ if @api_client.config.client_side_validation && id.nil?
280
+ fail ArgumentError, "Missing the required parameter 'id' when calling LinkedKeysApi.key_links_index"
281
+ end
282
+ # resource path
283
+ local_var_path = '/projects/{project_id}/keys/{id}/key_links'.sub('{' + 'project_id' + '}', CGI.escape(project_id.to_s)).sub('{' + 'id' + '}', CGI.escape(id.to_s))
284
+
285
+ # query parameters
286
+ query_params = opts[:query_params] || {}
287
+
288
+ # header parameters
289
+ header_params = opts[:header_params] || {}
290
+ # HTTP header 'Accept' (if needed)
291
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
292
+ header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
293
+
294
+ # form parameters
295
+ form_params = opts[:form_params] || {}
296
+
297
+ # http body (model)
298
+ post_body = opts[:body]
299
+
300
+ # return_type
301
+ return_type = opts[:return_type] || 'KeyLink'
302
+
303
+ # auth_names
304
+ auth_names = opts[:auth_names] || ['Basic', 'Token']
305
+
306
+ new_options = opts.merge(
307
+ :header_params => header_params,
308
+ :query_params => query_params,
309
+ :form_params => form_params,
310
+ :body => post_body,
311
+ :auth_names => auth_names,
312
+ :return_type => return_type
313
+ )
314
+
315
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
316
+ if @api_client.config.debugging
317
+ @api_client.config.logger.debug "API called: LinkedKeysApi#key_links_index\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
318
+ end
319
+ response = ::Phrase::Response.new(data, headers)
320
+ return response, status_code, headers
321
+ end
322
+ end
323
+ end
@@ -0,0 +1,290 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class KeyLink
5
+ # The timestamp when the link was created.
6
+ attr_accessor :created_at
7
+
8
+ # The timestamp when the link was last updated.
9
+ attr_accessor :updated_at
10
+
11
+ attr_accessor :created_by
12
+
13
+ attr_accessor :updated_by
14
+
15
+ attr_accessor :account
16
+
17
+ attr_accessor :parent
18
+
19
+ # The child translation keys linked to the parent.
20
+ attr_accessor :children
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'created_at' => :'created_at',
26
+ :'updated_at' => :'updated_at',
27
+ :'created_by' => :'created_by',
28
+ :'updated_by' => :'updated_by',
29
+ :'account' => :'account',
30
+ :'parent' => :'parent',
31
+ :'children' => :'children'
32
+ }
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'created_at' => :'DateTime',
39
+ :'updated_at' => :'DateTime',
40
+ :'created_by' => :'UserPreview',
41
+ :'updated_by' => :'UserPreview',
42
+ :'account' => :'Account',
43
+ :'parent' => :'KeyPreview',
44
+ :'children' => :'Array<KeyPreview>'
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new([
51
+ ])
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::KeyLink` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ attributes = attributes.each_with_object({}) { |(k, v), h|
63
+ if (!self.class.attribute_map.key?(k.to_sym))
64
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::KeyLink`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
65
+ end
66
+ h[k.to_sym] = v
67
+ }
68
+
69
+ if attributes.key?(:'created_at')
70
+ self.created_at = attributes[:'created_at']
71
+ end
72
+
73
+ if attributes.key?(:'updated_at')
74
+ self.updated_at = attributes[:'updated_at']
75
+ end
76
+
77
+ if attributes.key?(:'created_by')
78
+ self.created_by = attributes[:'created_by']
79
+ end
80
+
81
+ if attributes.key?(:'updated_by')
82
+ self.updated_by = attributes[:'updated_by']
83
+ end
84
+
85
+ if attributes.key?(:'account')
86
+ self.account = attributes[:'account']
87
+ end
88
+
89
+ if attributes.key?(:'parent')
90
+ self.parent = attributes[:'parent']
91
+ end
92
+
93
+ if attributes.key?(:'children')
94
+ if (value = attributes[:'children']).is_a?(Array)
95
+ self.children = value
96
+ end
97
+ end
98
+ end
99
+
100
+ # Show invalid properties with the reasons. Usually used together with valid?
101
+ # @return Array for valid properties with the reasons
102
+ def list_invalid_properties
103
+ invalid_properties = Array.new
104
+ if @created_at.nil?
105
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
106
+ end
107
+
108
+ if @updated_at.nil?
109
+ invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
110
+ end
111
+
112
+ if @created_by.nil?
113
+ invalid_properties.push('invalid value for "created_by", created_by cannot be nil.')
114
+ end
115
+
116
+ if @updated_by.nil?
117
+ invalid_properties.push('invalid value for "updated_by", updated_by cannot be nil.')
118
+ end
119
+
120
+ if @account.nil?
121
+ invalid_properties.push('invalid value for "account", account cannot be nil.')
122
+ end
123
+
124
+ if @parent.nil?
125
+ invalid_properties.push('invalid value for "parent", parent cannot be nil.')
126
+ end
127
+
128
+ if @children.nil?
129
+ invalid_properties.push('invalid value for "children", children cannot be nil.')
130
+ end
131
+
132
+ invalid_properties
133
+ end
134
+
135
+ # Check to see if the all the properties in the model are valid
136
+ # @return true if the model is valid
137
+ def valid?
138
+ return false if @created_at.nil?
139
+ return false if @updated_at.nil?
140
+ return false if @created_by.nil?
141
+ return false if @updated_by.nil?
142
+ return false if @account.nil?
143
+ return false if @parent.nil?
144
+ return false if @children.nil?
145
+ true
146
+ end
147
+
148
+ # Checks equality by comparing each attribute.
149
+ # @param [Object] Object to be compared
150
+ def ==(o)
151
+ return true if self.equal?(o)
152
+ self.class == o.class &&
153
+ created_at == o.created_at &&
154
+ updated_at == o.updated_at &&
155
+ created_by == o.created_by &&
156
+ updated_by == o.updated_by &&
157
+ account == o.account &&
158
+ parent == o.parent &&
159
+ children == o.children
160
+ end
161
+
162
+ # @see the `==` method
163
+ # @param [Object] Object to be compared
164
+ def eql?(o)
165
+ self == o
166
+ end
167
+
168
+ # Calculates hash code according to all attributes.
169
+ # @return [Integer] Hash code
170
+ def hash
171
+ [created_at, updated_at, created_by, updated_by, account, parent, children].hash
172
+ end
173
+
174
+ # Builds the object from hash
175
+ # @param [Hash] attributes Model attributes in the form of hash
176
+ # @return [Object] Returns the model itself
177
+ def self.build_from_hash(attributes)
178
+ new.build_from_hash(attributes)
179
+ end
180
+
181
+ # Builds the object from hash
182
+ # @param [Hash] attributes Model attributes in the form of hash
183
+ # @return [Object] Returns the model itself
184
+ def build_from_hash(attributes)
185
+ return nil unless attributes.is_a?(Hash)
186
+ self.class.openapi_types.each_pair do |key, type|
187
+ if type =~ /\AArray<(.*)>/i
188
+ # check to ensure the input is an array given that the attribute
189
+ # is documented as an array but the input is not
190
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
191
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
192
+ end
193
+ elsif !attributes[self.class.attribute_map[key]].nil?
194
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
195
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
196
+ end
197
+
198
+ self
199
+ end
200
+
201
+ # Deserializes the data based on type
202
+ # @param string type Data type
203
+ # @param string value Value to be deserialized
204
+ # @return [Object] Deserialized data
205
+ def _deserialize(type, value)
206
+ case type.to_sym
207
+ when :DateTime
208
+ DateTime.parse(value)
209
+ when :Date
210
+ Date.parse(value)
211
+ when :Time
212
+ Time.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
+ Phrase.const_get(type).build_from_hash(value)
241
+ end
242
+ end
243
+
244
+ # Returns the string representation of the object
245
+ # @return [String] String presentation of the object
246
+ def to_s
247
+ to_hash.to_s
248
+ end
249
+
250
+ # to_body is an alias to to_hash (backward compatibility)
251
+ # @return [Hash] Returns the object in the form of hash
252
+ def to_body
253
+ to_hash
254
+ end
255
+
256
+ # Returns the object in the form of hash
257
+ # @return [Hash] Returns the object in the form of hash
258
+ def to_hash
259
+ hash = {}
260
+ self.class.attribute_map.each_pair do |attr, param|
261
+ value = self.send(attr)
262
+ if value.nil?
263
+ is_nullable = self.class.openapi_nullable.include?(attr)
264
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
265
+ end
266
+
267
+ hash[param] = _to_hash(value)
268
+ end
269
+ hash
270
+ end
271
+
272
+ # Outputs non-array value in the form of hash
273
+ # For object, use to_hash. Otherwise, just return the value
274
+ # @param [Object] value Any valid value
275
+ # @return [Hash] Returns the value in the form of hash
276
+ def _to_hash(value)
277
+ if value.is_a?(Array)
278
+ value.compact.map { |v| _to_hash(v) }
279
+ elsif value.is_a?(Hash)
280
+ {}.tap do |hash|
281
+ value.each { |k, v| hash[k] = _to_hash(v) }
282
+ end
283
+ elsif value.respond_to? :to_hash
284
+ value.to_hash
285
+ else
286
+ value
287
+ end
288
+ end
289
+ end
290
+ end