phrase 4.25.0 → 4.27.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 (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -0
  3. data/README.md +26 -4
  4. data/docs/AutomationEvent.md +33 -0
  5. data/docs/AutomationEventProject.md +19 -0
  6. data/docs/AutomationEventsApi.md +168 -0
  7. data/docs/AutomationsCreateParameters.md +1 -1
  8. data/docs/AutomationsCreateParameters1.md +1 -1
  9. data/docs/CheckIssue.md +33 -0
  10. data/docs/ChecksApi.md +146 -0
  11. data/docs/DocumentsApi.md +4 -4
  12. data/docs/ICUApi.md +1 -1
  13. data/docs/IcuSkeletonError.md +17 -0
  14. data/docs/IcuSkeletonParameters.md +11 -11
  15. data/docs/JobCreateParameters.md +1 -1
  16. data/docs/JobsApi.md +2 -2
  17. data/docs/KeyCreateParameters.md +1 -1
  18. data/docs/KeyFormatAnnotationsApi.md +74 -0
  19. data/docs/KeyFormatAnnotationsList200ResponseInner.md +19 -0
  20. data/docs/KeyLinksBatchDestroyParameters.md +6 -4
  21. data/docs/KeyLinksCreateParameters.md +2 -2
  22. data/docs/KeyUpdateParameters.md +1 -1
  23. data/docs/LinkedKeysApi.md +14 -13
  24. data/docs/Locale.md +6 -0
  25. data/docs/LocaleCreateParameters.md +2 -0
  26. data/docs/LocaleDetails.md +6 -0
  27. data/docs/LocaleUpdateParameters.md +2 -0
  28. data/docs/MachineTranslationApi.md +263 -0
  29. data/docs/MachineTranslationLocaleProviderMapping.md +21 -0
  30. data/docs/MachineTranslationLocaleProviderMappingsCreateParameters.md +21 -0
  31. data/docs/MachineTranslationSettings.md +23 -0
  32. data/docs/MachineTranslationSettingsUpdateParameters.md +17 -0
  33. data/docs/PreTranslation.md +29 -0
  34. data/docs/PreTranslationCreateParameters.md +19 -0
  35. data/docs/PreTranslationsApi.md +210 -0
  36. data/docs/ProjectCreateParameters.md +8 -2
  37. data/docs/ProjectDetails.md +3 -1
  38. data/docs/ProjectUpdateParameters.md +8 -2
  39. data/docs/ScreenshotUpdateParameters.md +1 -1
  40. data/docs/ScreenshotsApi.md +2 -2
  41. data/docs/Upload.md +3 -1
  42. data/docs/UploadsApi.md +4 -4
  43. data/lib/phrase/api/automation_events_api.rb +215 -0
  44. data/lib/phrase/api/checks_api.rb +174 -0
  45. data/lib/phrase/api/documents_api.rb +6 -6
  46. data/lib/phrase/api/icu_api.rb +2 -6
  47. data/lib/phrase/api/key_format_annotations_api.rb +85 -0
  48. data/lib/phrase/api/linked_keys_api.rb +19 -23
  49. data/lib/phrase/api/machine_translation_api.rb +302 -0
  50. data/lib/phrase/api/pre_translations_api.rb +240 -0
  51. data/lib/phrase/api/screenshots_api.rb +4 -4
  52. data/lib/phrase/api/uploads_api.rb +6 -6
  53. data/lib/phrase/models/automation_event.rb +325 -0
  54. data/lib/phrase/models/automation_event_project.rb +208 -0
  55. data/lib/phrase/models/automations_create_parameters.rb +1 -1
  56. data/lib/phrase/models/automations_create_parameters1.rb +1 -1
  57. data/lib/phrase/models/check_issue.rb +319 -0
  58. data/lib/phrase/models/{key_links_index400_response.rb → icu_skeleton_error.rb} +11 -10
  59. data/lib/phrase/models/icu_skeleton_parameters.rb +6 -6
  60. data/lib/phrase/models/job_create_parameters.rb +1 -1
  61. data/lib/phrase/models/key_format_annotations_list200_response_inner.rb +207 -0
  62. data/lib/phrase/models/key_links_batch_destroy_parameters.rb +52 -6
  63. data/lib/phrase/models/key_links_create_parameters.rb +1 -1
  64. data/lib/phrase/models/locale.rb +31 -1
  65. data/lib/phrase/models/locale_create_parameters.rb +11 -1
  66. data/lib/phrase/models/locale_details.rb +31 -1
  67. data/lib/phrase/models/locale_update_parameters.rb +11 -1
  68. data/lib/phrase/models/machine_translation_locale_provider_mapping.rb +217 -0
  69. data/lib/phrase/models/machine_translation_locale_provider_mappings_create_parameters.rb +232 -0
  70. data/lib/phrase/models/machine_translation_settings.rb +230 -0
  71. data/lib/phrase/models/machine_translation_settings_update_parameters.rb +198 -0
  72. data/lib/phrase/models/pre_translation.rb +301 -0
  73. data/lib/phrase/models/pre_translation_create_parameters.rb +241 -0
  74. data/lib/phrase/models/project_create_parameters.rb +35 -1
  75. data/lib/phrase/models/project_details.rb +10 -1
  76. data/lib/phrase/models/project_update_parameters.rb +35 -1
  77. data/lib/phrase/models/upload.rb +13 -1
  78. data/lib/phrase/response.rb +2 -2
  79. data/lib/phrase/version.rb +1 -1
  80. data/lib/phrase.rb +16 -1
  81. data/phrase.gemspec +1 -1
  82. data/spec/api/automation_events_api_spec.rb +67 -0
  83. data/spec/api/checks_api_spec.rb +56 -0
  84. data/spec/api/documents_api_spec.rb +3 -3
  85. data/spec/api/icu_api_spec.rb +1 -1
  86. data/spec/api/key_format_annotations_api_spec.rb +38 -0
  87. data/spec/api/linked_keys_api_spec.rb +7 -7
  88. data/spec/api/machine_translation_api_spec.rb +79 -0
  89. data/spec/api/pre_translations_api_spec.rb +70 -0
  90. data/spec/api/screenshots_api_spec.rb +2 -2
  91. data/spec/models/automation_event_project_spec.rb +35 -0
  92. data/spec/models/automation_event_spec.rb +85 -0
  93. data/spec/models/check_issue_spec.rb +85 -0
  94. data/spec/models/{key_links_index400_response_spec.rb → icu_skeleton_error_spec.rb} +7 -7
  95. data/spec/models/key_format_annotations_list200_response_inner_spec.rb +35 -0
  96. data/spec/models/key_links_batch_destroy_parameters_spec.rb +10 -0
  97. data/spec/models/locale_create_parameters_spec.rb +6 -0
  98. data/spec/models/locale_details_spec.rb +18 -0
  99. data/spec/models/locale_spec.rb +18 -0
  100. data/spec/models/locale_update_parameters_spec.rb +6 -0
  101. data/spec/models/machine_translation_locale_provider_mapping_spec.rb +41 -0
  102. data/spec/models/machine_translation_locale_provider_mappings_create_parameters_spec.rb +41 -0
  103. data/spec/models/machine_translation_settings_spec.rb +47 -0
  104. data/spec/models/machine_translation_settings_update_parameters_spec.rb +29 -0
  105. data/spec/models/pre_translation_create_parameters_spec.rb +39 -0
  106. data/spec/models/pre_translation_spec.rb +73 -0
  107. data/spec/models/project_create_parameters_spec.rb +18 -0
  108. data/spec/models/project_details_spec.rb +6 -0
  109. data/spec/models/project_update_parameters_spec.rb +18 -0
  110. data/spec/models/upload_spec.rb +6 -0
  111. data/spec/response_spec.rb +53 -0
  112. metadata +313 -251
  113. data/docs/KeyLinksIndex400Response.md +0 -17
@@ -0,0 +1,198 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class MachineTranslationSettingsUpdateParameters
5
+ # The machine translation engine to use as the account default. Supported values: language_ai_translate, aita_translate, microsoft_translate, google_translate, amazon_translate, intento_translate, gpt_translate. Pass null or an empty string to reset to the plan default.
6
+ attr_accessor :default_service
7
+
8
+ # Attribute mapping from ruby-style variable name to JSON key.
9
+ def self.attribute_map
10
+ {
11
+ :'default_service' => :'default_service'
12
+ }
13
+ end
14
+
15
+ # Attribute type mapping.
16
+ def self.openapi_types
17
+ {
18
+ :'default_service' => :'String'
19
+ }
20
+ end
21
+
22
+ # List of attributes with nullable: true
23
+ def self.openapi_nullable
24
+ Set.new([
25
+ :'default_service'
26
+ ])
27
+ end
28
+
29
+ # Initializes the object
30
+ # @param [Hash] attributes Model attributes in the form of hash
31
+ def initialize(attributes = {})
32
+ if (!attributes.is_a?(Hash))
33
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::MachineTranslationSettingsUpdateParameters` initialize method"
34
+ end
35
+
36
+ # check to see if the attribute exists and convert string to symbol for hash key
37
+ attributes = attributes.each_with_object({}) { |(k, v), h|
38
+ if (!self.class.attribute_map.key?(k.to_sym))
39
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::MachineTranslationSettingsUpdateParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
40
+ end
41
+ h[k.to_sym] = v
42
+ }
43
+
44
+ if attributes.key?(:'default_service')
45
+ self.default_service = attributes[:'default_service']
46
+ end
47
+ end
48
+
49
+ # Show invalid properties with the reasons. Usually used together with valid?
50
+ # @return Array for valid properties with the reasons
51
+ def list_invalid_properties
52
+ invalid_properties = Array.new
53
+ invalid_properties
54
+ end
55
+
56
+ # Check to see if the all the properties in the model are valid
57
+ # @return true if the model is valid
58
+ def valid?
59
+ true
60
+ end
61
+
62
+ # Checks equality by comparing each attribute.
63
+ # @param [Object] Object to be compared
64
+ def ==(o)
65
+ return true if self.equal?(o)
66
+ self.class == o.class &&
67
+ default_service == o.default_service
68
+ end
69
+
70
+ # @see the `==` method
71
+ # @param [Object] Object to be compared
72
+ def eql?(o)
73
+ self == o
74
+ end
75
+
76
+ # Calculates hash code according to all attributes.
77
+ # @return [Integer] Hash code
78
+ def hash
79
+ [default_service].hash
80
+ end
81
+
82
+ # Builds the object from hash
83
+ # @param [Hash] attributes Model attributes in the form of hash
84
+ # @return [Object] Returns the model itself
85
+ def self.build_from_hash(attributes)
86
+ new.build_from_hash(attributes)
87
+ end
88
+
89
+ # Builds the object from hash
90
+ # @param [Hash] attributes Model attributes in the form of hash
91
+ # @return [Object] Returns the model itself
92
+ def build_from_hash(attributes)
93
+ return nil unless attributes.is_a?(Hash)
94
+ self.class.openapi_types.each_pair do |key, type|
95
+ if type =~ /\AArray<(.*)>/i
96
+ # check to ensure the input is an array given that the attribute
97
+ # is documented as an array but the input is not
98
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
99
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
100
+ end
101
+ elsif !attributes[self.class.attribute_map[key]].nil?
102
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
103
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
104
+ end
105
+
106
+ self
107
+ end
108
+
109
+ # Deserializes the data based on type
110
+ # @param string type Data type
111
+ # @param string value Value to be deserialized
112
+ # @return [Object] Deserialized data
113
+ def _deserialize(type, value)
114
+ case type.to_sym
115
+ when :DateTime
116
+ DateTime.parse(value)
117
+ when :Date
118
+ Date.parse(value)
119
+ when :Time
120
+ Time.parse(value)
121
+ when :String
122
+ value.to_s
123
+ when :Integer
124
+ value.to_i
125
+ when :Float
126
+ value.to_f
127
+ when :Boolean
128
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
129
+ true
130
+ else
131
+ false
132
+ end
133
+ when :Object
134
+ # generic object (usually a Hash), return directly
135
+ value
136
+ when /\AArray<(?<inner_type>.+)>\z/
137
+ inner_type = Regexp.last_match[:inner_type]
138
+ value.map { |v| _deserialize(inner_type, v) }
139
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
140
+ k_type = Regexp.last_match[:k_type]
141
+ v_type = Regexp.last_match[:v_type]
142
+ {}.tap do |hash|
143
+ value.each do |k, v|
144
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
145
+ end
146
+ end
147
+ else # model
148
+ Phrase.const_get(type).build_from_hash(value)
149
+ end
150
+ end
151
+
152
+ # Returns the string representation of the object
153
+ # @return [String] String presentation of the object
154
+ def to_s
155
+ to_hash.to_s
156
+ end
157
+
158
+ # to_body is an alias to to_hash (backward compatibility)
159
+ # @return [Hash] Returns the object in the form of hash
160
+ def to_body
161
+ to_hash
162
+ end
163
+
164
+ # Returns the object in the form of hash
165
+ # @return [Hash] Returns the object in the form of hash
166
+ def to_hash
167
+ hash = {}
168
+ self.class.attribute_map.each_pair do |attr, param|
169
+ value = self.send(attr)
170
+ if value.nil?
171
+ is_nullable = self.class.openapi_nullable.include?(attr)
172
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
173
+ end
174
+
175
+ hash[param] = _to_hash(value)
176
+ end
177
+ hash
178
+ end
179
+
180
+ # Outputs non-array value in the form of hash
181
+ # For object, use to_hash. Otherwise, just return the value
182
+ # @param [Object] value Any valid value
183
+ # @return [Hash] Returns the value in the form of hash
184
+ def _to_hash(value)
185
+ if value.is_a?(Array)
186
+ value.compact.map { |v| _to_hash(v) }
187
+ elsif value.is_a?(Hash)
188
+ {}.tap do |hash|
189
+ value.each { |k, v| hash[k] = _to_hash(v) }
190
+ end
191
+ elsif value.respond_to? :to_hash
192
+ value.to_hash
193
+ else
194
+ value
195
+ end
196
+ end
197
+ end
198
+ end
@@ -0,0 +1,301 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class PreTranslation
5
+ attr_accessor :id
6
+
7
+ # Current execution state of the pre-translation job. Jobs start as `pending` while queued, transition to `running` while executing, and settle to `success` or `error`.
8
+ attr_accessor :status
9
+
10
+ # Resource type that was pre-translated.
11
+ attr_accessor :translatable_type
12
+
13
+ # ID of the targeted resource (locale ID, job ID, key ID, or upload ID).
14
+ attr_accessor :translatable_id
15
+
16
+ # Error message. `null` unless the job's status is `error`.
17
+ attr_accessor :error
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
+ :'status' => :'status',
50
+ :'translatable_type' => :'translatable_type',
51
+ :'translatable_id' => :'translatable_id',
52
+ :'error' => :'error',
53
+ :'created_at' => :'created_at',
54
+ :'updated_at' => :'updated_at'
55
+ }
56
+ end
57
+
58
+ # Attribute type mapping.
59
+ def self.openapi_types
60
+ {
61
+ :'id' => :'String',
62
+ :'status' => :'String',
63
+ :'translatable_type' => :'String',
64
+ :'translatable_id' => :'String',
65
+ :'error' => :'String',
66
+ :'created_at' => :'DateTime',
67
+ :'updated_at' => :'DateTime'
68
+ }
69
+ end
70
+
71
+ # List of attributes with nullable: true
72
+ def self.openapi_nullable
73
+ Set.new([
74
+ :'error',
75
+ ])
76
+ end
77
+
78
+ # Initializes the object
79
+ # @param [Hash] attributes Model attributes in the form of hash
80
+ def initialize(attributes = {})
81
+ if (!attributes.is_a?(Hash))
82
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::PreTranslation` initialize method"
83
+ end
84
+
85
+ # check to see if the attribute exists and convert string to symbol for hash key
86
+ attributes = attributes.each_with_object({}) { |(k, v), h|
87
+ if (!self.class.attribute_map.key?(k.to_sym))
88
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::PreTranslation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
89
+ end
90
+ h[k.to_sym] = v
91
+ }
92
+
93
+ if attributes.key?(:'id')
94
+ self.id = attributes[:'id']
95
+ end
96
+
97
+ if attributes.key?(:'status')
98
+ self.status = attributes[:'status']
99
+ end
100
+
101
+ if attributes.key?(:'translatable_type')
102
+ self.translatable_type = attributes[:'translatable_type']
103
+ end
104
+
105
+ if attributes.key?(:'translatable_id')
106
+ self.translatable_id = attributes[:'translatable_id']
107
+ end
108
+
109
+ if attributes.key?(:'error')
110
+ self.error = attributes[:'error']
111
+ end
112
+
113
+ if attributes.key?(:'created_at')
114
+ self.created_at = attributes[:'created_at']
115
+ end
116
+
117
+ if attributes.key?(:'updated_at')
118
+ self.updated_at = attributes[:'updated_at']
119
+ end
120
+ end
121
+
122
+ # Show invalid properties with the reasons. Usually used together with valid?
123
+ # @return Array for valid properties with the reasons
124
+ def list_invalid_properties
125
+ invalid_properties = Array.new
126
+ invalid_properties
127
+ end
128
+
129
+ # Check to see if the all the properties in the model are valid
130
+ # @return true if the model is valid
131
+ def valid?
132
+ status_validator = EnumAttributeValidator.new('String', ["pending", "running", "success", "error"])
133
+ return false unless status_validator.valid?(@status)
134
+ translatable_type_validator = EnumAttributeValidator.new('String', ["locale", "job", "translation_key", "upload"])
135
+ return false unless translatable_type_validator.valid?(@translatable_type)
136
+ true
137
+ end
138
+
139
+ # Custom attribute writer method checking allowed values (enum).
140
+ # @param [Object] status Object to be assigned
141
+ def status=(status)
142
+ validator = EnumAttributeValidator.new('String', ["pending", "running", "success", "error"])
143
+ unless validator.valid?(status)
144
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
145
+ end
146
+ @status = status
147
+ end
148
+
149
+ # Custom attribute writer method checking allowed values (enum).
150
+ # @param [Object] translatable_type Object to be assigned
151
+ def translatable_type=(translatable_type)
152
+ validator = EnumAttributeValidator.new('String', ["locale", "job", "translation_key", "upload"])
153
+ unless validator.valid?(translatable_type)
154
+ fail ArgumentError, "invalid value for \"translatable_type\", must be one of #{validator.allowable_values}."
155
+ end
156
+ @translatable_type = translatable_type
157
+ end
158
+
159
+ # Checks equality by comparing each attribute.
160
+ # @param [Object] Object to be compared
161
+ def ==(o)
162
+ return true if self.equal?(o)
163
+ self.class == o.class &&
164
+ id == o.id &&
165
+ status == o.status &&
166
+ translatable_type == o.translatable_type &&
167
+ translatable_id == o.translatable_id &&
168
+ error == o.error &&
169
+ created_at == o.created_at &&
170
+ updated_at == o.updated_at
171
+ end
172
+
173
+ # @see the `==` method
174
+ # @param [Object] Object to be compared
175
+ def eql?(o)
176
+ self == o
177
+ end
178
+
179
+ # Calculates hash code according to all attributes.
180
+ # @return [Integer] Hash code
181
+ def hash
182
+ [id, status, translatable_type, translatable_id, error, created_at, updated_at].hash
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 self.build_from_hash(attributes)
189
+ new.build_from_hash(attributes)
190
+ end
191
+
192
+ # Builds the object from hash
193
+ # @param [Hash] attributes Model attributes in the form of hash
194
+ # @return [Object] Returns the model itself
195
+ def build_from_hash(attributes)
196
+ return nil unless attributes.is_a?(Hash)
197
+ self.class.openapi_types.each_pair do |key, type|
198
+ if type =~ /\AArray<(.*)>/i
199
+ # check to ensure the input is an array given that the attribute
200
+ # is documented as an array but the input is not
201
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
202
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
203
+ end
204
+ elsif !attributes[self.class.attribute_map[key]].nil?
205
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
206
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
207
+ end
208
+
209
+ self
210
+ end
211
+
212
+ # Deserializes the data based on type
213
+ # @param string type Data type
214
+ # @param string value Value to be deserialized
215
+ # @return [Object] Deserialized data
216
+ def _deserialize(type, value)
217
+ case type.to_sym
218
+ when :DateTime
219
+ DateTime.parse(value)
220
+ when :Date
221
+ Date.parse(value)
222
+ when :Time
223
+ Time.parse(value)
224
+ when :String
225
+ value.to_s
226
+ when :Integer
227
+ value.to_i
228
+ when :Float
229
+ value.to_f
230
+ when :Boolean
231
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
232
+ true
233
+ else
234
+ false
235
+ end
236
+ when :Object
237
+ # generic object (usually a Hash), return directly
238
+ value
239
+ when /\AArray<(?<inner_type>.+)>\z/
240
+ inner_type = Regexp.last_match[:inner_type]
241
+ value.map { |v| _deserialize(inner_type, v) }
242
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
243
+ k_type = Regexp.last_match[:k_type]
244
+ v_type = Regexp.last_match[:v_type]
245
+ {}.tap do |hash|
246
+ value.each do |k, v|
247
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
248
+ end
249
+ end
250
+ else # model
251
+ Phrase.const_get(type).build_from_hash(value)
252
+ end
253
+ end
254
+
255
+ # Returns the string representation of the object
256
+ # @return [String] String presentation of the object
257
+ def to_s
258
+ to_hash.to_s
259
+ end
260
+
261
+ # to_body is an alias to to_hash (backward compatibility)
262
+ # @return [Hash] Returns the object in the form of hash
263
+ def to_body
264
+ to_hash
265
+ end
266
+
267
+ # Returns the object in the form of hash
268
+ # @return [Hash] Returns the object in the form of hash
269
+ def to_hash
270
+ hash = {}
271
+ self.class.attribute_map.each_pair do |attr, param|
272
+ value = self.send(attr)
273
+ if value.nil?
274
+ is_nullable = self.class.openapi_nullable.include?(attr)
275
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
276
+ end
277
+
278
+ hash[param] = _to_hash(value)
279
+ end
280
+ hash
281
+ end
282
+
283
+ # Outputs non-array value in the form of hash
284
+ # For object, use to_hash. Otherwise, just return the value
285
+ # @param [Object] value Any valid value
286
+ # @return [Hash] Returns the value in the form of hash
287
+ def _to_hash(value)
288
+ if value.is_a?(Array)
289
+ value.compact.map { |v| _to_hash(v) }
290
+ elsif value.is_a?(Hash)
291
+ {}.tap do |hash|
292
+ value.each { |k, v| hash[k] = _to_hash(v) }
293
+ end
294
+ elsif value.respond_to? :to_hash
295
+ value.to_hash
296
+ else
297
+ value
298
+ end
299
+ end
300
+ end
301
+ end