phrase 2.20.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 (86) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/README.md +27 -5
  4. data/docs/CustomMetadataApi.md +339 -0
  5. data/docs/CustomMetadataDataType.md +16 -0
  6. data/docs/CustomMetadataPropertiesCreateParameters.md +25 -0
  7. data/docs/CustomMetadataPropertiesUpdateParameters.md +23 -0
  8. data/docs/CustomMetadataProperty.md +33 -0
  9. data/docs/CustomMetadataPropertyCreate422Response.md +19 -0
  10. data/docs/{InvitationCreate422ResponseErrorsInner.md → CustomMetadataPropertyCreate422ResponseErrorsInner.md} +2 -2
  11. data/docs/Error.md +17 -0
  12. data/docs/ErrorError.md +19 -0
  13. data/docs/KeyCreateParameters.md +4 -2
  14. data/docs/KeyUpdateParameters.md +4 -2
  15. data/docs/KeysApi.md +2 -2
  16. data/docs/KeysSearchParameters.md +1 -1
  17. data/docs/LocaleReport.md +43 -0
  18. data/docs/LocalesApi.md +3 -1
  19. data/docs/ProjectCreateParameters.md +1 -1
  20. data/docs/ProjectReport.md +31 -0
  21. data/docs/ProjectUpdateParameters.md +1 -1
  22. data/docs/ProjectsQualityPerformanceScore200Response.md +21 -0
  23. data/docs/ProjectsQualityPerformanceScore200ResponseAnyOf.md +19 -0
  24. data/docs/ProjectsQualityPerformanceScore200ResponseAnyOfData.md +17 -0
  25. data/docs/ProjectsQualityPerformanceScore200ResponseAnyOfDataTranslationsInner.md +21 -0
  26. data/docs/ProjectsQualityPerformanceScore200ResponseAnyOfErrorsInner.md +21 -0
  27. data/docs/ProjectsQualityPerformanceScoreRequest.md +17 -0
  28. data/docs/QualityPerformanceScoreApi.md +72 -0
  29. data/docs/ReportsApi.md +144 -0
  30. data/docs/ScreenshotUpdateParameters.md +1 -1
  31. data/docs/TranslationKeyDetails.md +3 -1
  32. data/docs/Upload.md +2 -0
  33. data/lib/phrase/api/custom_metadata_api.rb +390 -0
  34. data/lib/phrase/api/keys_api.rb +2 -2
  35. data/lib/phrase/api/locales_api.rb +3 -0
  36. data/lib/phrase/api/quality_performance_score_api.rb +84 -0
  37. data/lib/phrase/api/reports_api.rb +160 -0
  38. data/lib/phrase/models/custom_metadata_data_type.rb +30 -0
  39. data/lib/phrase/models/custom_metadata_properties_create_parameters.rb +272 -0
  40. data/lib/phrase/models/custom_metadata_properties_update_parameters.rb +231 -0
  41. data/lib/phrase/models/custom_metadata_property.rb +294 -0
  42. data/lib/phrase/models/{invitation_create422_response.rb → custom_metadata_property_create422_response.rb} +4 -4
  43. data/lib/phrase/models/{invitation_create422_response_errors_inner.rb → custom_metadata_property_create422_response_errors_inner.rb} +3 -3
  44. data/lib/phrase/models/error.rb +197 -0
  45. data/lib/phrase/models/error_error.rb +205 -0
  46. data/lib/phrase/models/key_create_parameters.rb +14 -4
  47. data/lib/phrase/models/key_update_parameters.rb +14 -4
  48. data/lib/phrase/models/keys_search_parameters.rb +1 -1
  49. data/lib/phrase/models/locale_report.rb +313 -0
  50. data/lib/phrase/models/project_report.rb +259 -0
  51. data/lib/phrase/models/projects_quality_performance_score200_response.rb +237 -0
  52. data/lib/phrase/models/projects_quality_performance_score200_response_any_of.rb +208 -0
  53. data/lib/phrase/models/projects_quality_performance_score200_response_any_of_data.rb +198 -0
  54. data/lib/phrase/models/projects_quality_performance_score200_response_any_of_data_translations_inner.rb +217 -0
  55. data/lib/phrase/models/projects_quality_performance_score200_response_any_of_errors_inner.rb +215 -0
  56. data/lib/phrase/models/projects_quality_performance_score_request.rb +199 -0
  57. data/lib/phrase/models/translation_key_details.rb +15 -4
  58. data/lib/phrase/models/upload.rb +11 -1
  59. data/lib/phrase/version.rb +1 -1
  60. data/lib/phrase.rb +19 -2
  61. data/spec/api/custom_metadata_api_spec.rb +99 -0
  62. data/spec/api/keys_api_spec.rb +1 -1
  63. data/spec/api/quality_performance_score_api_spec.rb +37 -0
  64. data/spec/api/reports_api_spec.rb +55 -0
  65. data/spec/models/custom_metadata_data_type_spec.rb +23 -0
  66. data/spec/models/custom_metadata_properties_create_parameters_spec.rb +53 -0
  67. data/spec/models/custom_metadata_properties_update_parameters_spec.rb +47 -0
  68. data/spec/models/{invitation_create422_response_errors_inner_spec.rb → custom_metadata_property_create422_response_errors_inner_spec.rb} +6 -6
  69. data/spec/models/custom_metadata_property_create422_response_spec.rb +35 -0
  70. data/spec/models/custom_metadata_property_spec.rb +77 -0
  71. data/spec/models/{invitation_create422_response_spec.rb → error_error_spec.rb} +7 -7
  72. data/spec/models/error_spec.rb +29 -0
  73. data/spec/models/key_create_parameters_spec.rb +6 -0
  74. data/spec/models/key_update_parameters_spec.rb +6 -0
  75. data/spec/models/locale_report_spec.rb +107 -0
  76. data/spec/models/project_report_spec.rb +71 -0
  77. data/spec/models/projects_quality_performance_score200_response_any_of_data_spec.rb +29 -0
  78. data/spec/models/projects_quality_performance_score200_response_any_of_data_translations_inner_spec.rb +41 -0
  79. data/spec/models/projects_quality_performance_score200_response_any_of_errors_inner_spec.rb +41 -0
  80. data/spec/models/projects_quality_performance_score200_response_any_of_spec.rb +35 -0
  81. data/spec/models/projects_quality_performance_score200_response_spec.rb +41 -0
  82. data/spec/models/projects_quality_performance_score_request_spec.rb +29 -0
  83. data/spec/models/translation_key_details_spec.rb +6 -0
  84. data/spec/models/upload_spec.rb +6 -0
  85. metadata +285 -217
  86. data/docs/InvitationCreate422Response.md +0 -19
