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,303 @@
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
+ # The username entity matcher output if enabled in your project. Read more at https://docs.moderationapi.com/models/username
18
+ class ModerationText200ResponseAllOfUsername
19
+ # The detection mode.
20
+ attr_accessor :mode
21
+
22
+ # Whether a match was found or not.
23
+ attr_accessor :found
24
+
25
+ # The matches of the entity matcher.
26
+ attr_accessor :matches
27
+
28
+ # The components of the matcher.
29
+ attr_accessor :components
30
+
31
+ # Indicates an error with the matcher.
32
+ attr_accessor :error
33
+
34
+ # Indicates a warning from the model, e.g. if the text is too short or long and the model might not be accurate.
35
+ attr_accessor :warning
36
+
37
+ class EnumAttributeValidator
38
+ attr_reader :datatype
39
+ attr_reader :allowable_values
40
+
41
+ def initialize(datatype, allowable_values)
42
+ @allowable_values = allowable_values.map do |value|
43
+ case datatype.to_s
44
+ when /Integer/i
45
+ value.to_i
46
+ when /Float/i
47
+ value.to_f
48
+ else
49
+ value
50
+ end
51
+ end
52
+ end
53
+
54
+ def valid?(value)
55
+ !value || allowable_values.include?(value)
56
+ end
57
+ end
58
+
59
+ # Attribute mapping from ruby-style variable name to JSON key.
60
+ def self.attribute_map
61
+ {
62
+ :'mode' => :'mode',
63
+ :'found' => :'found',
64
+ :'matches' => :'matches',
65
+ :'components' => :'components',
66
+ :'error' => :'error',
67
+ :'warning' => :'warning'
68
+ }
69
+ end
70
+
71
+ # Returns all the JSON keys this model knows about
72
+ def self.acceptable_attributes
73
+ attribute_map.values
74
+ end
75
+
76
+ # Attribute type mapping.
77
+ def self.openapi_types
78
+ {
79
+ :'mode' => :'String',
80
+ :'found' => :'Boolean',
81
+ :'matches' => :'Array<String>',
82
+ :'components' => :'Object',
83
+ :'error' => :'String',
84
+ :'warning' => :'String'
85
+ }
86
+ end
87
+
88
+ # List of attributes with nullable: true
89
+ def self.openapi_nullable
90
+ Set.new([
91
+ :'components',
92
+ ])
93
+ end
94
+
95
+ # Initializes the object
96
+ # @param [Hash] attributes Model attributes in the form of hash
97
+ def initialize(attributes = {})
98
+ if (!attributes.is_a?(Hash))
99
+ fail ArgumentError, "The input argument (attributes) must be a hash in `ModerationAPI::ModerationText200ResponseAllOfUsername` initialize method"
100
+ end
101
+
102
+ # check to see if the attribute exists and convert string to symbol for hash key
103
+ attributes = attributes.each_with_object({}) { |(k, v), h|
104
+ if (!self.class.attribute_map.key?(k.to_sym))
105
+ fail ArgumentError, "`#{k}` is not a valid attribute in `ModerationAPI::ModerationText200ResponseAllOfUsername`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
106
+ end
107
+ h[k.to_sym] = v
108
+ }
109
+
110
+ if attributes.key?(:'mode')
111
+ self.mode = attributes[:'mode']
112
+ end
113
+
114
+ if attributes.key?(:'found')
115
+ self.found = attributes[:'found']
116
+ end
117
+
118
+ if attributes.key?(:'matches')
119
+ if (value = attributes[:'matches']).is_a?(Array)
120
+ self.matches = value
121
+ end
122
+ end
123
+
124
+ if attributes.key?(:'components')
125
+ self.components = attributes[:'components']
126
+ end
127
+
128
+ if attributes.key?(:'error')
129
+ self.error = attributes[:'error']
130
+ end
131
+
132
+ if attributes.key?(:'warning')
133
+ self.warning = attributes[:'warning']
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
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
141
+ invalid_properties = Array.new
142
+ invalid_properties
143
+ end
144
+
145
+ # Check to see if the all the properties in the model are valid
146
+ # @return true if the model is valid
147
+ def valid?
148
+ warn '[DEPRECATED] the `valid?` method is obsolete'
149
+ mode_validator = EnumAttributeValidator.new('String', ["NORMAL", "SUSPICIOUS", "PARANOID", "unknown_default_open_api"])
150
+ return false unless mode_validator.valid?(@mode)
151
+ true
152
+ end
153
+
154
+ # Custom attribute writer method checking allowed values (enum).
155
+ # @param [Object] mode Object to be assigned
156
+ def mode=(mode)
157
+ validator = EnumAttributeValidator.new('String', ["NORMAL", "SUSPICIOUS", "PARANOID", "unknown_default_open_api"])
158
+ unless validator.valid?(mode)
159
+ fail ArgumentError, "invalid value for \"mode\", must be one of #{validator.allowable_values}."
160
+ end
161
+ @mode = mode
162
+ end
163
+
164
+ # Checks equality by comparing each attribute.
165
+ # @param [Object] Object to be compared
166
+ def ==(o)
167
+ return true if self.equal?(o)
168
+ self.class == o.class &&
169
+ mode == o.mode &&
170
+ found == o.found &&
171
+ matches == o.matches &&
172
+ components == o.components &&
173
+ error == o.error &&
174
+ warning == o.warning
175
+ end
176
+
177
+ # @see the `==` method
178
+ # @param [Object] Object to be compared
179
+ def eql?(o)
180
+ self == o
181
+ end
182
+
183
+ # Calculates hash code according to all attributes.
184
+ # @return [Integer] Hash code
185
+ def hash
186
+ [mode, found, matches, components, error, warning].hash
187
+ end
188
+
189
+ # Builds the object from hash
190
+ # @param [Hash] attributes Model attributes in the form of hash
191
+ # @return [Object] Returns the model itself
192
+ def self.build_from_hash(attributes)
193
+ return nil unless attributes.is_a?(Hash)
194
+ attributes = attributes.transform_keys(&:to_sym)
195
+ transformed_hash = {}
196
+ openapi_types.each_pair do |key, type|
197
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
198
+ transformed_hash["#{key}"] = nil
199
+ elsif type =~ /\AArray<(.*)>/i
200
+ # check to ensure the input is an array given that the attribute
201
+ # is documented as an array but the input is not
202
+ if attributes[attribute_map[key]].is_a?(Array)
203
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
204
+ end
205
+ elsif !attributes[attribute_map[key]].nil?
206
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
207
+ end
208
+ end
209
+ new(transformed_hash)
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 self._deserialize(type, value)
217
+ case type.to_sym
218
+ when :Time
219
+ Time.parse(value)
220
+ when :Date
221
+ Date.parse(value)
222
+ when :String
223
+ value.to_s
224
+ when :Integer
225
+ value.to_i
226
+ when :Float
227
+ value.to_f
228
+ when :Boolean
229
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
230
+ true
231
+ else
232
+ false
233
+ end
234
+ when :Object
235
+ # generic object (usually a Hash), return directly
236
+ value
237
+ when /\AArray<(?<inner_type>.+)>\z/
238
+ inner_type = Regexp.last_match[:inner_type]
239
+ value.map { |v| _deserialize(inner_type, v) }
240
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
241
+ k_type = Regexp.last_match[:k_type]
242
+ v_type = Regexp.last_match[:v_type]
243
+ {}.tap do |hash|
244
+ value.each do |k, v|
245
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
246
+ end
247
+ end
248
+ else # model
249
+ # models (e.g. Pet) or oneOf
250
+ klass = ModerationAPI.const_get(type)
251
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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
+
301
+ end
302
+
303
+ end
@@ -0,0 +1,303 @@
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
+ # The wordlist entity matcher output if enabled in your project. Read more at https://docs.moderationapi.com/models/word
18
+ class ModerationText200ResponseAllOfWordlist
19
+ # The detection mode.
20
+ attr_accessor :mode
21
+
22
+ # Whether a match was found or not.
23
+ attr_accessor :found
24
+
25
+ # The matches of the entity matcher.
26
+ attr_accessor :matches
27
+
28
+ # The components of the matcher.
29
+ attr_accessor :components
30
+
31
+ # Indicates an error with the matcher.
32
+ attr_accessor :error
33
+
34
+ # Indicates a warning from the model, e.g. if the text is too short or long and the model might not be accurate.
35
+ attr_accessor :warning
36
+
37
+ class EnumAttributeValidator
38
+ attr_reader :datatype
39
+ attr_reader :allowable_values
40
+
41
+ def initialize(datatype, allowable_values)
42
+ @allowable_values = allowable_values.map do |value|
43
+ case datatype.to_s
44
+ when /Integer/i
45
+ value.to_i
46
+ when /Float/i
47
+ value.to_f
48
+ else
49
+ value
50
+ end
51
+ end
52
+ end
53
+
54
+ def valid?(value)
55
+ !value || allowable_values.include?(value)
56
+ end
57
+ end
58
+
59
+ # Attribute mapping from ruby-style variable name to JSON key.
60
+ def self.attribute_map
61
+ {
62
+ :'mode' => :'mode',
63
+ :'found' => :'found',
64
+ :'matches' => :'matches',
65
+ :'components' => :'components',
66
+ :'error' => :'error',
67
+ :'warning' => :'warning'
68
+ }
69
+ end
70
+
71
+ # Returns all the JSON keys this model knows about
72
+ def self.acceptable_attributes
73
+ attribute_map.values
74
+ end
75
+
76
+ # Attribute type mapping.
77
+ def self.openapi_types
78
+ {
79
+ :'mode' => :'String',
80
+ :'found' => :'Boolean',
81
+ :'matches' => :'Array<String>',
82
+ :'components' => :'Object',
83
+ :'error' => :'String',
84
+ :'warning' => :'String'
85
+ }
86
+ end
87
+
88
+ # List of attributes with nullable: true
89
+ def self.openapi_nullable
90
+ Set.new([
91
+ :'components',
92
+ ])
93
+ end
94
+
95
+ # Initializes the object
96
+ # @param [Hash] attributes Model attributes in the form of hash
97
+ def initialize(attributes = {})
98
+ if (!attributes.is_a?(Hash))
99
+ fail ArgumentError, "The input argument (attributes) must be a hash in `ModerationAPI::ModerationText200ResponseAllOfWordlist` initialize method"
100
+ end
101
+
102
+ # check to see if the attribute exists and convert string to symbol for hash key
103
+ attributes = attributes.each_with_object({}) { |(k, v), h|
104
+ if (!self.class.attribute_map.key?(k.to_sym))
105
+ fail ArgumentError, "`#{k}` is not a valid attribute in `ModerationAPI::ModerationText200ResponseAllOfWordlist`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
106
+ end
107
+ h[k.to_sym] = v
108
+ }
109
+
110
+ if attributes.key?(:'mode')
111
+ self.mode = attributes[:'mode']
112
+ end
113
+
114
+ if attributes.key?(:'found')
115
+ self.found = attributes[:'found']
116
+ end
117
+
118
+ if attributes.key?(:'matches')
119
+ if (value = attributes[:'matches']).is_a?(Array)
120
+ self.matches = value
121
+ end
122
+ end
123
+
124
+ if attributes.key?(:'components')
125
+ self.components = attributes[:'components']
126
+ end
127
+
128
+ if attributes.key?(:'error')
129
+ self.error = attributes[:'error']
130
+ end
131
+
132
+ if attributes.key?(:'warning')
133
+ self.warning = attributes[:'warning']
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
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
141
+ invalid_properties = Array.new
142
+ invalid_properties
143
+ end
144
+
145
+ # Check to see if the all the properties in the model are valid
146
+ # @return true if the model is valid
147
+ def valid?
148
+ warn '[DEPRECATED] the `valid?` method is obsolete'
149
+ mode_validator = EnumAttributeValidator.new('String', ["NORMAL", "SUSPICIOUS", "PARANOID", "unknown_default_open_api"])
150
+ return false unless mode_validator.valid?(@mode)
151
+ true
152
+ end
153
+
154
+ # Custom attribute writer method checking allowed values (enum).
155
+ # @param [Object] mode Object to be assigned
156
+ def mode=(mode)
157
+ validator = EnumAttributeValidator.new('String', ["NORMAL", "SUSPICIOUS", "PARANOID", "unknown_default_open_api"])
158
+ unless validator.valid?(mode)
159
+ fail ArgumentError, "invalid value for \"mode\", must be one of #{validator.allowable_values}."
160
+ end
161
+ @mode = mode
162
+ end
163
+
164
+ # Checks equality by comparing each attribute.
165
+ # @param [Object] Object to be compared
166
+ def ==(o)
167
+ return true if self.equal?(o)
168
+ self.class == o.class &&
169
+ mode == o.mode &&
170
+ found == o.found &&
171
+ matches == o.matches &&
172
+ components == o.components &&
173
+ error == o.error &&
174
+ warning == o.warning
175
+ end
176
+
177
+ # @see the `==` method
178
+ # @param [Object] Object to be compared
179
+ def eql?(o)
180
+ self == o
181
+ end
182
+
183
+ # Calculates hash code according to all attributes.
184
+ # @return [Integer] Hash code
185
+ def hash
186
+ [mode, found, matches, components, error, warning].hash
187
+ end
188
+
189
+ # Builds the object from hash
190
+ # @param [Hash] attributes Model attributes in the form of hash
191
+ # @return [Object] Returns the model itself
192
+ def self.build_from_hash(attributes)
193
+ return nil unless attributes.is_a?(Hash)
194
+ attributes = attributes.transform_keys(&:to_sym)
195
+ transformed_hash = {}
196
+ openapi_types.each_pair do |key, type|
197
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
198
+ transformed_hash["#{key}"] = nil
199
+ elsif type =~ /\AArray<(.*)>/i
200
+ # check to ensure the input is an array given that the attribute
201
+ # is documented as an array but the input is not
202
+ if attributes[attribute_map[key]].is_a?(Array)
203
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
204
+ end
205
+ elsif !attributes[attribute_map[key]].nil?
206
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
207
+ end
208
+ end
209
+ new(transformed_hash)
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 self._deserialize(type, value)
217
+ case type.to_sym
218
+ when :Time
219
+ Time.parse(value)
220
+ when :Date
221
+ Date.parse(value)
222
+ when :String
223
+ value.to_s
224
+ when :Integer
225
+ value.to_i
226
+ when :Float
227
+ value.to_f
228
+ when :Boolean
229
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
230
+ true
231
+ else
232
+ false
233
+ end
234
+ when :Object
235
+ # generic object (usually a Hash), return directly
236
+ value
237
+ when /\AArray<(?<inner_type>.+)>\z/
238
+ inner_type = Regexp.last_match[:inner_type]
239
+ value.map { |v| _deserialize(inner_type, v) }
240
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
241
+ k_type = Regexp.last_match[:k_type]
242
+ v_type = Regexp.last_match[:v_type]
243
+ {}.tap do |hash|
244
+ value.each do |k, v|
245
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
246
+ end
247
+ end
248
+ else # model
249
+ # models (e.g. Pet) or oneOf
250
+ klass = ModerationAPI.const_get(type)
251
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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
+
301
+ end
302
+
303
+ end