moderation_api 3.2.0 → 3.3.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.
- checksums.yaml +4 -4
- data/lib/moderation_api/authors.rb +759 -0
- data/lib/moderation_api/content.rb +506 -0
- data/lib/moderation_api/models/operations/allowcontent_request.rb +45 -0
- data/lib/moderation_api/models/operations/allowcontent_request.rbi +26 -0
- data/lib/moderation_api/models/operations/allowcontent_requestbody.rb +67 -0
- data/lib/moderation_api/models/operations/allowcontent_requestbody.rbi +32 -0
- data/lib/moderation_api/models/operations/allowcontent_response.rb +51 -0
- data/lib/moderation_api/models/operations/allowcontent_response.rbi +32 -0
- data/lib/moderation_api/models/operations/allowcontent_responsebody.rb +35 -0
- data/lib/moderation_api/models/operations/allowcontent_responsebody.rbi +14 -0
- data/lib/moderation_api/models/operations/blockauthor_request.rb +45 -0
- data/lib/moderation_api/models/operations/blockauthor_request.rbi +26 -0
- data/lib/moderation_api/models/operations/blockauthor_requestbody.rb +35 -0
- data/lib/moderation_api/models/operations/blockauthor_requestbody.rbi +14 -0
- data/lib/moderation_api/models/operations/blockauthor_response.rb +51 -0
- data/lib/moderation_api/models/operations/blockauthor_response.rbi +32 -0
- data/lib/moderation_api/models/operations/blockauthor_responsebody.rb +35 -0
- data/lib/moderation_api/models/operations/blockauthor_responsebody.rbi +14 -0
- data/lib/moderation_api/models/operations/executeaction_requestbody.rb +29 -2
- data/lib/moderation_api/models/operations/executeaction_requestbody.rbi +12 -0
- data/lib/moderation_api/models/operations/rejectcontent_request.rb +45 -0
- data/lib/moderation_api/models/operations/rejectcontent_request.rbi +26 -0
- data/lib/moderation_api/models/operations/rejectcontent_requestbody.rb +67 -0
- data/lib/moderation_api/models/operations/rejectcontent_requestbody.rbi +32 -0
- data/lib/moderation_api/models/operations/rejectcontent_response.rb +51 -0
- data/lib/moderation_api/models/operations/rejectcontent_response.rbi +32 -0
- data/lib/moderation_api/models/operations/rejectcontent_responsebody.rb +35 -0
- data/lib/moderation_api/models/operations/rejectcontent_responsebody.rbi +14 -0
- data/lib/moderation_api/models/operations/suspendauthor_request.rb +45 -0
- data/lib/moderation_api/models/operations/suspendauthor_request.rbi +26 -0
- data/lib/moderation_api/models/operations/suspendauthor_requestbody.rb +43 -0
- data/lib/moderation_api/models/operations/suspendauthor_requestbody.rbi +20 -0
- data/lib/moderation_api/models/operations/suspendauthor_response.rb +51 -0
- data/lib/moderation_api/models/operations/suspendauthor_response.rbi +32 -0
- data/lib/moderation_api/models/operations/suspendauthor_responsebody.rb +35 -0
- data/lib/moderation_api/models/operations/suspendauthor_responsebody.rbi +14 -0
- data/lib/moderation_api/models/operations/unblockauthor_request.rb +45 -0
- data/lib/moderation_api/models/operations/unblockauthor_request.rbi +26 -0
- data/lib/moderation_api/models/operations/unblockauthor_requestbody.rb +35 -0
- data/lib/moderation_api/models/operations/unblockauthor_requestbody.rbi +14 -0
- data/lib/moderation_api/models/operations/unblockauthor_response.rb +51 -0
- data/lib/moderation_api/models/operations/unblockauthor_response.rbi +32 -0
- data/lib/moderation_api/models/operations/unblockauthor_responsebody.rb +35 -0
- data/lib/moderation_api/models/operations/unblockauthor_responsebody.rbi +14 -0
- data/lib/moderation_api/models/operations.rb +20 -0
- data/lib/moderation_api/moderationapi.rb +2 -2
- data/lib/moderation_api/sdkconfiguration.rb +2 -2
- data/lib/moderation_api.rb +1 -1
- metadata +42 -2
|
@@ -37,6 +37,512 @@ module ModerationApi
|
|
|
37
37
|
return Utils.template_url(base_url, url_variables)
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
+
sig {
|
|
41
|
+
params(
|
|
42
|
+
body: Models::Operations::RejectContentRequestBody,
|
|
43
|
+
id: ::String,
|
|
44
|
+
project_id: T.nilable(::String),
|
|
45
|
+
timeout_ms: T.nilable(Integer),
|
|
46
|
+
http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
|
|
47
|
+
)
|
|
48
|
+
.returns(Models::Operations::RejectContentResponse)
|
|
49
|
+
}
|
|
50
|
+
def reject(body:, id:, project_id: nil, timeout_ms: nil, http_headers: nil)
|
|
51
|
+
# reject - Reject content
|
|
52
|
+
# Reject a content item with the built-in reject action, and resolve it in the review queue.
|
|
53
|
+
request = Models::Operations::RejectContentRequest.new(
|
|
54
|
+
id: id,
|
|
55
|
+
body: body,
|
|
56
|
+
project_id: project_id
|
|
57
|
+
)
|
|
58
|
+
url, params = @sdk_configuration.get_server_details
|
|
59
|
+
base_url = Utils.template_url(url, params)
|
|
60
|
+
url = Utils.generate_url(
|
|
61
|
+
Models::Operations::RejectContentRequest,
|
|
62
|
+
base_url,
|
|
63
|
+
"/content/{id}/reject",
|
|
64
|
+
request
|
|
65
|
+
)
|
|
66
|
+
headers = Utils.get_headers(request)
|
|
67
|
+
headers = T.cast(headers, T::Hash[String, String])
|
|
68
|
+
req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
|
|
69
|
+
headers["content-type"] = req_content_type
|
|
70
|
+
raise StandardError, "request body is required" if data.nil? && form.nil?
|
|
71
|
+
|
|
72
|
+
if form && !form.empty?
|
|
73
|
+
body = Utils.encode_form(form)
|
|
74
|
+
elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
|
|
75
|
+
body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
|
|
76
|
+
else
|
|
77
|
+
body = data
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
headers["Accept"] = "application/json"
|
|
81
|
+
headers["user-agent"] = @sdk_configuration.user_agent
|
|
82
|
+
|
|
83
|
+
security = @sdk_configuration.security_source&.call
|
|
84
|
+
|
|
85
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
|
86
|
+
timeout ||= @sdk_configuration.timeout
|
|
87
|
+
|
|
88
|
+
connection = @sdk_configuration.client
|
|
89
|
+
|
|
90
|
+
hook_ctx = SDKHooks::HookContext.new(
|
|
91
|
+
config: @sdk_configuration,
|
|
92
|
+
base_url: base_url,
|
|
93
|
+
oauth2_scopes: nil,
|
|
94
|
+
operation_id: "rejectContent",
|
|
95
|
+
security_source: @sdk_configuration.security_source
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
error = T.let(nil, T.nilable(StandardError))
|
|
99
|
+
http_response = T.let(nil, T.nilable(Faraday::Response))
|
|
100
|
+
|
|
101
|
+
begin
|
|
102
|
+
http_response = T.must(connection).post(url) do |req|
|
|
103
|
+
req.body = body
|
|
104
|
+
req.headers.merge!(headers)
|
|
105
|
+
req.options.timeout = timeout unless timeout.nil?
|
|
106
|
+
Utils.configure_request_security(req, security)
|
|
107
|
+
http_headers&.each do |key, value|
|
|
108
|
+
req.headers[key.to_s] = value
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
@sdk_configuration.hooks.before_request(
|
|
112
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
|
113
|
+
hook_ctx: hook_ctx
|
|
114
|
+
),
|
|
115
|
+
request: req
|
|
116
|
+
)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
rescue StandardError => e
|
|
120
|
+
error = e
|
|
121
|
+
ensure
|
|
122
|
+
if http_response.nil? || Utils.error_status?(http_response.status)
|
|
123
|
+
http_response = @sdk_configuration.hooks.after_error(
|
|
124
|
+
error: error,
|
|
125
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
126
|
+
hook_ctx: hook_ctx
|
|
127
|
+
),
|
|
128
|
+
response: http_response
|
|
129
|
+
)
|
|
130
|
+
else
|
|
131
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
132
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
133
|
+
hook_ctx: hook_ctx
|
|
134
|
+
),
|
|
135
|
+
response: http_response
|
|
136
|
+
)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
if http_response.nil?
|
|
140
|
+
raise error if !error.nil?
|
|
141
|
+
raise "no response"
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
|
|
146
|
+
if Utils.match_status_code(http_response.status, ["200"])
|
|
147
|
+
if Utils.match_content_type(content_type, "application/json")
|
|
148
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
149
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
150
|
+
hook_ctx: hook_ctx
|
|
151
|
+
),
|
|
152
|
+
response: http_response
|
|
153
|
+
)
|
|
154
|
+
response_data = http_response.env.response_body
|
|
155
|
+
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Operations::RejectContentResponseBody)
|
|
156
|
+
response = Models::Operations::RejectContentResponse.new(
|
|
157
|
+
status_code: http_response.status,
|
|
158
|
+
content_type: content_type,
|
|
159
|
+
raw_response: http_response,
|
|
160
|
+
object: T.unsafe(obj)
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
return response
|
|
164
|
+
else
|
|
165
|
+
raise(
|
|
166
|
+
::ModerationApi::Models::Errors::APIError.new(
|
|
167
|
+
status_code: http_response.status,
|
|
168
|
+
body: http_response.env.response_body,
|
|
169
|
+
raw_response: http_response
|
|
170
|
+
),
|
|
171
|
+
"Unknown content type received"
|
|
172
|
+
)
|
|
173
|
+
end
|
|
174
|
+
elsif Utils.match_status_code(http_response.status, ["400"])
|
|
175
|
+
if Utils.match_content_type(content_type, "application/json")
|
|
176
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
177
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
178
|
+
hook_ctx: hook_ctx
|
|
179
|
+
),
|
|
180
|
+
response: http_response
|
|
181
|
+
)
|
|
182
|
+
response_data = http_response.env.response_body
|
|
183
|
+
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
|
|
184
|
+
obj.raw_response = http_response
|
|
185
|
+
raise obj
|
|
186
|
+
else
|
|
187
|
+
raise(
|
|
188
|
+
::ModerationApi::Models::Errors::APIError.new(
|
|
189
|
+
status_code: http_response.status,
|
|
190
|
+
body: http_response.env.response_body,
|
|
191
|
+
raw_response: http_response
|
|
192
|
+
),
|
|
193
|
+
"Unknown content type received"
|
|
194
|
+
)
|
|
195
|
+
end
|
|
196
|
+
elsif Utils.match_status_code(http_response.status, ["401"])
|
|
197
|
+
if Utils.match_content_type(content_type, "application/json")
|
|
198
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
199
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
200
|
+
hook_ctx: hook_ctx
|
|
201
|
+
),
|
|
202
|
+
response: http_response
|
|
203
|
+
)
|
|
204
|
+
response_data = http_response.env.response_body
|
|
205
|
+
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
|
|
206
|
+
obj.raw_response = http_response
|
|
207
|
+
raise obj
|
|
208
|
+
else
|
|
209
|
+
raise(
|
|
210
|
+
::ModerationApi::Models::Errors::APIError.new(
|
|
211
|
+
status_code: http_response.status,
|
|
212
|
+
body: http_response.env.response_body,
|
|
213
|
+
raw_response: http_response
|
|
214
|
+
),
|
|
215
|
+
"Unknown content type received"
|
|
216
|
+
)
|
|
217
|
+
end
|
|
218
|
+
elsif Utils.match_status_code(http_response.status, ["404"])
|
|
219
|
+
if Utils.match_content_type(content_type, "application/json")
|
|
220
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
221
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
222
|
+
hook_ctx: hook_ctx
|
|
223
|
+
),
|
|
224
|
+
response: http_response
|
|
225
|
+
)
|
|
226
|
+
response_data = http_response.env.response_body
|
|
227
|
+
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
|
|
228
|
+
obj.raw_response = http_response
|
|
229
|
+
raise obj
|
|
230
|
+
else
|
|
231
|
+
raise(
|
|
232
|
+
::ModerationApi::Models::Errors::APIError.new(
|
|
233
|
+
status_code: http_response.status,
|
|
234
|
+
body: http_response.env.response_body,
|
|
235
|
+
raw_response: http_response
|
|
236
|
+
),
|
|
237
|
+
"Unknown content type received"
|
|
238
|
+
)
|
|
239
|
+
end
|
|
240
|
+
elsif Utils.match_status_code(http_response.status, ["429"])
|
|
241
|
+
if Utils.match_content_type(content_type, "application/json")
|
|
242
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
243
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
244
|
+
hook_ctx: hook_ctx
|
|
245
|
+
),
|
|
246
|
+
response: http_response
|
|
247
|
+
)
|
|
248
|
+
response_data = http_response.env.response_body
|
|
249
|
+
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
|
|
250
|
+
obj.raw_response = http_response
|
|
251
|
+
raise obj
|
|
252
|
+
else
|
|
253
|
+
raise(
|
|
254
|
+
::ModerationApi::Models::Errors::APIError.new(
|
|
255
|
+
status_code: http_response.status,
|
|
256
|
+
body: http_response.env.response_body,
|
|
257
|
+
raw_response: http_response
|
|
258
|
+
),
|
|
259
|
+
"Unknown content type received"
|
|
260
|
+
)
|
|
261
|
+
end
|
|
262
|
+
elsif Utils.match_status_code(http_response.status, ["4XX"])
|
|
263
|
+
raise(
|
|
264
|
+
::ModerationApi::Models::Errors::APIError.new(
|
|
265
|
+
status_code: http_response.status,
|
|
266
|
+
body: http_response.env.response_body,
|
|
267
|
+
raw_response: http_response
|
|
268
|
+
),
|
|
269
|
+
"API error occurred"
|
|
270
|
+
)
|
|
271
|
+
elsif Utils.match_status_code(http_response.status, ["5XX"])
|
|
272
|
+
raise(
|
|
273
|
+
::ModerationApi::Models::Errors::APIError.new(
|
|
274
|
+
status_code: http_response.status,
|
|
275
|
+
body: http_response.env.response_body,
|
|
276
|
+
raw_response: http_response
|
|
277
|
+
),
|
|
278
|
+
"API error occurred"
|
|
279
|
+
)
|
|
280
|
+
else
|
|
281
|
+
raise(
|
|
282
|
+
::ModerationApi::Models::Errors::APIError.new(
|
|
283
|
+
status_code: http_response.status,
|
|
284
|
+
body: http_response.env.response_body,
|
|
285
|
+
raw_response: http_response
|
|
286
|
+
),
|
|
287
|
+
"Unknown status code received"
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
end
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
sig {
|
|
294
|
+
params(
|
|
295
|
+
body: Models::Operations::AllowContentRequestBody,
|
|
296
|
+
id: ::String,
|
|
297
|
+
project_id: T.nilable(::String),
|
|
298
|
+
timeout_ms: T.nilable(Integer),
|
|
299
|
+
http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
|
|
300
|
+
)
|
|
301
|
+
.returns(Models::Operations::AllowContentResponse)
|
|
302
|
+
}
|
|
303
|
+
def allow(body:, id:, project_id: nil, timeout_ms: nil, http_headers: nil)
|
|
304
|
+
# allow - Allow content
|
|
305
|
+
# Allow a content item with the built-in allow action, and resolve it in the review queue.
|
|
306
|
+
request = Models::Operations::AllowContentRequest.new(
|
|
307
|
+
id: id,
|
|
308
|
+
body: body,
|
|
309
|
+
project_id: project_id
|
|
310
|
+
)
|
|
311
|
+
url, params = @sdk_configuration.get_server_details
|
|
312
|
+
base_url = Utils.template_url(url, params)
|
|
313
|
+
url = Utils.generate_url(
|
|
314
|
+
Models::Operations::AllowContentRequest,
|
|
315
|
+
base_url,
|
|
316
|
+
"/content/{id}/allow",
|
|
317
|
+
request
|
|
318
|
+
)
|
|
319
|
+
headers = Utils.get_headers(request)
|
|
320
|
+
headers = T.cast(headers, T::Hash[String, String])
|
|
321
|
+
req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
|
|
322
|
+
headers["content-type"] = req_content_type
|
|
323
|
+
raise StandardError, "request body is required" if data.nil? && form.nil?
|
|
324
|
+
|
|
325
|
+
if form && !form.empty?
|
|
326
|
+
body = Utils.encode_form(form)
|
|
327
|
+
elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
|
|
328
|
+
body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
|
|
329
|
+
else
|
|
330
|
+
body = data
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
headers["Accept"] = "application/json"
|
|
334
|
+
headers["user-agent"] = @sdk_configuration.user_agent
|
|
335
|
+
|
|
336
|
+
security = @sdk_configuration.security_source&.call
|
|
337
|
+
|
|
338
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
|
339
|
+
timeout ||= @sdk_configuration.timeout
|
|
340
|
+
|
|
341
|
+
connection = @sdk_configuration.client
|
|
342
|
+
|
|
343
|
+
hook_ctx = SDKHooks::HookContext.new(
|
|
344
|
+
config: @sdk_configuration,
|
|
345
|
+
base_url: base_url,
|
|
346
|
+
oauth2_scopes: nil,
|
|
347
|
+
operation_id: "allowContent",
|
|
348
|
+
security_source: @sdk_configuration.security_source
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
error = T.let(nil, T.nilable(StandardError))
|
|
352
|
+
http_response = T.let(nil, T.nilable(Faraday::Response))
|
|
353
|
+
|
|
354
|
+
begin
|
|
355
|
+
http_response = T.must(connection).post(url) do |req|
|
|
356
|
+
req.body = body
|
|
357
|
+
req.headers.merge!(headers)
|
|
358
|
+
req.options.timeout = timeout unless timeout.nil?
|
|
359
|
+
Utils.configure_request_security(req, security)
|
|
360
|
+
http_headers&.each do |key, value|
|
|
361
|
+
req.headers[key.to_s] = value
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
@sdk_configuration.hooks.before_request(
|
|
365
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
|
366
|
+
hook_ctx: hook_ctx
|
|
367
|
+
),
|
|
368
|
+
request: req
|
|
369
|
+
)
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
rescue StandardError => e
|
|
373
|
+
error = e
|
|
374
|
+
ensure
|
|
375
|
+
if http_response.nil? || Utils.error_status?(http_response.status)
|
|
376
|
+
http_response = @sdk_configuration.hooks.after_error(
|
|
377
|
+
error: error,
|
|
378
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
|
379
|
+
hook_ctx: hook_ctx
|
|
380
|
+
),
|
|
381
|
+
response: http_response
|
|
382
|
+
)
|
|
383
|
+
else
|
|
384
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
385
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
386
|
+
hook_ctx: hook_ctx
|
|
387
|
+
),
|
|
388
|
+
response: http_response
|
|
389
|
+
)
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
if http_response.nil?
|
|
393
|
+
raise error if !error.nil?
|
|
394
|
+
raise "no response"
|
|
395
|
+
end
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
|
|
399
|
+
if Utils.match_status_code(http_response.status, ["200"])
|
|
400
|
+
if Utils.match_content_type(content_type, "application/json")
|
|
401
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
402
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
403
|
+
hook_ctx: hook_ctx
|
|
404
|
+
),
|
|
405
|
+
response: http_response
|
|
406
|
+
)
|
|
407
|
+
response_data = http_response.env.response_body
|
|
408
|
+
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Operations::AllowContentResponseBody)
|
|
409
|
+
response = Models::Operations::AllowContentResponse.new(
|
|
410
|
+
status_code: http_response.status,
|
|
411
|
+
content_type: content_type,
|
|
412
|
+
raw_response: http_response,
|
|
413
|
+
object: T.unsafe(obj)
|
|
414
|
+
)
|
|
415
|
+
|
|
416
|
+
return response
|
|
417
|
+
else
|
|
418
|
+
raise(
|
|
419
|
+
::ModerationApi::Models::Errors::APIError.new(
|
|
420
|
+
status_code: http_response.status,
|
|
421
|
+
body: http_response.env.response_body,
|
|
422
|
+
raw_response: http_response
|
|
423
|
+
),
|
|
424
|
+
"Unknown content type received"
|
|
425
|
+
)
|
|
426
|
+
end
|
|
427
|
+
elsif Utils.match_status_code(http_response.status, ["400"])
|
|
428
|
+
if Utils.match_content_type(content_type, "application/json")
|
|
429
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
430
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
431
|
+
hook_ctx: hook_ctx
|
|
432
|
+
),
|
|
433
|
+
response: http_response
|
|
434
|
+
)
|
|
435
|
+
response_data = http_response.env.response_body
|
|
436
|
+
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
|
|
437
|
+
obj.raw_response = http_response
|
|
438
|
+
raise obj
|
|
439
|
+
else
|
|
440
|
+
raise(
|
|
441
|
+
::ModerationApi::Models::Errors::APIError.new(
|
|
442
|
+
status_code: http_response.status,
|
|
443
|
+
body: http_response.env.response_body,
|
|
444
|
+
raw_response: http_response
|
|
445
|
+
),
|
|
446
|
+
"Unknown content type received"
|
|
447
|
+
)
|
|
448
|
+
end
|
|
449
|
+
elsif Utils.match_status_code(http_response.status, ["401"])
|
|
450
|
+
if Utils.match_content_type(content_type, "application/json")
|
|
451
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
452
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
453
|
+
hook_ctx: hook_ctx
|
|
454
|
+
),
|
|
455
|
+
response: http_response
|
|
456
|
+
)
|
|
457
|
+
response_data = http_response.env.response_body
|
|
458
|
+
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
|
|
459
|
+
obj.raw_response = http_response
|
|
460
|
+
raise obj
|
|
461
|
+
else
|
|
462
|
+
raise(
|
|
463
|
+
::ModerationApi::Models::Errors::APIError.new(
|
|
464
|
+
status_code: http_response.status,
|
|
465
|
+
body: http_response.env.response_body,
|
|
466
|
+
raw_response: http_response
|
|
467
|
+
),
|
|
468
|
+
"Unknown content type received"
|
|
469
|
+
)
|
|
470
|
+
end
|
|
471
|
+
elsif Utils.match_status_code(http_response.status, ["404"])
|
|
472
|
+
if Utils.match_content_type(content_type, "application/json")
|
|
473
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
474
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
475
|
+
hook_ctx: hook_ctx
|
|
476
|
+
),
|
|
477
|
+
response: http_response
|
|
478
|
+
)
|
|
479
|
+
response_data = http_response.env.response_body
|
|
480
|
+
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
|
|
481
|
+
obj.raw_response = http_response
|
|
482
|
+
raise obj
|
|
483
|
+
else
|
|
484
|
+
raise(
|
|
485
|
+
::ModerationApi::Models::Errors::APIError.new(
|
|
486
|
+
status_code: http_response.status,
|
|
487
|
+
body: http_response.env.response_body,
|
|
488
|
+
raw_response: http_response
|
|
489
|
+
),
|
|
490
|
+
"Unknown content type received"
|
|
491
|
+
)
|
|
492
|
+
end
|
|
493
|
+
elsif Utils.match_status_code(http_response.status, ["429"])
|
|
494
|
+
if Utils.match_content_type(content_type, "application/json")
|
|
495
|
+
http_response = @sdk_configuration.hooks.after_success(
|
|
496
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
|
497
|
+
hook_ctx: hook_ctx
|
|
498
|
+
),
|
|
499
|
+
response: http_response
|
|
500
|
+
)
|
|
501
|
+
response_data = http_response.env.response_body
|
|
502
|
+
obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
|
|
503
|
+
obj.raw_response = http_response
|
|
504
|
+
raise obj
|
|
505
|
+
else
|
|
506
|
+
raise(
|
|
507
|
+
::ModerationApi::Models::Errors::APIError.new(
|
|
508
|
+
status_code: http_response.status,
|
|
509
|
+
body: http_response.env.response_body,
|
|
510
|
+
raw_response: http_response
|
|
511
|
+
),
|
|
512
|
+
"Unknown content type received"
|
|
513
|
+
)
|
|
514
|
+
end
|
|
515
|
+
elsif Utils.match_status_code(http_response.status, ["4XX"])
|
|
516
|
+
raise(
|
|
517
|
+
::ModerationApi::Models::Errors::APIError.new(
|
|
518
|
+
status_code: http_response.status,
|
|
519
|
+
body: http_response.env.response_body,
|
|
520
|
+
raw_response: http_response
|
|
521
|
+
),
|
|
522
|
+
"API error occurred"
|
|
523
|
+
)
|
|
524
|
+
elsif Utils.match_status_code(http_response.status, ["5XX"])
|
|
525
|
+
raise(
|
|
526
|
+
::ModerationApi::Models::Errors::APIError.new(
|
|
527
|
+
status_code: http_response.status,
|
|
528
|
+
body: http_response.env.response_body,
|
|
529
|
+
raw_response: http_response
|
|
530
|
+
),
|
|
531
|
+
"API error occurred"
|
|
532
|
+
)
|
|
533
|
+
else
|
|
534
|
+
raise(
|
|
535
|
+
::ModerationApi::Models::Errors::APIError.new(
|
|
536
|
+
status_code: http_response.status,
|
|
537
|
+
body: http_response.env.response_body,
|
|
538
|
+
raw_response: http_response
|
|
539
|
+
),
|
|
540
|
+
"Unknown status code received"
|
|
541
|
+
)
|
|
542
|
+
|
|
543
|
+
end
|
|
544
|
+
end
|
|
545
|
+
|
|
40
546
|
sig {
|
|
41
547
|
params(
|
|
42
548
|
body: Models::Operations::SubmitContentRequestBody,
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
# typed: true
|
|
4
|
+
# frozen_string_literal: true
|
|
5
|
+
|
|
6
|
+
module ModerationApi
|
|
7
|
+
module Models
|
|
8
|
+
module Operations
|
|
9
|
+
|
|
10
|
+
class AllowContentRequest
|
|
11
|
+
extend T::Sig
|
|
12
|
+
include Crystalline::MetadataFields
|
|
13
|
+
|
|
14
|
+
# The content ID you sent when you submitted the content, or the ID Moderation API assigned.
|
|
15
|
+
field :id, ::String, {'path_param': {'field_name': "id", 'style': "simple", 'explode': false}}
|
|
16
|
+
|
|
17
|
+
field :body, Models::Operations::AllowContentRequestBody, {'request': {'media_type': "application/json"}}
|
|
18
|
+
# The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error.
|
|
19
|
+
field(
|
|
20
|
+
:project_id,
|
|
21
|
+
Crystalline::Nilable.new(::String),
|
|
22
|
+
{'header': {'field_name': "Project-Id", 'style': "simple", 'explode': false}}
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
sig {
|
|
26
|
+
params(id: ::String, body: Models::Operations::AllowContentRequestBody, project_id: T.nilable(::String)).void
|
|
27
|
+
}
|
|
28
|
+
def initialize(id:, body:, project_id: nil)
|
|
29
|
+
@id = id
|
|
30
|
+
@body = body
|
|
31
|
+
@project_id = project_id
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
sig { params(other: T.untyped).returns(T::Boolean) }
|
|
35
|
+
def ==(other)
|
|
36
|
+
return false unless other.is_a?(self.class)
|
|
37
|
+
return false unless @id == other.id
|
|
38
|
+
return false unless @body == other.body
|
|
39
|
+
return false unless @project_id == other.project_id
|
|
40
|
+
true
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
class ModerationApi::Models::Operations::AllowContentRequest
|
|
5
|
+
extend ::Crystalline::MetadataFields::ClassMethods
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
class ModerationApi::Models::Operations::AllowContentRequest
|
|
9
|
+
def id
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def id=(str_)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def body
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def body=(str_)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def project_id
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def project_id=(str_)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
# typed: true
|
|
4
|
+
# frozen_string_literal: true
|
|
5
|
+
|
|
6
|
+
module ModerationApi
|
|
7
|
+
module Models
|
|
8
|
+
module Operations
|
|
9
|
+
|
|
10
|
+
class AllowContentRequestBody
|
|
11
|
+
extend T::Sig
|
|
12
|
+
include Crystalline::MetadataFields
|
|
13
|
+
|
|
14
|
+
# Why the action was taken. Saved with the action and sent in the webhook event.
|
|
15
|
+
field(
|
|
16
|
+
:reason,
|
|
17
|
+
Crystalline::Nilable.new(::String),
|
|
18
|
+
{'format_json': {'letter_case': ::ModerationApi::Utils.field_name("reason")}}
|
|
19
|
+
)
|
|
20
|
+
# The queue the content is reviewed in. Defaults to the project's default queue.
|
|
21
|
+
field(
|
|
22
|
+
:queue_id,
|
|
23
|
+
Crystalline::Nilable.new(::String),
|
|
24
|
+
{'format_json': {'letter_case': ::ModerationApi::Utils.field_name("queueId")}}
|
|
25
|
+
)
|
|
26
|
+
# The user ID or email of the organization member who made the decision. The action is recorded as theirs.
|
|
27
|
+
field(
|
|
28
|
+
:moderator,
|
|
29
|
+
Crystalline::Nilable.new(::String),
|
|
30
|
+
{'format_json': {'letter_case': ::ModerationApi::Utils.field_name("moderator")}}
|
|
31
|
+
)
|
|
32
|
+
# Record an allow or reject decision as a casebook case. Defaults to true when `moderator` is set, else false. Without `moderator`, the case is recorded as System.
|
|
33
|
+
field(
|
|
34
|
+
:create_casebook_case,
|
|
35
|
+
Crystalline::Nilable.new(Crystalline::Boolean.new),
|
|
36
|
+
{'format_json': {'letter_case': ::ModerationApi::Utils.field_name("createCasebookCase")}}
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
sig {
|
|
40
|
+
params(
|
|
41
|
+
reason: T.nilable(::String),
|
|
42
|
+
queue_id: T.nilable(::String),
|
|
43
|
+
moderator: T.nilable(::String),
|
|
44
|
+
create_casebook_case: T.nilable(T::Boolean)
|
|
45
|
+
)
|
|
46
|
+
.void
|
|
47
|
+
}
|
|
48
|
+
def initialize(reason: nil, queue_id: nil, moderator: nil, create_casebook_case: nil)
|
|
49
|
+
@reason = reason
|
|
50
|
+
@queue_id = queue_id
|
|
51
|
+
@moderator = moderator
|
|
52
|
+
@create_casebook_case = create_casebook_case
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
sig { params(other: T.untyped).returns(T::Boolean) }
|
|
56
|
+
def ==(other)
|
|
57
|
+
return false unless other.is_a?(self.class)
|
|
58
|
+
return false unless @reason == other.reason
|
|
59
|
+
return false unless @queue_id == other.queue_id
|
|
60
|
+
return false unless @moderator == other.moderator
|
|
61
|
+
return false unless @create_casebook_case == other.create_casebook_case
|
|
62
|
+
true
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
class ModerationApi::Models::Operations::AllowContentRequestBody
|
|
5
|
+
extend ::Crystalline::MetadataFields::ClassMethods
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
class ModerationApi::Models::Operations::AllowContentRequestBody
|
|
9
|
+
def reason
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def reason=(str_)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def queue_id
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def queue_id=(str_)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def moderator
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def moderator=(str_)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def create_casebook_case
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def create_casebook_case=(str_)
|
|
31
|
+
end
|
|
32
|
+
end
|