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,377 @@
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 ModerationText200ResponseAllOfWordlistsInner
18
+ # The flagging mode.
19
+ attr_accessor :mode
20
+
21
+ # Whether the wordlists flagged the content.
22
+ attr_accessor :flagged
23
+
24
+ # The name of the wordlist
25
+ attr_accessor :name
26
+
27
+ # The ID of the wordlist
28
+ attr_accessor :id
29
+
30
+ # The score of the wordlist
31
+ attr_accessor :score
32
+
33
+ # Whether a match was found or not.
34
+ attr_accessor :found
35
+
36
+ # The matches of the entity matcher.
37
+ attr_accessor :matches
38
+
39
+ # The components of the matcher.
40
+ attr_accessor :components
41
+
42
+ # Indicates an error with the matcher.
43
+ attr_accessor :error
44
+
45
+ # Indicates a warning from the model, e.g. if the text is too short or long and the model might not be accurate.
46
+ attr_accessor :warning
47
+
48
+ class EnumAttributeValidator
49
+ attr_reader :datatype
50
+ attr_reader :allowable_values
51
+
52
+ def initialize(datatype, allowable_values)
53
+ @allowable_values = allowable_values.map do |value|
54
+ case datatype.to_s
55
+ when /Integer/i
56
+ value.to_i
57
+ when /Float/i
58
+ value.to_f
59
+ else
60
+ value
61
+ end
62
+ end
63
+ end
64
+
65
+ def valid?(value)
66
+ !value || allowable_values.include?(value)
67
+ end
68
+ end
69
+
70
+ # Attribute mapping from ruby-style variable name to JSON key.
71
+ def self.attribute_map
72
+ {
73
+ :'mode' => :'mode',
74
+ :'flagged' => :'flagged',
75
+ :'name' => :'name',
76
+ :'id' => :'id',
77
+ :'score' => :'score',
78
+ :'found' => :'found',
79
+ :'matches' => :'matches',
80
+ :'components' => :'components',
81
+ :'error' => :'error',
82
+ :'warning' => :'warning'
83
+ }
84
+ end
85
+
86
+ # Returns all the JSON keys this model knows about
87
+ def self.acceptable_attributes
88
+ attribute_map.values
89
+ end
90
+
91
+ # Attribute type mapping.
92
+ def self.openapi_types
93
+ {
94
+ :'mode' => :'String',
95
+ :'flagged' => :'Boolean',
96
+ :'name' => :'String',
97
+ :'id' => :'String',
98
+ :'score' => :'Float',
99
+ :'found' => :'Boolean',
100
+ :'matches' => :'Array<String>',
101
+ :'components' => :'Object',
102
+ :'error' => :'String',
103
+ :'warning' => :'String'
104
+ }
105
+ end
106
+
107
+ # List of attributes with nullable: true
108
+ def self.openapi_nullable
109
+ Set.new([
110
+ :'components',
111
+ ])
112
+ end
113
+
114
+ # Initializes the object
115
+ # @param [Hash] attributes Model attributes in the form of hash
116
+ def initialize(attributes = {})
117
+ if (!attributes.is_a?(Hash))
118
+ fail ArgumentError, "The input argument (attributes) must be a hash in `ModerationAPI::ModerationText200ResponseAllOfWordlistsInner` initialize method"
119
+ end
120
+
121
+ # check to see if the attribute exists and convert string to symbol for hash key
122
+ attributes = attributes.each_with_object({}) { |(k, v), h|
123
+ if (!self.class.attribute_map.key?(k.to_sym))
124
+ fail ArgumentError, "`#{k}` is not a valid attribute in `ModerationAPI::ModerationText200ResponseAllOfWordlistsInner`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
125
+ end
126
+ h[k.to_sym] = v
127
+ }
128
+
129
+ if attributes.key?(:'mode')
130
+ self.mode = attributes[:'mode']
131
+ else
132
+ self.mode = nil
133
+ end
134
+
135
+ if attributes.key?(:'flagged')
136
+ self.flagged = attributes[:'flagged']
137
+ else
138
+ self.flagged = nil
139
+ end
140
+
141
+ if attributes.key?(:'name')
142
+ self.name = attributes[:'name']
143
+ else
144
+ self.name = nil
145
+ end
146
+
147
+ if attributes.key?(:'id')
148
+ self.id = attributes[:'id']
149
+ else
150
+ self.id = nil
151
+ end
152
+
153
+ if attributes.key?(:'score')
154
+ self.score = attributes[:'score']
155
+ else
156
+ self.score = nil
157
+ end
158
+
159
+ if attributes.key?(:'found')
160
+ self.found = attributes[:'found']
161
+ end
162
+
163
+ if attributes.key?(:'matches')
164
+ if (value = attributes[:'matches']).is_a?(Array)
165
+ self.matches = value
166
+ end
167
+ end
168
+
169
+ if attributes.key?(:'components')
170
+ self.components = attributes[:'components']
171
+ end
172
+
173
+ if attributes.key?(:'error')
174
+ self.error = attributes[:'error']
175
+ end
176
+
177
+ if attributes.key?(:'warning')
178
+ self.warning = attributes[:'warning']
179
+ end
180
+ end
181
+
182
+ # Show invalid properties with the reasons. Usually used together with valid?
183
+ # @return Array for valid properties with the reasons
184
+ def list_invalid_properties
185
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
186
+ invalid_properties = Array.new
187
+ if @mode.nil?
188
+ invalid_properties.push('invalid value for "mode", mode cannot be nil.')
189
+ end
190
+
191
+ if @flagged.nil?
192
+ invalid_properties.push('invalid value for "flagged", flagged cannot be nil.')
193
+ end
194
+
195
+ if @name.nil?
196
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
197
+ end
198
+
199
+ if @id.nil?
200
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
201
+ end
202
+
203
+ if @score.nil?
204
+ invalid_properties.push('invalid value for "score", score cannot be nil.')
205
+ end
206
+
207
+ invalid_properties
208
+ end
209
+
210
+ # Check to see if the all the properties in the model are valid
211
+ # @return true if the model is valid
212
+ def valid?
213
+ warn '[DEPRECATED] the `valid?` method is obsolete'
214
+ return false if @mode.nil?
215
+ mode_validator = EnumAttributeValidator.new('String', ["BLOCKLIST", "ALLOWLIST", "PASS", "unknown_default_open_api"])
216
+ return false unless mode_validator.valid?(@mode)
217
+ return false if @flagged.nil?
218
+ return false if @name.nil?
219
+ return false if @id.nil?
220
+ return false if @score.nil?
221
+ true
222
+ end
223
+
224
+ # Custom attribute writer method checking allowed values (enum).
225
+ # @param [Object] mode Object to be assigned
226
+ def mode=(mode)
227
+ validator = EnumAttributeValidator.new('String', ["BLOCKLIST", "ALLOWLIST", "PASS", "unknown_default_open_api"])
228
+ unless validator.valid?(mode)
229
+ fail ArgumentError, "invalid value for \"mode\", must be one of #{validator.allowable_values}."
230
+ end
231
+ @mode = mode
232
+ end
233
+
234
+ # Checks equality by comparing each attribute.
235
+ # @param [Object] Object to be compared
236
+ def ==(o)
237
+ return true if self.equal?(o)
238
+ self.class == o.class &&
239
+ mode == o.mode &&
240
+ flagged == o.flagged &&
241
+ name == o.name &&
242
+ id == o.id &&
243
+ score == o.score &&
244
+ found == o.found &&
245
+ matches == o.matches &&
246
+ components == o.components &&
247
+ error == o.error &&
248
+ warning == o.warning
249
+ end
250
+
251
+ # @see the `==` method
252
+ # @param [Object] Object to be compared
253
+ def eql?(o)
254
+ self == o
255
+ end
256
+
257
+ # Calculates hash code according to all attributes.
258
+ # @return [Integer] Hash code
259
+ def hash
260
+ [mode, flagged, name, id, score, found, matches, components, error, warning].hash
261
+ end
262
+
263
+ # Builds the object from hash
264
+ # @param [Hash] attributes Model attributes in the form of hash
265
+ # @return [Object] Returns the model itself
266
+ def self.build_from_hash(attributes)
267
+ return nil unless attributes.is_a?(Hash)
268
+ attributes = attributes.transform_keys(&:to_sym)
269
+ transformed_hash = {}
270
+ openapi_types.each_pair do |key, type|
271
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
272
+ transformed_hash["#{key}"] = nil
273
+ elsif type =~ /\AArray<(.*)>/i
274
+ # check to ensure the input is an array given that the attribute
275
+ # is documented as an array but the input is not
276
+ if attributes[attribute_map[key]].is_a?(Array)
277
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
278
+ end
279
+ elsif !attributes[attribute_map[key]].nil?
280
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
281
+ end
282
+ end
283
+ new(transformed_hash)
284
+ end
285
+
286
+ # Deserializes the data based on type
287
+ # @param string type Data type
288
+ # @param string value Value to be deserialized
289
+ # @return [Object] Deserialized data
290
+ def self._deserialize(type, value)
291
+ case type.to_sym
292
+ when :Time
293
+ Time.parse(value)
294
+ when :Date
295
+ Date.parse(value)
296
+ when :String
297
+ value.to_s
298
+ when :Integer
299
+ value.to_i
300
+ when :Float
301
+ value.to_f
302
+ when :Boolean
303
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
304
+ true
305
+ else
306
+ false
307
+ end
308
+ when :Object
309
+ # generic object (usually a Hash), return directly
310
+ value
311
+ when /\AArray<(?<inner_type>.+)>\z/
312
+ inner_type = Regexp.last_match[:inner_type]
313
+ value.map { |v| _deserialize(inner_type, v) }
314
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
315
+ k_type = Regexp.last_match[:k_type]
316
+ v_type = Regexp.last_match[:v_type]
317
+ {}.tap do |hash|
318
+ value.each do |k, v|
319
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
320
+ end
321
+ end
322
+ else # model
323
+ # models (e.g. Pet) or oneOf
324
+ klass = ModerationAPI.const_get(type)
325
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
326
+ end
327
+ end
328
+
329
+ # Returns the string representation of the object
330
+ # @return [String] String presentation of the object
331
+ def to_s
332
+ to_hash.to_s
333
+ end
334
+
335
+ # to_body is an alias to to_hash (backward compatibility)
336
+ # @return [Hash] Returns the object in the form of hash
337
+ def to_body
338
+ to_hash
339
+ end
340
+
341
+ # Returns the object in the form of hash
342
+ # @return [Hash] Returns the object in the form of hash
343
+ def to_hash
344
+ hash = {}
345
+ self.class.attribute_map.each_pair do |attr, param|
346
+ value = self.send(attr)
347
+ if value.nil?
348
+ is_nullable = self.class.openapi_nullable.include?(attr)
349
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
350
+ end
351
+
352
+ hash[param] = _to_hash(value)
353
+ end
354
+ hash
355
+ end
356
+
357
+ # Outputs non-array value in the form of hash
358
+ # For object, use to_hash. Otherwise, just return the value
359
+ # @param [Object] value Any valid value
360
+ # @return [Hash] Returns the value in the form of hash
361
+ def _to_hash(value)
362
+ if value.is_a?(Array)
363
+ value.compact.map { |v| _to_hash(v) }
364
+ elsif value.is_a?(Hash)
365
+ {}.tap do |hash|
366
+ value.each { |k, v| hash[k] = _to_hash(v) }
367
+ end
368
+ elsif value.respond_to? :to_hash
369
+ value.to_hash
370
+ else
371
+ value
372
+ end
373
+ end
374
+
375
+ end
376
+
377
+ end
@@ -0,0 +1,330 @@
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 ModerationTextRequest
18
+ # The text you'd like to analyze. We recommend to submit plain text or HTML
19
+ attr_accessor :value
20
+
21
+ # The unique ID of the content in your database.
22
+ attr_accessor :content_id
23
+
24
+ # Do not store the content. The content won't enter the review queue
25
+ attr_accessor :do_not_store
26
+
27
+ # The author of the content.
28
+ attr_accessor :author_id
29
+
30
+ # For example the ID of a chat room or a post
31
+ attr_accessor :context_id
32
+
33
+ # Any metadata you want to store with the content
34
+ attr_accessor :metadata
35
+
36
+ # Attribute mapping from ruby-style variable name to JSON key.
37
+ def self.attribute_map
38
+ {
39
+ :'value' => :'value',
40
+ :'content_id' => :'contentId',
41
+ :'do_not_store' => :'doNotStore',
42
+ :'author_id' => :'authorId',
43
+ :'context_id' => :'contextId',
44
+ :'metadata' => :'metadata'
45
+ }
46
+ end
47
+
48
+ # Returns all the JSON keys this model knows about
49
+ def self.acceptable_attributes
50
+ attribute_map.values
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.openapi_types
55
+ {
56
+ :'value' => :'String',
57
+ :'content_id' => :'String',
58
+ :'do_not_store' => :'Boolean',
59
+ :'author_id' => :'String',
60
+ :'context_id' => :'String',
61
+ :'metadata' => :'Hash<String, Object>'
62
+ }
63
+ end
64
+
65
+ # List of attributes with nullable: true
66
+ def self.openapi_nullable
67
+ Set.new([
68
+ ])
69
+ end
70
+
71
+ # Initializes the object
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ def initialize(attributes = {})
74
+ if (!attributes.is_a?(Hash))
75
+ fail ArgumentError, "The input argument (attributes) must be a hash in `ModerationAPI::ModerationTextRequest` initialize method"
76
+ end
77
+
78
+ # check to see if the attribute exists and convert string to symbol for hash key
79
+ attributes = attributes.each_with_object({}) { |(k, v), h|
80
+ if (!self.class.attribute_map.key?(k.to_sym))
81
+ fail ArgumentError, "`#{k}` is not a valid attribute in `ModerationAPI::ModerationTextRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
82
+ end
83
+ h[k.to_sym] = v
84
+ }
85
+
86
+ if attributes.key?(:'value')
87
+ self.value = attributes[:'value']
88
+ else
89
+ self.value = nil
90
+ end
91
+
92
+ if attributes.key?(:'content_id')
93
+ self.content_id = attributes[:'content_id']
94
+ end
95
+
96
+ if attributes.key?(:'do_not_store')
97
+ self.do_not_store = attributes[:'do_not_store']
98
+ end
99
+
100
+ if attributes.key?(:'author_id')
101
+ self.author_id = attributes[:'author_id']
102
+ end
103
+
104
+ if attributes.key?(:'context_id')
105
+ self.context_id = attributes[:'context_id']
106
+ end
107
+
108
+ if attributes.key?(:'metadata')
109
+ if (value = attributes[:'metadata']).is_a?(Hash)
110
+ self.metadata = value
111
+ end
112
+ end
113
+ end
114
+
115
+ # Show invalid properties with the reasons. Usually used together with valid?
116
+ # @return Array for valid properties with the reasons
117
+ def list_invalid_properties
118
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
119
+ invalid_properties = Array.new
120
+ if @value.nil?
121
+ invalid_properties.push('invalid value for "value", value cannot be nil.')
122
+ end
123
+
124
+ if @value.to_s.length > 100000
125
+ invalid_properties.push('invalid value for "value", the character length must be smaller than or equal to 100000.')
126
+ end
127
+
128
+ if @value.to_s.length < 1
129
+ invalid_properties.push('invalid value for "value", the character length must be great than or equal to 1.')
130
+ end
131
+
132
+ if !@content_id.nil? && @content_id.to_s.length > 100
133
+ invalid_properties.push('invalid value for "content_id", the character length must be smaller than or equal to 100.')
134
+ end
135
+
136
+ if !@content_id.nil? && @content_id.to_s.length < 1
137
+ invalid_properties.push('invalid value for "content_id", the character length must be great than or equal to 1.')
138
+ end
139
+
140
+ invalid_properties
141
+ end
142
+
143
+ # Check to see if the all the properties in the model are valid
144
+ # @return true if the model is valid
145
+ def valid?
146
+ warn '[DEPRECATED] the `valid?` method is obsolete'
147
+ return false if @value.nil?
148
+ return false if @value.to_s.length > 100000
149
+ return false if @value.to_s.length < 1
150
+ return false if !@content_id.nil? && @content_id.to_s.length > 100
151
+ return false if !@content_id.nil? && @content_id.to_s.length < 1
152
+ true
153
+ end
154
+
155
+ # Custom attribute writer method with validation
156
+ # @param [Object] value Value to be assigned
157
+ def value=(value)
158
+ if value.nil?
159
+ fail ArgumentError, 'value cannot be nil'
160
+ end
161
+
162
+ if value.to_s.length > 100000
163
+ fail ArgumentError, 'invalid value for "value", the character length must be smaller than or equal to 100000.'
164
+ end
165
+
166
+ if value.to_s.length < 1
167
+ fail ArgumentError, 'invalid value for "value", the character length must be great than or equal to 1.'
168
+ end
169
+
170
+ @value = value
171
+ end
172
+
173
+ # Custom attribute writer method with validation
174
+ # @param [Object] content_id Value to be assigned
175
+ def content_id=(content_id)
176
+ if content_id.nil?
177
+ fail ArgumentError, 'content_id cannot be nil'
178
+ end
179
+
180
+ if content_id.to_s.length > 100
181
+ fail ArgumentError, 'invalid value for "content_id", the character length must be smaller than or equal to 100.'
182
+ end
183
+
184
+ if content_id.to_s.length < 1
185
+ fail ArgumentError, 'invalid value for "content_id", the character length must be great than or equal to 1.'
186
+ end
187
+
188
+ @content_id = content_id
189
+ end
190
+
191
+ # Checks equality by comparing each attribute.
192
+ # @param [Object] Object to be compared
193
+ def ==(o)
194
+ return true if self.equal?(o)
195
+ self.class == o.class &&
196
+ value == o.value &&
197
+ content_id == o.content_id &&
198
+ do_not_store == o.do_not_store &&
199
+ author_id == o.author_id &&
200
+ context_id == o.context_id &&
201
+ metadata == o.metadata
202
+ end
203
+
204
+ # @see the `==` method
205
+ # @param [Object] Object to be compared
206
+ def eql?(o)
207
+ self == o
208
+ end
209
+
210
+ # Calculates hash code according to all attributes.
211
+ # @return [Integer] Hash code
212
+ def hash
213
+ [value, content_id, do_not_store, author_id, context_id, metadata].hash
214
+ end
215
+
216
+ # Builds the object from hash
217
+ # @param [Hash] attributes Model attributes in the form of hash
218
+ # @return [Object] Returns the model itself
219
+ def self.build_from_hash(attributes)
220
+ return nil unless attributes.is_a?(Hash)
221
+ attributes = attributes.transform_keys(&:to_sym)
222
+ transformed_hash = {}
223
+ openapi_types.each_pair do |key, type|
224
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
225
+ transformed_hash["#{key}"] = nil
226
+ elsif type =~ /\AArray<(.*)>/i
227
+ # check to ensure the input is an array given that the attribute
228
+ # is documented as an array but the input is not
229
+ if attributes[attribute_map[key]].is_a?(Array)
230
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
231
+ end
232
+ elsif !attributes[attribute_map[key]].nil?
233
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
234
+ end
235
+ end
236
+ new(transformed_hash)
237
+ end
238
+
239
+ # Deserializes the data based on type
240
+ # @param string type Data type
241
+ # @param string value Value to be deserialized
242
+ # @return [Object] Deserialized data
243
+ def self._deserialize(type, value)
244
+ case type.to_sym
245
+ when :Time
246
+ Time.parse(value)
247
+ when :Date
248
+ Date.parse(value)
249
+ when :String
250
+ value.to_s
251
+ when :Integer
252
+ value.to_i
253
+ when :Float
254
+ value.to_f
255
+ when :Boolean
256
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
257
+ true
258
+ else
259
+ false
260
+ end
261
+ when :Object
262
+ # generic object (usually a Hash), return directly
263
+ value
264
+ when /\AArray<(?<inner_type>.+)>\z/
265
+ inner_type = Regexp.last_match[:inner_type]
266
+ value.map { |v| _deserialize(inner_type, v) }
267
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
268
+ k_type = Regexp.last_match[:k_type]
269
+ v_type = Regexp.last_match[:v_type]
270
+ {}.tap do |hash|
271
+ value.each do |k, v|
272
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
273
+ end
274
+ end
275
+ else # model
276
+ # models (e.g. Pet) or oneOf
277
+ klass = ModerationAPI.const_get(type)
278
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
279
+ end
280
+ end
281
+
282
+ # Returns the string representation of the object
283
+ # @return [String] String presentation of the object
284
+ def to_s
285
+ to_hash.to_s
286
+ end
287
+
288
+ # to_body is an alias to to_hash (backward compatibility)
289
+ # @return [Hash] Returns the object in the form of hash
290
+ def to_body
291
+ to_hash
292
+ end
293
+
294
+ # Returns the object in the form of hash
295
+ # @return [Hash] Returns the object in the form of hash
296
+ def to_hash
297
+ hash = {}
298
+ self.class.attribute_map.each_pair do |attr, param|
299
+ value = self.send(attr)
300
+ if value.nil?
301
+ is_nullable = self.class.openapi_nullable.include?(attr)
302
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
303
+ end
304
+
305
+ hash[param] = _to_hash(value)
306
+ end
307
+ hash
308
+ end
309
+
310
+ # Outputs non-array value in the form of hash
311
+ # For object, use to_hash. Otherwise, just return the value
312
+ # @param [Object] value Any valid value
313
+ # @return [Hash] Returns the value in the form of hash
314
+ def _to_hash(value)
315
+ if value.is_a?(Array)
316
+ value.compact.map { |v| _to_hash(v) }
317
+ elsif value.is_a?(Hash)
318
+ {}.tap do |hash|
319
+ value.each { |k, v| hash[k] = _to_hash(v) }
320
+ end
321
+ elsif value.respond_to? :to_hash
322
+ value.to_hash
323
+ else
324
+ value
325
+ end
326
+ end
327
+
328
+ end
329
+
330
+ end