phrase 2.21.0 → 2.22.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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/README.md +14 -3
  4. data/docs/CustomMetadataApi.md +12 -26
  5. data/docs/CustomMetadataPropertiesCreateParameters.md +25 -0
  6. data/docs/CustomMetadataPropertiesUpdateParameters.md +23 -0
  7. data/docs/Error.md +17 -0
  8. data/docs/ErrorError.md +19 -0
  9. data/docs/KeyCreateParameters.md +1 -1
  10. data/docs/KeyUpdateParameters.md +1 -1
  11. data/docs/ProjectCreateParameters.md +1 -1
  12. data/docs/ProjectUpdateParameters.md +1 -1
  13. data/docs/ProjectsQualityPerformanceScore200Response.md +21 -0
  14. data/docs/ProjectsQualityPerformanceScore200ResponseAnyOf.md +19 -0
  15. data/docs/ProjectsQualityPerformanceScore200ResponseAnyOfData.md +17 -0
  16. data/docs/ProjectsQualityPerformanceScore200ResponseAnyOfDataTranslationsInner.md +21 -0
  17. data/docs/ProjectsQualityPerformanceScore200ResponseAnyOfErrorsInner.md +21 -0
  18. data/docs/ProjectsQualityPerformanceScoreRequest.md +17 -0
  19. data/docs/QualityPerformanceScoreApi.md +72 -0
  20. data/docs/ScreenshotUpdateParameters.md +1 -1
  21. data/lib/phrase/api/custom_metadata_api.rb +23 -42
  22. data/lib/phrase/api/quality_performance_score_api.rb +84 -0
  23. data/lib/phrase/models/custom_metadata_properties_create_parameters.rb +272 -0
  24. data/lib/phrase/models/custom_metadata_properties_update_parameters.rb +231 -0
  25. data/lib/phrase/models/error.rb +197 -0
  26. data/lib/phrase/models/error_error.rb +205 -0
  27. data/lib/phrase/models/projects_quality_performance_score200_response.rb +237 -0
  28. data/lib/phrase/models/projects_quality_performance_score200_response_any_of.rb +208 -0
  29. data/lib/phrase/models/projects_quality_performance_score200_response_any_of_data.rb +198 -0
  30. data/lib/phrase/models/projects_quality_performance_score200_response_any_of_data_translations_inner.rb +217 -0
  31. data/lib/phrase/models/projects_quality_performance_score200_response_any_of_errors_inner.rb +215 -0
  32. data/lib/phrase/models/projects_quality_performance_score_request.rb +199 -0
  33. data/lib/phrase/version.rb +1 -1
  34. data/lib/phrase.rb +11 -0
  35. data/spec/api/custom_metadata_api_spec.rb +2 -9
  36. data/spec/api/quality_performance_score_api_spec.rb +37 -0
  37. data/spec/models/custom_metadata_properties_create_parameters_spec.rb +53 -0
  38. data/spec/models/custom_metadata_properties_update_parameters_spec.rb +47 -0
  39. data/spec/models/error_error_spec.rb +35 -0
  40. data/spec/models/error_spec.rb +29 -0
  41. data/spec/models/projects_quality_performance_score200_response_any_of_data_spec.rb +29 -0
  42. data/spec/models/projects_quality_performance_score200_response_any_of_data_translations_inner_spec.rb +41 -0
  43. data/spec/models/projects_quality_performance_score200_response_any_of_errors_inner_spec.rb +41 -0
  44. data/spec/models/projects_quality_performance_score200_response_any_of_spec.rb +35 -0
  45. data/spec/models/projects_quality_performance_score200_response_spec.rb +41 -0
  46. data/spec/models/projects_quality_performance_score_request_spec.rb +29 -0
  47. metadata +259 -215
@@ -164,31 +164,23 @@ module Phrase
164
164
  # Create a property
165
165
  # Create a new custom metadata property.
166
166
  # @param account_id [String] Account ID
167
- # @param name [String] name of the property
168
- # @param data_type [CustomMetadataDataType] Data Type of Custom Metadata Property
167
+ # @param custom_metadata_properties_create_parameters [CustomMetadataPropertiesCreateParameters]
169
168
  # @param [Hash] opts the optional parameters
170
169
  # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