@@ -0,0 +1,294 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class CustomMetadataProperty
5
+ attr_accessor :id
6
+
7
+ attr_accessor :name
8
+
9
+ attr_accessor :description
10
+
11
+ attr_accessor :data_type
12
+
13
+ attr_accessor :user
14
+
15
+ attr_accessor :projects
16
+
17
+ attr_accessor :value_options
18
+
19
+ attr_accessor :created_at
20
+
21
+ attr_accessor :updated_at
22
+
23
+ class EnumAttributeValidator
24
+ attr_reader :datatype
25
+ attr_reader :allowable_values
26
+
27
+ def initialize(datatype, allowable_values)
28
+ @allowable_values = allowable_values.map do |value|
29
+ case datatype.to_s
30
+ when /Integer/i
31
+ value.to_i
32
+ when /Float/i
33
+ value.to_f
34
+ else
35
+ value
36
+ end
37
+ end
38
+ end
39
+
40
+ def valid?(value)
41
+ !value || allowable_values.include?(value)
42
+ end
43
+ end
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'id' => :'id',
49
+ :'name' => :'name',
50
+ :'description' => :'description',
51
+ :'data_type' => :'data_type',
52
+ :'user' => :'user',
53
+ :'projects' => :'projects',
54
+ :'value_options' => :'value_options',
55
+ :'created_at' => :'created_at',
56
+ :'updated_at' => :'updated_at'
57
+ }
58
+ end
59
+
60
+ # Attribute type mapping.
61
+ def self.openapi_types
62
+ {
63
+ :'id' => :'String',
64
+ :'name' => :'String',
65
+ :'description' => :'String',
66
+ :'data_type' => :'CustomMetadataDataType',
67
+ :'user' => :'UserPreview',
68
+ :'projects' => :'Array<ProjectShort>',
69
+ :'value_options' => :'Array<String>',
70
+ :'created_at' => :'DateTime',
71
+ :'updated_at' => :'DateTime'
72
+ }
73
+ end
74
+
75
+ # List of attributes with nullable: true
76
+ def self.openapi_nullable
77
+ Set.new([
78
+ ])
79
+ end
80
+
81
+ # Initializes the object
82
+ # @param [Hash] attributes Model attributes in the form of hash
83
+ def initialize(attributes = {})
84
+ if (!attributes.is_a?(Hash))
85
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::CustomMetadataProperty` initialize method"
86
+ end
87
+
88
+ # check to see if the attribute exists and convert string to symbol for hash key
89
+ attributes = attributes.each_with_object({}) { |(k, v), h|
90
+ if (!self.class.attribute_map.key?(k.to_sym))
91
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::CustomMetadataProperty`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
92
+ end
93
+ h[k.to_sym] = v
94
+ }
95
+
96
+ if attributes.key?(:'id')
97
+ self.id = attributes[:'id']
98
+ end
99
+
100
+ if attributes.key?(:'name')
101
+ self.name = attributes[:'name']
102
+ end
103
+
104
+ if attributes.key?(:'description')
105
+ self.description = attributes[:'description']
106
+ end
107
+
108
+ if attributes.key?(:'data_type')
109
+ self.data_type = attributes[:'data_type']
110
+ end
111
+
112
+ if attributes.key?(:'user')
113
+ self.user = attributes[:'user']
114
+ end
115
+
116
+ if attributes.key?(:'projects')
117
+ if (value = attributes[:'projects']).is_a?(Array)
118
+ self.projects = value
119
+ end
120
+ end
121
+
122
+ if attributes.key?(:'value_options')
123
+ if (value = attributes[:'value_options']).is_a?(Array)
124
+ self.value_options = value
125
+ end
126
+ end
127
+
128
+ if attributes.key?(:'created_at')
129
+ self.created_at = attributes[:'created_at']
130
+ end
131
+
132
+ if attributes.key?(:'updated_at')
133
+ self.updated_at = attributes[:'updated_at']
134
+ end
135
+ end
136
+
137
+ # Show invalid properties with the reasons. Usually used together with valid?
138
+ # @return Array for valid properties with the reasons
139
+ def list_invalid_properties
140
+ invalid_properties = Array.new
141
+ invalid_properties
142
+ end
143
+
144
+ # Check to see if the all the properties in the model are valid
145
+ # @return true if the model is valid
146
+ def valid?
147
+ true
148
+ end
149
+
150
+ # Checks equality by comparing each attribute.
151
+ # @param [Object] Object to be compared
152
+ def ==(o)
153
+ return true if self.equal?(o)
154
+ self.class == o.class &&
155
+ id == o.id &&
156
+ name == o.name &&
157
+ description == o.description &&
158
+ data_type == o.data_type &&
159
+ user == o.user &&
160
+ projects == o.projects &&
161
+ value_options == o.value_options &&
162
+ created_at == o.created_at &&
163
+ updated_at == o.updated_at
164
+ end
165
+
166
+ # @see the `==` method
167
+ # @param [Object] Object to be compared
168
+ def eql?(o)
169
+ self == o
170
+ end
171
+
172
+ # Calculates hash code according to all attributes.
173
+ # @return [Integer] Hash code
174
+ def hash
175
+ [id, name, description, data_type, user, projects, value_options, created_at, updated_at].hash
176
+ end
177
+
178
+ # Builds the object from hash
179
+ # @param [Hash] attributes Model attributes in the form of hash
180
+ # @return [Object] Returns the model itself
181
+ def self.build_from_hash(attributes)
182
+ new.build_from_hash(attributes)
183
+ end
184
+
185
+ # Builds the object from hash
186
+ # @param [Hash] attributes Model attributes in the form of hash
187
+ # @return [Object] Returns the model itself
188
+ def build_from_hash(attributes)
189
+ return nil unless attributes.is_a?(Hash)
190
+ self.class.openapi_types.each_pair do |key, type|
191
+ if type =~ /\AArray<(.*)>/i
192
+ # check to ensure the input is an array given that the attribute
193
+ # is documented as an array but the input is not
194
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
195
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
196
+ end
197
+ elsif !attributes[self.class.attribute_map[key]].nil?
198
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
199
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
200
+ end
201
+
202
+ self
203
+ end
204
+
205
+ # Deserializes the data based on type
206
+ # @param string type Data type
207
+ # @param string value Value to be deserialized
208
+ # @return [Object] Deserialized data
209
+ def _deserialize(type, value)
210
+ case type.to_sym
211
+ when :DateTime
212
+ DateTime.parse(value)
213
+ when :Date
214
+ Date.parse(value)
215
+ when :Time
216
+ Time.parse(value)
217
+ when :String
218
+ value.to_s
219
+ when :Integer
220
+ value.to_i
221
+ when :Float
222
+ value.to_f
223
+ when :Boolean
224
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
225
+ true
226
+ else
227
+ false
228
+ end
229
+ when :Object
230
+ # generic object (usually a Hash), return directly
231
+ value
232
+ when /\AArray<(?<inner_type>.+)>\z/
233
+ inner_type = Regexp.last_match[:inner_type]
234
+ value.map { |v| _deserialize(inner_type, v) }
235
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
236
+ k_type = Regexp.last_match[:k_type]
237
+ v_type = Regexp.last_match[:v_type]
238
+ {}.tap do |hash|
239
+ value.each do |k, v|
240
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
241
+ end
242
+ end
243
+ else # model
244
+ Phrase.const_get(type).build_from_hash(value)
245
+ end
246
+ end
247
+
248
+ # Returns the string representation of the object
249
+ # @return [String] String presentation of the object
250
+ def to_s
251
+ to_hash.to_s
252
+ end
253
+
254
+ # to_body is an alias to to_hash (backward compatibility)
255
+ # @return [Hash] Returns the object in the form of hash
256
+ def to_body
257
+ to_hash
258
+ end
259
+
260
+ # Returns the object in the form of hash
261
+ # @return [Hash] Returns the object in the form of hash
262
+ def to_hash
263
+ hash = {}
264
+ self.class.attribute_map.each_pair do |attr, param|
265
+ value = self.send(attr)
266
+ if value.nil?
267
+ is_nullable = self.class.openapi_nullable.include?(attr)
268
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
269
+ end
270
+
271
+ hash[param] = _to_hash(value)
272
+ end
273
+ hash
274
+ end
275
+
276
+ # Outputs non-array value in the form of hash
277
+ # For object, use to_hash. Otherwise, just return the value
278
+ # @param [Object] value Any valid value
279
+ # @return [Hash] Returns the value in the form of hash
280
+ def _to_hash(value)
281
+ if value.is_a?(Array)
282
+ value.compact.map { |v| _to_hash(v) }
283
+ elsif value.is_a?(Hash)
284
+ {}.tap do |hash|
285
+ value.each { |k, v| hash[k] = _to_hash(v) }
286
+ end
287
+ elsif value.respond_to? :to_hash
288
+ value.to_hash
289
+ else
290
+ value
291
+ end
292
+ end
293
+ end
294
+ end
@@ -1,7 +1,7 @@
1
1
  require 'date'
