moderation_api 1.2.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 (175) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +144 -0
  4. data/Rakefile +10 -0
  5. data/docs/AccountApi.md +74 -0
  6. data/docs/AccountGet200Response.md +26 -0
  7. data/docs/AccountGet200ResponseCurrentProject.md +20 -0
  8. data/docs/ActionsCreateRequest.md +36 -0
  9. data/docs/ActionsCreateRequestWebhooksInner.md +24 -0
  10. data/docs/ActionsDelete200Response.md +20 -0
  11. data/docs/ActionsExecute200Response.md +22 -0
  12. data/docs/ActionsExecuteDeprecatedRequest.md +22 -0
  13. data/docs/ActionsExecuteRequest.md +24 -0
  14. data/docs/ActionsGet200Response.md +40 -0
  15. data/docs/ActionsGet200ResponseWebhooksInner.md +26 -0
  16. data/docs/ActionsList200ResponseInner.md +38 -0
  17. data/docs/ActionsList200ResponseInnerPossibleValuesInner.md +18 -0
  18. data/docs/ActionsList400Response.md +22 -0
  19. data/docs/ActionsList400ResponseIssuesInner.md +18 -0
  20. data/docs/ActionsUpdateRequest.md +36 -0
  21. data/docs/ModerateApi.md +357 -0
  22. data/docs/ModerationAudioRequest.md +28 -0
  23. data/docs/ModerationImage200Response.md +28 -0
  24. data/docs/ModerationImage200ResponseLabelsInner.md +20 -0
  25. data/docs/ModerationImageRequest.md +28 -0
  26. data/docs/ModerationObject200Response.md +36 -0
  27. data/docs/ModerationObject200ResponseAllOfEntitiesInner.md +22 -0
  28. data/docs/ModerationObject200ResponseAllOfFieldsInner.md +22 -0
  29. data/docs/ModerationObject200ResponseAllOfLabelsInner.md +22 -0
  30. data/docs/ModerationObjectRequest.md +28 -0
  31. data/docs/ModerationObjectRequestValue.md +20 -0
  32. data/docs/ModerationObjectRequestValueDataValue.md +22 -0
  33. data/docs/ModerationText200Response.md +64 -0
  34. data/docs/ModerationText200ResponseAllOfAddress.md +28 -0
  35. data/docs/ModerationText200ResponseAllOfEmail.md +28 -0
  36. data/docs/ModerationText200ResponseAllOfName.md +28 -0
  37. data/docs/ModerationText200ResponseAllOfNsfw.md +26 -0
  38. data/docs/ModerationText200ResponseAllOfNsfwLabelScores.md +22 -0
  39. data/docs/ModerationText200ResponseAllOfPhone.md +28 -0
  40. data/docs/ModerationText200ResponseAllOfProfanity.md +28 -0
  41. data/docs/ModerationText200ResponseAllOfPropriety.md +26 -0
  42. data/docs/ModerationText200ResponseAllOfProprietyLabelScores.md +22 -0
  43. data/docs/ModerationText200ResponseAllOfQuality.md +26 -0
  44. data/docs/ModerationText200ResponseAllOfQualityLabelScores.md +24 -0
  45. data/docs/ModerationText200ResponseAllOfRequest.md +20 -0
  46. data/docs/ModerationText200ResponseAllOfSensitive.md +28 -0
  47. data/docs/ModerationText200ResponseAllOfSentiment.md +26 -0
  48. data/docs/ModerationText200ResponseAllOfSentimentLabelScores.md +22 -0
  49. data/docs/ModerationText200ResponseAllOfToxicity.md +26 -0
  50. data/docs/ModerationText200ResponseAllOfToxicityLabelScores.md +30 -0
  51. data/docs/ModerationText200ResponseAllOfUrl.md +28 -0
  52. data/docs/ModerationText200ResponseAllOfUsername.md +28 -0
  53. data/docs/ModerationText200ResponseAllOfWordlist.md +28 -0
  54. data/docs/ModerationText200ResponseAllOfWordlistsInner.md +36 -0
  55. data/docs/ModerationTextRequest.md +28 -0
  56. data/docs/ModerationVideo200Response.md +24 -0
  57. data/docs/ModerationVideoRequest.md +28 -0
  58. data/docs/QueueActionsApi.md +503 -0
  59. data/git_push.sh +57 -0
  60. data/lib/moderation_api/api/account_api.rb +79 -0
  61. data/lib/moderation_api/api/moderate_api.rb +362 -0
  62. data/lib/moderation_api/api/queue_actions_api.rb +492 -0
  63. data/lib/moderation_api/api_client.rb +437 -0
  64. data/lib/moderation_api/api_error.rb +58 -0
  65. data/lib/moderation_api/configuration.rb +392 -0
  66. data/lib/moderation_api/models/account_get200_response.rb +278 -0
  67. data/lib/moderation_api/models/account_get200_response_current_project.rb +237 -0
  68. data/lib/moderation_api/models/actions_create_request.rb +374 -0
  69. data/lib/moderation_api/models/actions_create_request_webhooks_inner.rb +260 -0
  70. data/lib/moderation_api/models/actions_delete200_response.rb +239 -0
  71. data/lib/moderation_api/models/actions_execute200_response.rb +258 -0
  72. data/lib/moderation_api/models/actions_execute_deprecated_request.rb +244 -0
  73. data/lib/moderation_api/models/actions_execute_request.rb +261 -0
  74. data/lib/moderation_api/models/actions_get200_response.rb +408 -0
  75. data/lib/moderation_api/models/actions_get200_response_webhooks_inner.rb +278 -0
  76. data/lib/moderation_api/models/actions_list200_response_inner.rb +396 -0
  77. data/lib/moderation_api/models/actions_list200_response_inner_possible_values_inner.rb +222 -0
  78. data/lib/moderation_api/models/actions_list400_response.rb +248 -0
  79. data/lib/moderation_api/models/actions_list400_response_issues_inner.rb +221 -0
  80. data/lib/moderation_api/models/actions_update_request.rb +367 -0
  81. data/lib/moderation_api/models/moderation_audio_request.rb +302 -0
  82. data/lib/moderation_api/models/moderation_image200_response.rb +296 -0
  83. data/lib/moderation_api/models/moderation_image200_response_labels_inner.rb +301 -0
  84. data/lib/moderation_api/models/moderation_image_request.rb +302 -0
  85. data/lib/moderation_api/models/moderation_object200_response.rb +368 -0
  86. data/lib/moderation_api/models/moderation_object200_response_all_of_entities_inner.rb +251 -0
  87. data/lib/moderation_api/models/moderation_object200_response_all_of_fields_inner.rb +258 -0
  88. data/lib/moderation_api/models/moderation_object200_response_all_of_labels_inner.rb +284 -0
  89. data/lib/moderation_api/models/moderation_object_request.rb +301 -0
  90. data/lib/moderation_api/models/moderation_object_request_value.rb +275 -0
  91. data/lib/moderation_api/models/moderation_object_request_value_data_value.rb +285 -0
  92. data/lib/moderation_api/models/moderation_text200_response.rb +488 -0
  93. data/lib/moderation_api/models/moderation_text200_response_all_of_address.rb +303 -0
  94. data/lib/moderation_api/models/moderation_text200_response_all_of_email.rb +303 -0
  95. data/lib/moderation_api/models/moderation_text200_response_all_of_name.rb +303 -0
  96. data/lib/moderation_api/models/moderation_text200_response_all_of_nsfw.rb +255 -0
  97. data/lib/moderation_api/models/moderation_text200_response_all_of_nsfw_label_scores.rb +235 -0
  98. data/lib/moderation_api/models/moderation_text200_response_all_of_phone.rb +303 -0
  99. data/lib/moderation_api/models/moderation_text200_response_all_of_profanity.rb +303 -0
  100. data/lib/moderation_api/models/moderation_text200_response_all_of_propriety.rb +255 -0
  101. data/lib/moderation_api/models/moderation_text200_response_all_of_propriety_label_scores.rb +235 -0
  102. data/lib/moderation_api/models/moderation_text200_response_all_of_quality.rb +255 -0
  103. data/lib/moderation_api/models/moderation_text200_response_all_of_quality_label_scores.rb +245 -0
  104. data/lib/moderation_api/models/moderation_text200_response_all_of_request.rb +240 -0
  105. data/lib/moderation_api/models/moderation_text200_response_all_of_sensitive.rb +303 -0
  106. data/lib/moderation_api/models/moderation_text200_response_all_of_sentiment.rb +255 -0
  107. data/lib/moderation_api/models/moderation_text200_response_all_of_sentiment_label_scores.rb +235 -0
  108. data/lib/moderation_api/models/moderation_text200_response_all_of_toxicity.rb +262 -0
  109. data/lib/moderation_api/models/moderation_text200_response_all_of_toxicity_label_scores.rb +275 -0
  110. data/lib/moderation_api/models/moderation_text200_response_all_of_url.rb +303 -0
  111. data/lib/moderation_api/models/moderation_text200_response_all_of_username.rb +303 -0
  112. data/lib/moderation_api/models/moderation_text200_response_all_of_wordlist.rb +303 -0
  113. data/lib/moderation_api/models/moderation_text200_response_all_of_wordlists_inner.rb +377 -0
  114. data/lib/moderation_api/models/moderation_text_request.rb +330 -0
  115. data/lib/moderation_api/models/moderation_video200_response.rb +265 -0
  116. data/lib/moderation_api/models/moderation_video_request.rb +302 -0
  117. data/lib/moderation_api/version.rb +15 -0
  118. data/lib/moderation_api.rb +93 -0
  119. data/moderation_api.gemspec +45 -0
  120. data/spec/api/account_api_spec.rb +46 -0
  121. data/spec/api/moderate_api_spec.rb +95 -0
  122. data/spec/api/queue_actions_api_spec.rb +121 -0
  123. data/spec/models/account_get200_response_current_project_spec.rb +42 -0
  124. data/spec/models/account_get200_response_spec.rb +60 -0
  125. data/spec/models/actions_create_request_spec.rb +98 -0
  126. data/spec/models/actions_create_request_webhooks_inner_spec.rb +54 -0
  127. data/spec/models/actions_delete200_response_spec.rb +42 -0
  128. data/spec/models/actions_execute200_response_spec.rb +48 -0
  129. data/spec/models/actions_execute_deprecated_request_spec.rb +48 -0
  130. data/spec/models/actions_execute_request_spec.rb +54 -0
  131. data/spec/models/actions_get200_response_spec.rb +110 -0
  132. data/spec/models/actions_get200_response_webhooks_inner_spec.rb +60 -0
  133. data/spec/models/actions_list200_response_inner_possible_values_inner_spec.rb +36 -0
  134. data/spec/models/actions_list200_response_inner_spec.rb +104 -0
  135. data/spec/models/actions_list400_response_issues_inner_spec.rb +36 -0
  136. data/spec/models/actions_list400_response_spec.rb +48 -0
  137. data/spec/models/actions_update_request_spec.rb +98 -0
  138. data/spec/models/moderation_audio_request_spec.rb +66 -0
  139. data/spec/models/moderation_image200_response_labels_inner_spec.rb +46 -0
  140. data/spec/models/moderation_image200_response_spec.rb +66 -0
  141. data/spec/models/moderation_image_request_spec.rb +66 -0
  142. data/spec/models/moderation_object200_response_all_of_entities_inner_spec.rb +48 -0
  143. data/spec/models/moderation_object200_response_all_of_fields_inner_spec.rb +48 -0
  144. data/spec/models/moderation_object200_response_all_of_labels_inner_spec.rb +48 -0
  145. data/spec/models/moderation_object200_response_spec.rb +90 -0
  146. data/spec/models/moderation_object_request_spec.rb +66 -0
  147. data/spec/models/moderation_object_request_value_data_value_spec.rb +52 -0
  148. data/spec/models/moderation_object_request_value_spec.rb +46 -0
  149. data/spec/models/moderation_text200_response_all_of_address_spec.rb +70 -0
  150. data/spec/models/moderation_text200_response_all_of_email_spec.rb +70 -0
  151. data/spec/models/moderation_text200_response_all_of_name_spec.rb +70 -0
  152. data/spec/models/moderation_text200_response_all_of_nsfw_label_scores_spec.rb +48 -0
  153. data/spec/models/moderation_text200_response_all_of_nsfw_spec.rb +60 -0
  154. data/spec/models/moderation_text200_response_all_of_phone_spec.rb +70 -0
  155. data/spec/models/moderation_text200_response_all_of_profanity_spec.rb +70 -0
  156. data/spec/models/moderation_text200_response_all_of_propriety_label_scores_spec.rb +48 -0
  157. data/spec/models/moderation_text200_response_all_of_propriety_spec.rb +60 -0
  158. data/spec/models/moderation_text200_response_all_of_quality_label_scores_spec.rb +54 -0
  159. data/spec/models/moderation_text200_response_all_of_quality_spec.rb +60 -0
  160. data/spec/models/moderation_text200_response_all_of_request_spec.rb +42 -0
  161. data/spec/models/moderation_text200_response_all_of_sensitive_spec.rb +70 -0
  162. data/spec/models/moderation_text200_response_all_of_sentiment_label_scores_spec.rb +48 -0
  163. data/spec/models/moderation_text200_response_all_of_sentiment_spec.rb +60 -0
  164. data/spec/models/moderation_text200_response_all_of_toxicity_label_scores_spec.rb +72 -0
  165. data/spec/models/moderation_text200_response_all_of_toxicity_spec.rb +60 -0
  166. data/spec/models/moderation_text200_response_all_of_url_spec.rb +70 -0
  167. data/spec/models/moderation_text200_response_all_of_username_spec.rb +70 -0
  168. data/spec/models/moderation_text200_response_all_of_wordlist_spec.rb +70 -0
  169. data/spec/models/moderation_text200_response_all_of_wordlists_inner_spec.rb +94 -0
  170. data/spec/models/moderation_text200_response_spec.rb +174 -0
  171. data/spec/models/moderation_text_request_spec.rb +66 -0
  172. data/spec/models/moderation_video200_response_spec.rb +54 -0
  173. data/spec/models/moderation_video_request_spec.rb +66 -0
  174. data/spec/spec_helper.rb +111 -0
  175. metadata +340 -0