171
- # @option opts [String] :description description of property
172
- # @option opts [Array<String>] :project_ids ids of projects that the property belongs to
173
- # @option opts [Array<String>] :value_options value options of property (only applies to single or multi select properties)
174
170
  # @return [CustomMetadataProperty]
175
- def custom_metadata_property_create(account_id, name, data_type, opts = {})
176
- data, _status_code, _headers = custom_metadata_property_create_with_http_info(account_id, name, data_type, opts)
171
+ def custom_metadata_property_create(account_id, custom_metadata_properties_create_parameters, opts = {})
172
+ data, _status_code, _headers = custom_metadata_property_create_with_http_info(account_id, custom_metadata_properties_create_parameters, opts)
177
173
  data
178
174
  end
179
175
 
180
176
  # Create a property
181
177
  # Create a new custom metadata property.
182
178
  # @param account_id [String] Account ID
183
- # @param name [String] name of the property
184
- # @param data_type [CustomMetadataDataType] Data Type of Custom Metadata Property
179
+ # @param custom_metadata_properties_create_parameters [CustomMetadataPropertiesCreateParameters]
185
180
  # @param [Hash] opts the optional parameters
186
181
  # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
187
- # @option opts [String] :description description of property
188
- # @option opts [Array<String>] :project_ids ids of projects that the property belongs to
189
- # @option opts [Array<String>] :value_options value options of property (only applies to single or multi select properties)
190
182
  # @return [Array<(Response<(CustomMetadataProperty)>, Integer, Hash)>] Response<(CustomMetadataProperty)> data, response status code and response headers
191
- def custom_metadata_property_create_with_http_info(account_id, name, data_type, opts = {})
183
+ def custom_metadata_property_create_with_http_info(account_id, custom_metadata_properties_create_parameters, opts = {})
192
184
  if @api_client.config.debugging
193
185
  @api_client.config.logger.debug 'Calling API: CustomMetadataApi.custom_metadata_property_create ...'
194
186
  end
@@ -196,36 +188,29 @@ module Phrase
196
188
  if @api_client.config.client_side_validation && account_id.nil?
197
189
  fail ArgumentError, "Missing the required parameter 'account_id' when calling CustomMetadataApi.custom_metadata_property_create"
198
190
  end
199
- # verify the required parameter 'name' is set
200
- if @api_client.config.client_side_validation && name.nil?
201
- fail ArgumentError, "Missing the required parameter 'name' when calling CustomMetadataApi.custom_metadata_property_create"
202
- end
203
- # verify the required parameter 'data_type' is set
204
- if @api_client.config.client_side_validation && data_type.nil?
205
- fail ArgumentError, "Missing the required parameter 'data_type' when calling CustomMetadataApi.custom_metadata_property_create"
191
+ # verify the required parameter 'custom_metadata_properties_create_parameters' is set
192
+ if @api_client.config.client_side_validation && custom_metadata_properties_create_parameters.nil?
193
+ fail ArgumentError, "Missing the required parameter 'custom_metadata_properties_create_parameters' when calling CustomMetadataApi.custom_metadata_property_create"
206
194
  end
207
195
  # resource path
208
196
  local_var_path = '/accounts/{account_id}/custom_metadata/properties'.sub('{' + 'account_id' + '}', CGI.escape(account_id.to_s))
209
197
 
210
198
  # query parameters
211
199
  query_params = opts[:query_params] || {}
212
- query_params[:'name'] = name
213
- query_params[:'data_type'] = data_type
214
- query_params[:'description'] = opts[:'description'] if !opts[:'description'].nil?
215
- query_params[:'project_ids'] = @api_client.build_collection_param(opts[:'project_ids'], :multi) if !opts[:'project_ids'].nil?
216
- query_params[:'value_options'] = @api_client.build_collection_param(opts[:'value_options'], :multi) if !opts[:'value_options'].nil?
217
200
 
218
201
  # header parameters
219
202
  header_params = opts[:header_params] || {}
220
203
  # HTTP header 'Accept' (if needed)
221
204
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
205
+ # HTTP header 'Content-Type'
206
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
222
207
  header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
223
208
 
224
209
  # form parameters
225
210
  form_params = opts[:form_params] || {}
226
211
 
227
212
  # http body (model)