2
2
 
3
3
  module Phrase
4
- class InvitationCreate422Response
4
+ class CustomMetadataPropertyCreate422Response
5
5
  attr_accessor :message
6
6
 
7
7
  attr_accessor :errors
@@ -18,7 +18,7 @@ module Phrase
18
18
  def self.openapi_types
19
19
  {
20
20
  :'message' => :'String',
21
- :'errors' => :'Array<InvitationCreate422ResponseErrorsInner>'
21
+ :'errors' => :'Array<CustomMetadataPropertyCreate422ResponseErrorsInner>'
22
22
  }
23
23
  end
24
24
 
@@ -32,13 +32,13 @@ module Phrase
32
32
  # @param [Hash] attributes Model attributes in the form of hash
33
33
  def initialize(attributes = {})
34
34
  if (!attributes.is_a?(Hash))
35
- fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::InvitationCreate422Response` initialize method"
35
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::CustomMetadataPropertyCreate422Response` initialize method"
36
36
  end
37
37
 
38
38
  # check to see if the attribute exists and convert string to symbol for hash key
39
39
  attributes = attributes.each_with_object({}) { |(k, v), h|
40
40
  if (!self.class.attribute_map.key?(k.to_sym))
41
- fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::InvitationCreate422Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
41
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::CustomMetadataPropertyCreate422Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
42
42
  end
43
43
  h[k.to_sym] = v
44
44
  }