@@ -0,0 +1,258 @@
1
+ =begin
2
+ #Moderation API
3
+
4
+ #API for automated content moderation
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.10.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module ModerationAPI
17
+ class ActionsExecute200Response
18
+ # Action executed successfully.
19
+ attr_accessor :success
20
+
21
+ # The ID of the action.
22
+ attr_accessor :action_id
23
+
24
+ # The IDs of the content items.
25
+ attr_accessor :ids
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'success' => :'success',
31
+ :'action_id' => :'actionId',
32
+ :'ids' => :'ids'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'success' => :'Boolean',
45
+ :'action_id' => :'String',
46
+ :'ids' => :'Array<String>'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `ModerationAPI::ActionsExecute200Response` initialize method"
61
+ end
62
+
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ attributes = attributes.each_with_object({}) { |(k, v), h|
65
+ if (!self.class.attribute_map.key?(k.to_sym))
66
+ fail ArgumentError, "`#{k}` is not a valid attribute in `ModerationAPI::ActionsExecute200Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
67
+ end
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:'success')
72
+ self.success = attributes[:'success']
73
+ else
74
+ self.success = nil
75
+ end
76
+
77
+ if attributes.key?(:'action_id')
78
+ self.action_id = attributes[:'action_id']
79
+ else
80
+ self.action_id = nil
81
+ end
82
+
83
+ if attributes.key?(:'ids')
84
+ if (value = attributes[:'ids']).is_a?(Array)
85
+ self.ids = value
86
+ end
87
+ else
88
+ self.ids = nil
89
+ end
90
+ end
91
+
92
+ # Show invalid properties with the reasons. Usually used together with valid?
93
+ # @return Array for valid properties with the reasons
94
+ def list_invalid_properties
95
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
96
+ invalid_properties = Array.new
97
+ if @success.nil?
98
+ invalid_properties.push('invalid value for "success", success cannot be nil.')
99
+ end
100
+
101
+ if @action_id.nil?
102
+ invalid_properties.push('invalid value for "action_id", action_id cannot be nil.')
103
+ end
104
+
105
+ if @ids.nil?
106
+ invalid_properties.push('invalid value for "ids", ids cannot be nil.')
107
+ end
108
+
109
+ invalid_properties
110
+ end
111
+
112
+ # Check to see if the all the properties in the model are valid
113
+ # @return true if the model is valid
114
+ def valid?
115
+ warn '[DEPRECATED] the `valid?` method is obsolete'
116
+ return false if @success.nil?
117
+ return false if @action_id.nil?
118
+ return false if @ids.nil?
119
+ true
120
+ end
121
+
122
+ # Checks equality by comparing each attribute.
123
+ # @param [Object] Object to be compared
124
+ def ==(o)
125
+ return true if self.equal?(o)
126
+ self.class == o.class &&
127
+ success == o.success &&
128
+ action_id == o.action_id &&
129
+ ids == o.ids
130
+ end
131
+
132
+ # @see the `==` method
133
+ # @param [Object] Object to be compared
134
+ def eql?(o)
135
+ self == o
136
+ end
137
+
138
+ # Calculates hash code according to all attributes.
139
+ # @return [Integer] Hash code
140
+ def hash
141
+ [success, action_id, ids].hash
142
+ end
143
+
144
+ # Builds the object from hash
145
+ # @param [Hash] attributes Model attributes in the form of hash
146
+ # @return [Object] Returns the model itself
147
+ def self.build_from_hash(attributes)
148
+ return nil unless attributes.is_a?(Hash)
149
+ attributes = attributes.transform_keys(&:to_sym)
150
+ transformed_hash = {}
151
+ openapi_types.each_pair do |key, type|
152
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
153
+ transformed_hash["#{key}"] = nil
154
+ elsif type =~ /\AArray<(.*)>/i
155
+ # check to ensure the input is an array given that the attribute
156
+ # is documented as an array but the input is not
157
+ if attributes[attribute_map[key]].is_a?(Array)
158
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
159
+ end
160
+ elsif !attributes[attribute_map[key]].nil?
161
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
162
+ end
163
+ end
164
+ new(transformed_hash)
165
+ end
166
+
167
+ # Deserializes the data based on type
168
+ # @param string type Data type
169
+ # @param string value Value to be deserialized
170
+ # @return [Object] Deserialized data
171
+ def self._deserialize(type, value)
172
+ case type.to_sym
173
+ when :Time
174
+ Time.parse(value)
175
+ when :Date
176
+ Date.parse(value)
177
+ when :String
178
+ value.to_s
179
+ when :Integer
180
+ value.to_i
181
+ when :Float
182
+ value.to_f
183
+ when :Boolean
184
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
185
+ true
186
+ else
187
+ false
188
+ end
189
+ when :Object
190
+ # generic object (usually a Hash), return directly
191
+ value
192
+ when /\AArray<(?<inner_type>.+)>\z/
193
+ inner_type = Regexp.last_match[:inner_type]
194
+ value.map { |v| _deserialize(inner_type, v) }
195
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
196
+ k_type = Regexp.last_match[:k_type]
197
+ v_type = Regexp.last_match[:v_type]
198
+ {}.tap do |hash|
199
+ value.each do |k, v|
200
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
201
+ end
202
+ end
203
+ else # model
204
+ # models (e.g. Pet) or oneOf
205
+ klass = ModerationAPI.const_get(type)
206
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
207
+ end
208
+ end
209
+
210
+ # Returns the string representation of the object
211
+ # @return [String] String presentation of the object
212
+ def to_s
213
+ to_hash.to_s
214
+ end
215
+
216
+ # to_body is an alias to to_hash (backward compatibility)
217
+ # @return [Hash] Returns the object in the form of hash
218
+ def to_body
219
+ to_hash
220
+ end
221
+
222
+ # Returns the object in the form of hash
223
+ # @return [Hash] Returns the object in the form of hash
224
+ def to_hash
225
+ hash = {}
226
+ self.class.attribute_map.each_pair do |attr, param|
227
+ value = self.send(attr)
228
+ if value.nil?
229
+ is_nullable = self.class.openapi_nullable.include?(attr)
230
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
231
+ end
232
+
233
+ hash[param] = _to_hash(value)
234
+ end
235
+ hash
236
+ end
237
+
238
+ # Outputs non-array value in the form of hash
239
+ # For object, use to_hash. Otherwise, just return the value
240
+ # @param [Object] value Any valid value
241
+ # @return [Hash] Returns the value in the form of hash
242
+ def _to_hash(value)
243
+ if value.is_a?(Array)
244
+ value.compact.map { |v| _to_hash(v) }
245
+ elsif value.is_a?(Hash)
246
+ {}.tap do |hash|
247
+ value.each { |k, v| hash[k] = _to_hash(v) }
248
+ end
249
+ elsif value.respond_to? :to_hash
250
+ value.to_hash
251
+ else
252
+ value
253
+ end
254
+ end
255
+
256
+ end
257
+
258
+ end
@@ -0,0 +1,244 @@
1
+ =begin
2
+ #Moderation API
3
+
4
+ #API for automated content moderation
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.10.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module ModerationAPI
17
+ class ActionsExecuteDeprecatedRequest
18
+ # The IDs of the content items to perform the action on.
19
+ attr_accessor :content_ids
20
+
21
+ # The ID of the queue the action was performed from if any.
22
+ attr_accessor :queue_id
23
+
24
+ # The value of the action. Useful to set a reason for the action etc.
25
+ attr_accessor :value
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'content_ids' => :'contentIds',
31
+ :'queue_id' => :'queueId',
32
+ :'value' => :'value'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'content_ids' => :'Array<String>',
45
+ :'queue_id' => :'String',
46
+ :'value' => :'String'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `ModerationAPI::ActionsExecuteDeprecatedRequest` initialize method"
61
+ end
62
+
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ attributes = attributes.each_with_object({}) { |(k, v), h|
65
+ if (!self.class.attribute_map.key?(k.to_sym))
66
+ fail ArgumentError, "`#{k}` is not a valid attribute in `ModerationAPI::ActionsExecuteDeprecatedRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
67
+ end
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:'content_ids')
72
+ if (value = attributes[:'content_ids']).is_a?(Array)
73
+ self.content_ids = value
74
+ end
75
+ else
76
+ self.content_ids = nil
77
+ end
78
+
79
+ if attributes.key?(:'queue_id')
80
+ self.queue_id = attributes[:'queue_id']
81
+ end
82
+
83
+ if attributes.key?(:'value')
84
+ self.value = attributes[:'value']
85
+ end
86
+ end
87
+
88
+ # Show invalid properties with the reasons. Usually used together with valid?
89
+ # @return Array for valid properties with the reasons
90
+ def list_invalid_properties
91
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
92
+ invalid_properties = Array.new
93
+ if @content_ids.nil?
94
+ invalid_properties.push('invalid value for "content_ids", content_ids cannot be nil.')
95
+ end
96
+
97
+ invalid_properties
98
+ end
99
+
100
+ # Check to see if the all the properties in the model are valid
101
+ # @return true if the model is valid
102
+ def valid?
103
+ warn '[DEPRECATED] the `valid?` method is obsolete'
104
+ return false if @content_ids.nil?
105
+ true
106
+ end
107
+
108
+ # Checks equality by comparing each attribute.
109
+ # @param [Object] Object to be compared
110
+ def ==(o)
111
+ return true if self.equal?(o)
112
+ self.class == o.class &&
113
+ content_ids == o.content_ids &&
114
+ queue_id == o.queue_id &&
115
+ value == o.value
116
+ end
117
+
118
+ # @see the `==` method
119
+ # @param [Object] Object to be compared
120
+ def eql?(o)
121
+ self == o
122
+ end
123
+
124
+ # Calculates hash code according to all attributes.
125
+ # @return [Integer] Hash code
126
+ def hash
127
+ [content_ids, queue_id, value].hash
128
+ end
129
+
130
+ # Builds the object from hash
131
+ # @param [Hash] attributes Model attributes in the form of hash
132
+ # @return [Object] Returns the model itself
133
+ def self.build_from_hash(attributes)
134
+ return nil unless attributes.is_a?(Hash)
135
+ attributes = attributes.transform_keys(&:to_sym)
136
+ transformed_hash = {}
137
+ openapi_types.each_pair do |key, type|
138
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
139
+ transformed_hash["#{key}"] = nil
140
+ elsif type =~ /\AArray<(.*)>/i
141
+ # check to ensure the input is an array given that the attribute
142
+ # is documented as an array but the input is not
143
+ if attributes[attribute_map[key]].is_a?(Array)
144
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
145
+ end
146
+ elsif !attributes[attribute_map[key]].nil?
147
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
148
+ end
149
+ end
150
+ new(transformed_hash)
151
+ end
152
+
153
+ # Deserializes the data based on type
154
+ # @param string type Data type
155
+ # @param string value Value to be deserialized
156
+ # @return [Object] Deserialized data
157
+ def self._deserialize(type, value)
158
+ case type.to_sym
159
+ when :Time
160
+ Time.parse(value)
161
+ when :Date
162
+ Date.parse(value)
163
+ when :String
164
+ value.to_s
165
+ when :Integer
166
+ value.to_i
167
+ when :Float
168
+ value.to_f
169
+ when :Boolean
170
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
171
+ true
172
+ else
173
+ false
174
+ end
175
+ when :Object
176
+ # generic object (usually a Hash), return directly
177
+ value
178
+ when /\AArray<(?<inner_type>.+)>\z/
179
+ inner_type = Regexp.last_match[:inner_type]
180
+ value.map { |v| _deserialize(inner_type, v) }
181
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
182
+ k_type = Regexp.last_match[:k_type]
183
+ v_type = Regexp.last_match[:v_type]
184
+ {}.tap do |hash|
185
+ value.each do |k, v|
186
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
187
+ end
188
+ end
189
+ else # model
190
+ # models (e.g. Pet) or oneOf
191
+ klass = ModerationAPI.const_get(type)
192
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
193
+ end
194
+ end
195
+
196
+ # Returns the string representation of the object
197
+ # @return [String] String presentation of the object
198
+ def to_s
199
+ to_hash.to_s
200
+ end
201
+
202
+ # to_body is an alias to to_hash (backward compatibility)
203
+ # @return [Hash] Returns the object in the form of hash
204
+ def to_body
205
+ to_hash
206
+ end
207
+
208
+ # Returns the object in the form of hash
209
+ # @return [Hash] Returns the object in the form of hash
210
+ def to_hash
211
+ hash = {}
212
+ self.class.attribute_map.each_pair do |attr, param|
213
+ value = self.send(attr)
214
+ if value.nil?
215
+ is_nullable = self.class.openapi_nullable.include?(attr)
216
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
217
+ end
218
+
219
+ hash[param] = _to_hash(value)
220
+ end
221
+ hash
222
+ end
223
+
224
+ # Outputs non-array value in the form of hash
225
+ # For object, use to_hash. Otherwise, just return the value
226
+ # @param [Object] value Any valid value
227
+ # @return [Hash] Returns the value in the form of hash
228
+ def _to_hash(value)
229
+ if value.is_a?(Array)
230
+ value.compact.map { |v| _to_hash(v) }
231
+ elsif value.is_a?(Hash)
232
+ {}.tap do |hash|
233
+ value.each { |k, v| hash[k] = _to_hash(v) }
234
+ end
235
+ elsif value.respond_to? :to_hash
236
+ value.to_hash
237
+ else
238
+ value
239
+ end
240
+ end
241
+
242
+ end
243
+
244
+ end