228
- post_body = opts[:body]
213
+ post_body = opts[:body] || @api_client.object_to_http_body(custom_metadata_properties_create_parameters)
229
214
 
230
215
  # return_type
231
216
  return_type = opts[:return_type] || 'CustomMetadataProperty'
@@ -326,15 +311,12 @@ module Phrase
326
311
  # Update an existing custom metadata property.
327
312
  # @param account_id [String] Account ID
328
313
  # @param id [String] ID
314
+ # @param custom_metadata_properties_update_parameters [CustomMetadataPropertiesUpdateParameters]
329
315
  # @param [Hash] opts the optional parameters
330
316
  # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
331
- # @option opts [String] :name name of the property
332
- # @option opts [String] :description description of property
333
- # @option opts [Array<String>] :project_ids ids of projects that the property belongs to
334
- # @option opts [Array<String>] :value_options value options of property (only applies to single or multi select properties)
335
317
  # @return [CustomMetadataProperty]
336
- def custom_metadata_property_update(account_id, id, opts = {})
337
- data, _status_code, _headers = custom_metadata_property_update_with_http_info(account_id, id, opts)
318
+ def custom_metadata_property_update(account_id, id, custom_metadata_properties_update_parameters, opts = {})
319
+ data, _status_code, _headers = custom_metadata_property_update_with_http_info(account_id, id, custom_metadata_properties_update_parameters, opts)
338
320
  data
339
321
  end
340
322
 
@@ -342,14 +324,11 @@ module Phrase
342
324
  # Update an existing custom metadata property.
343
325
  # @param account_id [String] Account ID
344
326
  # @param id [String] ID
327
+ # @param custom_metadata_properties_update_parameters [CustomMetadataPropertiesUpdateParameters]
345
328
  # @param [Hash] opts the optional parameters
346
329
  # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
347
- # @option opts [String] :name name of the property
348
- # @option opts [String] :description description of property
349
- # @option opts [Array<String>] :project_ids ids of projects that the property belongs to
350
- # @option opts [Array<String>] :value_options value options of property (only applies to single or multi select properties)
351
330
  # @return [Array<(Response<(CustomMetadataProperty)>, Integer, Hash)>] Response<(CustomMetadataProperty)> data, response status code and response headers
352
- def custom_metadata_property_update_with_http_info(account_id, id, opts = {})
331
+ def custom_metadata_property_update_with_http_info(account_id, id, custom_metadata_properties_update_parameters, opts = {})
353
332
  if @api_client.config.debugging
354
333
  @api_client.config.logger.debug 'Calling API: CustomMetadataApi.custom_metadata_property_update ...'
355
334
  end
@@ -361,27 +340,29 @@ module Phrase
361
340
  if @api_client.config.client_side_validation && id.nil?
362
341
  fail ArgumentError, "Missing the required parameter 'id' when calling CustomMetadataApi.custom_metadata_property_update"
363
342
  end
343
+ # verify the required parameter 'custom_metadata_properties_update_parameters' is set
344
+ if @api_client.config.client_side_validation && custom_metadata_properties_update_parameters.nil?
345
+ fail ArgumentError, "Missing the required parameter 'custom_metadata_properties_update_parameters' when calling CustomMetadataApi.custom_metadata_property_update"
346
+ end
364
347
  # resource path
365
348
  local_var_path = '/accounts/{account_id}/custom_metadata/properties/{id}'.sub('{' + 'account_id' + '}', CGI.escape(account_id.to_s)).sub('{' + 'id' + '}', CGI.escape(id.to_s))
366
349
 
367
350
  # query parameters
368
351
  query_params = opts[:query_params] || {}
369
- query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?
370
- query_params[:'description'] = opts[:'description'] if !opts[:'description'].nil?
371
- query_params[:'project_ids'] = @api_client.build_collection_param(opts[:'project_ids'], :multi) if !opts[:'project_ids'].nil?
372
- query_params[:'value_options'] = @api_client.build_collection_param(opts[:'value_options'], :multi) if !opts[:'value_options'].nil?
373
352
 
374
353
  # header parameters
375
354
  header_params = opts[:header_params] || {}
376
355
  # HTTP header 'Accept' (if needed)
377
356
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
357
+ # HTTP header 'Content-Type'
358
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
378
359
  header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