@@ -1,7 +1,7 @@
1
1
  require 'date'
2
2
 
3
3
  module Phrase
4
- class InvitationCreate422ResponseErrorsInner
4
+ class CustomMetadataPropertyCreate422ResponseErrorsInner
5
5
  attr_accessor :resource
6
6
 
7
7
  attr_accessor :field
@@ -36,13 +36,13 @@ module Phrase
36
36
  # @param [Hash] attributes Model attributes in the form of hash
37
37
  def initialize(attributes = {})
38
38
  if (!attributes.is_a?(Hash))
39
- fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::InvitationCreate422ResponseErrorsInner` initialize method"
39
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::CustomMetadataPropertyCreate422ResponseErrorsInner` initialize method"
40
40
  end
41
41
 
42
42
  # check to see if the attribute exists and convert string to symbol for hash key
43
43
  attributes = attributes.each_with_object({}) { |(k, v), h|
44
44
  if (!self.class.attribute_map.key?(k.to_sym))
45
- fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::InvitationCreate422ResponseErrorsInner`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
45
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::CustomMetadataPropertyCreate422ResponseErrorsInner`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
46
46
  end
47
47
  h[k.to_sym] = v
48
48
  }
@@ -0,0 +1,197 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ # Error field for when the request completely fails
5
+ class Error
6
+ attr_accessor :error
7
+
8
+ # Attribute mapping from ruby-style variable name to JSON key.
9
+ def self.attribute_map
10
+ {
11
+ :'error' => :'error'
12
+ }
13
+ end
14
+
15
+ # Attribute type mapping.
16
+ def self.openapi_types
17
+ {
18
+ :'error' => :'ErrorError'
19
+ }
20
+ end
21
+
22
+ # List of attributes with nullable: true
23
+ def self.openapi_nullable
24
+ Set.new([
25
+ ])
26
+ end
27
+
28
+ # Initializes the object
29
+ # @param [Hash] attributes Model attributes in the form of hash
30
+ def initialize(attributes = {})
31
+ if (!attributes.is_a?(Hash))
32
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::Error` initialize method"
33
+ end
34
+
35
+ # check to see if the attribute exists and convert string to symbol for hash key
36
+ attributes = attributes.each_with_object({}) { |(k, v), h|
37
+ if (!self.class.attribute_map.key?(k.to_sym))
38
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::Error`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
39
+ end
40
+ h[k.to_sym] = v
41
+ }
42
+
43
+ if attributes.key?(:'error')
44
+ self.error = attributes[:'error']
45
+ end
46
+ end
47
+
48
+ # Show invalid properties with the reasons. Usually used together with valid?
49
+ # @return Array for valid properties with the reasons
50
+ def list_invalid_properties
51
+ invalid_properties = Array.new
52
+ invalid_properties
53
+ end
54
+
55
+ # Check to see if the all the properties in the model are valid
56
+ # @return true if the model is valid
57
+ def valid?
58
+ true
59
+ end
60
+
61
+ # Checks equality by comparing each attribute.
62
+ # @param [Object] Object to be compared
63
+ def ==(o)
64
+ return true if self.equal?(o)
65
+ self.class == o.class &&
66
+ error == o.error
67
+ end
68
+
69
+ # @see the `==` method
70
+ # @param [Object] Object to be compared
71
+ def eql?(o)
72
+ self == o
73
+ end
74
+
75
+ # Calculates hash code according to all attributes.
76
+ # @return [Integer] Hash code
77
+ def hash
78
+ [error].hash
79
+ end
80
+
81
+ # Builds the object from hash
82
+ # @param [Hash] attributes Model attributes in the form of hash
83
+ # @return [Object] Returns the model itself
84
+ def self.build_from_hash(attributes)
85
+ new.build_from_hash(attributes)
86
+ end
87
+
88
+ # Builds the object from hash
89
+ # @param [Hash] attributes Model attributes in the form of hash
90
+ # @return [Object] Returns the model itself
91
+ def build_from_hash(attributes)
92
+ return nil unless attributes.is_a?(Hash)
93
+ self.class.openapi_types.each_pair do |key, type|
94
+ if type =~ /\AArray<(.*)>/i
95
+ # check to ensure the input is an array given that the attribute
96
+ # is documented as an array but the input is not
97
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
98
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
99
+ end
100
+ elsif !attributes[self.class.attribute_map[key]].nil?
101
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
102
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
103
+ end
104
+
105
+ self
106
+ end
107
+
108
+ # Deserializes the data based on type
109
+ # @param string type Data type
110
+ # @param string value Value to be deserialized
111
+ # @return [Object] Deserialized data
112
+ def _deserialize(type, value)
113
+ case type.to_sym
114
+ when :DateTime
115
+ DateTime.parse(value)
116
+ when :Date
117
+ Date.parse(value)
118
+ when :Time
119
+ Time.parse(value)
120
+ when :String
121
+ value.to_s
122
+ when :Integer
123
+ value.to_i
124
+ when :Float
125
+ value.to_f
126
+ when :Boolean
127
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
128
+ true
129
+ else
130
+ false
131
+ end
132
+ when :Object
133
+ # generic object (usually a Hash), return directly
134
+ value
135
+ when /\AArray<(?<inner_type>.+)>\z/
136
+ inner_type = Regexp.last_match[:inner_type]
137
+ value.map { |v| _deserialize(inner_type, v) }
138
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
139
+ k_type = Regexp.last_match[:k_type]
140
+ v_type = Regexp.last_match[:v_type]
141
+ {}.tap do |hash|
142
+ value.each do |k, v|
143
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
144
+ end
145
+ end
146
+ else # model
147
+ Phrase.const_get(type).build_from_hash(value)
148
+ end
149
+ end
150
+
151
+ # Returns the string representation of the object
152
+ # @return [String] String presentation of the object
153
+ def to_s
154
+ to_hash.to_s
155
+ end
156
+
157
+ # to_body is an alias to to_hash (backward compatibility)
158
+ # @return [Hash] Returns the object in the form of hash
159
+ def to_body
160
+ to_hash
161
+ end
162
+
163
+ # Returns the object in the form of hash
164
+ # @return [Hash] Returns the object in the form of hash
165
+ def to_hash
166
+ hash = {}
167
+ self.class.attribute_map.each_pair do |attr, param|
168
+ value = self.send(attr)
169
+ if value.nil?
170
+ is_nullable = self.class.openapi_nullable.include?(attr)
171
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
172
+ end
173
+
174
+ hash[param] = _to_hash(value)
175
+ end
176
+ hash
177
+ end
178
+
179
+ # Outputs non-array value in the form of hash
180
+ # For object, use to_hash. Otherwise, just return the value
181
+ # @param [Object] value Any valid value
182
+ # @return [Hash] Returns the value in the form of hash
183
+ def _to_hash(value)
184
+ if value.is_a?(Array)
185
+ value.compact.map { |v| _to_hash(v) }
186
+ elsif value.is_a?(Hash)
187
+ {}.tap do |hash|
188
+ value.each { |k, v| hash[k] = _to_hash(v) }
189
+ end
190
+ elsif value.respond_to? :to_hash
191
+ value.to_hash
192
+ else
193
+ value
194
+ end
195
+ end
196
+ end
197
+ end