379
360
 
380
361
  # form parameters
381
362
  form_params = opts[:form_params] || {}
382
363
 
383
364
  # http body (model)
384
- post_body = opts[:body]
365
+ post_body = opts[:body] || @api_client.object_to_http_body(custom_metadata_properties_update_parameters)
385
366
 
386
367
  # return_type
387
368
  return_type = opts[:return_type] || 'CustomMetadataProperty'
@@ -0,0 +1,84 @@
1
+ require 'cgi'
2
+
3
+ module Phrase
4
+ class QualityPerformanceScoreApi
5
+ attr_accessor :api_client
6
+
7
+ def initialize(api_client = ApiClient.default)
8
+ @api_client = api_client
9
+ end
10
+ # Get project's translations' quality performance scores
11
+ # Get project's translations' quality performance scores
12
+ # @param id [String] ID
13
+ # @param projects_quality_performance_score_request [ProjectsQualityPerformanceScoreRequest]
14
+ # @param [Hash] opts the optional parameters
15
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
16
+ # @return [ProjectsQualityPerformanceScore200Response]
17
+ def projects_quality_performance_score(id, projects_quality_performance_score_request, opts = {})
18
+ data, _status_code, _headers = projects_quality_performance_score_with_http_info(id, projects_quality_performance_score_request, opts)
19
+ data
20
+ end
21
+
22
+ # Get project&#39;s translations&#39; quality performance scores
23
+ # Get project&#39;s translations&#39; quality performance scores
24
+ # @param id [String] ID
25
+ # @param projects_quality_performance_score_request [ProjectsQualityPerformanceScoreRequest]
26
+ # @param [Hash] opts the optional parameters
27
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
28
+ # @return [Array<(Response<(ProjectsQualityPerformanceScore200Response)>, Integer, Hash)>] Response<(ProjectsQualityPerformanceScore200Response)> data, response status code and response headers
29
+ def projects_quality_performance_score_with_http_info(id, projects_quality_performance_score_request, opts = {})
30
+ if @api_client.config.debugging
31
+ @api_client.config.logger.debug 'Calling API: QualityPerformanceScoreApi.projects_quality_performance_score ...'
32
+ end
33
+ # verify the required parameter 'id' is set
34
+ if @api_client.config.client_side_validation && id.nil?
35
+ fail ArgumentError, "Missing the required parameter 'id' when calling QualityPerformanceScoreApi.projects_quality_performance_score"
36
+ end
37
+ # verify the required parameter 'projects_quality_performance_score_request' is set
38
+ if @api_client.config.client_side_validation && projects_quality_performance_score_request.nil?
39
+ fail ArgumentError, "Missing the required parameter 'projects_quality_performance_score_request' when calling QualityPerformanceScoreApi.projects_quality_performance_score"
40
+ end
41
+ # resource path
42
+ local_var_path = '/projects/{id}/quality_performance_score'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
43
+
44
+ # query parameters
45
+ query_params = opts[:query_params] || {}
46
+
47
+ # header parameters
48
+ header_params = opts[:header_params] || {}
49
+ # HTTP header 'Accept' (if needed)
50
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
51
+ # HTTP header 'Content-Type'
52
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
53
+ header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
54
+
55
+ # form parameters
56
+ form_params = opts[:form_params] || {}
57
+
58
+ # http body (model)
59
+ post_body = opts[:body] || @api_client.object_to_http_body(projects_quality_performance_score_request)
60
+
61
+ # return_type
62
+ return_type = opts[:return_type] || 'ProjectsQualityPerformanceScore200Response'
63
+
64
+ # auth_names
65
+ auth_names = opts[:auth_names] || ['Basic', 'Token']
66
+
67
+ new_options = opts.merge(
68
+ :header_params => header_params,
69
+ :query_params => query_params,
70
+ :form_params => form_params,
71
+ :body => post_body,
72
+ :auth_names => auth_names,
73
+ :return_type => return_type
74
+ )
75
+
76
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
77
+ if @api_client.config.debugging
78
+ @api_client.config.logger.debug "API called: QualityPerformanceScoreApi#projects_quality_performance_score\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
79
+ end
80
+ response = ::Phrase::Response.new(data, headers)
81
+ return response, status_code, headers
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,272 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class CustomMetadataPropertiesCreateParameters
5
+ # name of the property
6
+ attr_accessor :name
7
+
8
+ attr_accessor :data_type
9
+
10
+ # ids of projects that the property belongs to
11
+ attr_accessor :project_ids
12
+
13
+ # description of property
14
+ attr_accessor :description
15
+
16
+ # value options of property (only applies to single or multi select properties)
17
+ attr_accessor :value_options
18
+
19
+ class EnumAttributeValidator
20
+ attr_reader :datatype
21
+ attr_reader :allowable_values
22
+
23
+ def initialize(datatype, allowable_values)
24
+ @allowable_values = allowable_values.map do |value|
25
+ case datatype.to_s
26
+ when /Integer/i
27
+ value.to_i
28
+ when /Float/i
29
+ value.to_f
30
+ else
31
+ value
32
+ end
33
+ end
34
+ end
35
+
36
+ def valid?(value)
37
+ !value || allowable_values.include?(value)
38
+ end
39
+ end
40
+
41
+ # Attribute mapping from ruby-style variable name to JSON key.
42
+ def self.attribute_map
43
+ {
44
+ :'name' => :'name',
45
+ :'data_type' => :'data_type',
46
+ :'project_ids' => :'project_ids',
47
+ :'description' => :'description',
48
+ :'value_options' => :'value_options'
49
+ }
50
+ end
51
+
52
+ # Attribute type mapping.
53
+ def self.openapi_types
54
+ {
55
+ :'name' => :'String',
56
+ :'data_type' => :'CustomMetadataDataType',
57
+ :'project_ids' => :'Array<String>',
58
+ :'description' => :'String',
59
+ :'value_options' => :'Array<String>'
60
+ }
61
+ end
62
+
63
+ # List of attributes with nullable: true
64
+ def self.openapi_nullable
65
+ Set.new([
66
+ ])
67
+ end
68
+
69
+ # Initializes the object
70
+ # @param [Hash] attributes Model attributes in the form of hash
71
+ def initialize(attributes = {})
72
+ if (!attributes.is_a?(Hash))
73
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::CustomMetadataPropertiesCreateParameters` initialize method"
74
+ end
75
+
76
+ # check to see if the attribute exists and convert string to symbol for hash key
77
+ attributes = attributes.each_with_object({}) { |(k, v), h|
78
+ if (!self.class.attribute_map.key?(k.to_sym))
79
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::CustomMetadataPropertiesCreateParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
80
+ end
81
+ h[k.to_sym] = v
82
+ }
83
+
84
+ if attributes.key?(:'name')
85
+ self.name = attributes[:'name']
86
+ end
87
+
88
+ if attributes.key?(:'data_type')
89
+ self.data_type = attributes[:'data_type']
90
+ end
91
+
92
+ if attributes.key?(:'project_ids')
93
+ if (value = attributes[:'project_ids']).is_a?(Array)
94
+ self.project_ids = value
95
+ end
96
+ end
97
+
98
+ if attributes.key?(:'description')
99
+ self.description = attributes[:'description']
100
+ end
101
+
102
+ if attributes.key?(:'value_options')
103
+ if (value = attributes[:'value_options']).is_a?(Array)
104
+ self.value_options = value
105
+ end
106
+ end
107
+ end
108
+
109
+ # Show invalid properties with the reasons. Usually used together with valid?
110
+ # @return Array for valid properties with the reasons
111
+ def list_invalid_properties
112
+ invalid_properties = Array.new
113
+ if @name.nil?
114
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
115
+ end
116
+
117
+ if @data_type.nil?
118
+ invalid_properties.push('invalid value for "data_type", data_type cannot be nil.')
119
+ end
120
+
121
+ invalid_properties
122
+ end
123
+
124
+ # Check to see if the all the properties in the model are valid
125
+ # @return true if the model is valid
126
+ def valid?
127
+ return false if @name.nil?
128
+ return false if @data_type.nil?
129
+ true
130
+ end
131
+
132
+ # Checks equality by comparing each attribute.
133
+ # @param [Object] Object to be compared
134
+ def ==(o)
135
+ return true if self.equal?(o)
136
+ self.class == o.class &&
137
+ name == o.name &&
138
+ data_type == o.data_type &&
139
+ project_ids == o.project_ids &&
140
+ description == o.description &&
141
+ value_options == o.value_options
142
+ end
143
+
144
+ # @see the `==` method
145
+ # @param [Object] Object to be compared
146
+ def eql?(o)
147
+ self == o
148
+ end
149
+
150
+ # Calculates hash code according to all attributes.
151
+ # @return [Integer] Hash code
152
+ def hash
153
+ [name, data_type, project_ids, description, value_options].hash
154
+ end
155
+
156
+ # Builds the object from hash
157
+ # @param [Hash] attributes Model attributes in the form of hash
158
+ # @return [Object] Returns the model itself
159
+ def self.build_from_hash(attributes)
160
+ new.build_from_hash(attributes)
161
+ end
162
+
163
+ # Builds the object from hash
164
+ # @param [Hash] attributes Model attributes in the form of hash
165
+ # @return [Object] Returns the model itself
166
+ def build_from_hash(attributes)
167
+ return nil unless attributes.is_a?(Hash)
168
+ self.class.openapi_types.each_pair do |key, type|
169
+ if type =~ /\AArray<(.*)>/i
170
+ # check to ensure the input is an array given that the attribute
171
+ # is documented as an array but the input is not
172
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
173
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
174
+ end
175
+ elsif !attributes[self.class.attribute_map[key]].nil?
176
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
177
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
178
+ end
179
+
180
+ self
181
+ end
182
+
183
+ # Deserializes the data based on type
184
+ # @param string type Data type
185
+ # @param string value Value to be deserialized
186
+ # @return [Object] Deserialized data
187
+ def _deserialize(type, value)
188
+ case type.to_sym
189
+ when :DateTime
190
+ DateTime.parse(value)
191
+ when :Date
192
+ Date.parse(value)
193
+ when :Time
194
+ Time.parse(value)
195
+ when :String
196
+ value.to_s
197
+ when :Integer
198
+ value.to_i
199
+ when :Float
200
+ value.to_f
201
+ when :Boolean
202
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
203
+ true
204
+ else
205
+ false
206
+ end
207
+ when :Object
208
+ # generic object (usually a Hash), return directly
209
+ value
210
+ when /\AArray<(?<inner_type>.+)>\z/
211
+ inner_type = Regexp.last_match[:inner_type]
212
+ value.map { |v| _deserialize(inner_type, v) }
213
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
214
+ k_type = Regexp.last_match[:k_type]
215
+ v_type = Regexp.last_match[:v_type]
216
+ {}.tap do |hash|
217
+ value.each do |k, v|
218
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
219
+ end
220
+ end
221
+ else # model
222
+ Phrase.const_get(type).build_from_hash(value)
223
+ end
224
+ end
225
+
226
+ # Returns the string representation of the object
227
+ # @return [String] String presentation of the object
228
+ def to_s
229
+ to_hash.to_s
230
+ end
231
+
232
+ # to_body is an alias to to_hash (backward compatibility)
233
+ # @return [Hash] Returns the object in the form of hash
234
+ def to_body
235
+ to_hash
236
+ end
237
+
238
+ # Returns the object in the form of hash
239
+ # @return [Hash] Returns the object in the form of hash
240
+ def to_hash
241
+ hash = {}
242
+ self.class.attribute_map.each_pair do |attr, param|
243
+ value = self.send(attr)
244
+ if value.nil?
245
+ is_nullable = self.class.openapi_nullable.include?(attr)
246
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
247
+ end
248
+
249
+ hash[param] = _to_hash(value)
250
+ end
251
+ hash
252
+ end
253
+
254
+ # Outputs non-array value in the form of hash
255
+ # For object, use to_hash. Otherwise, just return the value
256
+ # @param [Object] value Any valid value
257
+ # @return [Hash] Returns the value in the form of hash
258
+ def _to_hash(value)
259
+ if value.is_a?(Array)
260
+ value.compact.map { |v| _to_hash(v) }
261
+ elsif value.is_a?(Hash)
262
+ {}.tap do |hash|
263
+ value.each { |k, v| hash[k] = _to_hash(v) }
264
+ end
265
+ elsif value.respond_to? :to_hash
266
+ value.to_hash
267
+ else
268
+ value
269
+ end
270
+ end
271
+ end
272
+ end