moderation_api 2.32.0 → 2.34.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/CHANGELOG.md +16 -0
- data/README.md +1 -1
- data/lib/moderation_api/client.rb +15 -0
- data/lib/moderation_api/models/content_stream_params.rb +29 -0
- data/lib/moderation_api/models/queue_retrieve_response.rb +13 -1
- data/lib/moderation_api/models/webhook_create_params.rb +73 -0
- data/lib/moderation_api/models/webhook_create_response.rb +107 -0
- data/lib/moderation_api/models/webhook_delete_params.rb +22 -0
- data/lib/moderation_api/models/webhook_delete_response.rb +25 -0
- data/lib/moderation_api/models/webhook_list_params.rb +14 -0
- data/lib/moderation_api/models/webhook_list_response.rb +110 -0
- data/lib/moderation_api/models/webhook_retrieve_params.rb +22 -0
- data/lib/moderation_api/models/webhook_retrieve_response.rb +107 -0
- data/lib/moderation_api/models/webhook_secret_retrieve_params.rb +14 -0
- data/lib/moderation_api/models/webhook_secret_retrieve_response.rb +22 -0
- data/lib/moderation_api/models/webhook_update_params.rb +81 -0
- data/lib/moderation_api/models/webhook_update_response.rb +107 -0
- data/lib/moderation_api/models.rb +14 -0
- data/lib/moderation_api/resources/content.rb +42 -0
- data/lib/moderation_api/resources/webhook_secret.rb +34 -0
- data/lib/moderation_api/resources/webhooks.rb +139 -0
- data/lib/moderation_api/version.rb +1 -1
- data/lib/moderation_api.rb +15 -0
- data/rbi/moderation_api/client.rbi +11 -0
- data/rbi/moderation_api/models/content_stream_params.rbi +76 -0
- data/rbi/moderation_api/models/queue_retrieve_response.rbi +18 -0
- data/rbi/moderation_api/models/webhook_create_params.rbi +154 -0
- data/rbi/moderation_api/models/webhook_create_response.rbi +225 -0
- data/rbi/moderation_api/models/webhook_delete_params.rbi +43 -0
- data/rbi/moderation_api/models/webhook_delete_response.rbi +36 -0
- data/rbi/moderation_api/models/webhook_list_params.rbi +32 -0
- data/rbi/moderation_api/models/webhook_list_response.rbi +233 -0
- data/rbi/moderation_api/models/webhook_retrieve_params.rbi +43 -0
- data/rbi/moderation_api/models/webhook_retrieve_response.rbi +225 -0
- data/rbi/moderation_api/models/webhook_secret_retrieve_params.rbi +32 -0
- data/rbi/moderation_api/models/webhook_secret_retrieve_response.rbi +34 -0
- data/rbi/moderation_api/models/webhook_update_params.rbi +178 -0
- data/rbi/moderation_api/models/webhook_update_response.rbi +225 -0
- data/rbi/moderation_api/models.rbi +15 -0
- data/rbi/moderation_api/resources/content.rbi +34 -0
- data/rbi/moderation_api/resources/webhook_secret.rbi +23 -0
- data/rbi/moderation_api/resources/webhooks.rbi +105 -0
- data/sig/moderation_api/client.rbs +6 -0
- data/sig/moderation_api/models/content_stream_params.rbs +36 -0
- data/sig/moderation_api/models/queue_retrieve_response.rbs +14 -0
- data/sig/moderation_api/models/webhook_create_params.rbs +72 -0
- data/sig/moderation_api/models/webhook_create_response.rbs +92 -0
- data/sig/moderation_api/models/webhook_delete_params.rbs +23 -0
- data/sig/moderation_api/models/webhook_delete_response.rbs +15 -0
- data/sig/moderation_api/models/webhook_list_params.rbs +15 -0
- data/sig/moderation_api/models/webhook_list_response.rbs +97 -0
- data/sig/moderation_api/models/webhook_retrieve_params.rbs +23 -0
- data/sig/moderation_api/models/webhook_retrieve_response.rbs +92 -0
- data/sig/moderation_api/models/webhook_secret_retrieve_params.rbs +15 -0
- data/sig/moderation_api/models/webhook_secret_retrieve_response.rbs +13 -0
- data/sig/moderation_api/models/webhook_update_params.rbs +85 -0
- data/sig/moderation_api/models/webhook_update_response.rbs +92 -0
- data/sig/moderation_api/models.rbs +14 -0
- data/sig/moderation_api/resources/content.rbs +5 -0
- data/sig/moderation_api/resources/webhook_secret.rbs +11 -0
- data/sig/moderation_api/resources/webhooks.rbs +38 -0
- metadata +47 -2
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ModerationAPI
|
|
4
|
+
module Models
|
|
5
|
+
# @see ModerationAPI::Resources::WebhookSecret#retrieve
|
|
6
|
+
class WebhookSecretRetrieveResponse < ModerationAPI::Internal::Type::BaseModel
|
|
7
|
+
# @!attribute secret
|
|
8
|
+
# The signing secret for this project. Every webhook delivery is signed with
|
|
9
|
+
# HMAC-SHA256 over the raw JSON body, hex-encoded in the `modapi-signature`
|
|
10
|
+
# header.
|
|
11
|
+
#
|
|
12
|
+
# @return [String]
|
|
13
|
+
required :secret, String
|
|
14
|
+
|
|
15
|
+
# @!method initialize(secret:)
|
|
16
|
+
# Some parameter documentations has been truncated, see
|
|
17
|
+
# {ModerationAPI::Models::WebhookSecretRetrieveResponse} for more details.
|
|
18
|
+
#
|
|
19
|
+
# @param secret [String] The signing secret for this project. Every webhook delivery is signed with HMAC-
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ModerationAPI
|
|
4
|
+
module Models
|
|
5
|
+
# @see ModerationAPI::Resources::Webhooks#update
|
|
6
|
+
class WebhookUpdateParams < ModerationAPI::Internal::Type::BaseModel
|
|
7
|
+
extend ModerationAPI::Internal::Type::RequestParameters::Converter
|
|
8
|
+
include ModerationAPI::Internal::Type::RequestParameters
|
|
9
|
+
|
|
10
|
+
# @!attribute id
|
|
11
|
+
# The ID of the webhook to update.
|
|
12
|
+
#
|
|
13
|
+
# @return [String]
|
|
14
|
+
required :id, String
|
|
15
|
+
|
|
16
|
+
# @!attribute description
|
|
17
|
+
# The webhook's description
|
|
18
|
+
#
|
|
19
|
+
# @return [String, nil]
|
|
20
|
+
optional :description, String, nil?: true
|
|
21
|
+
|
|
22
|
+
# @!attribute event_types
|
|
23
|
+
# Event types this webhook subscribes to. One webhook URL receives all events you
|
|
24
|
+
# list here.
|
|
25
|
+
#
|
|
26
|
+
# @return [Array<Symbol, ModerationAPI::Models::WebhookUpdateParams::EventType>, nil]
|
|
27
|
+
optional :event_types,
|
|
28
|
+
-> {
|
|
29
|
+
ModerationAPI::Internal::Type::ArrayOf[enum: ModerationAPI::WebhookUpdateParams::EventType]
|
|
30
|
+
},
|
|
31
|
+
api_name: :eventTypes
|
|
32
|
+
|
|
33
|
+
# @!attribute name
|
|
34
|
+
# The webhook's name, used to identify it in the dashboard
|
|
35
|
+
#
|
|
36
|
+
# @return [String, nil]
|
|
37
|
+
optional :name, String
|
|
38
|
+
|
|
39
|
+
# @!attribute url
|
|
40
|
+
# The webhook's URL. We'll call this URL when an event occurs.
|
|
41
|
+
#
|
|
42
|
+
# @return [String, nil]
|
|
43
|
+
optional :url, String
|
|
44
|
+
|
|
45
|
+
# @!method initialize(id:, description: nil, event_types: nil, name: nil, url: nil, request_options: {})
|
|
46
|
+
# Some parameter documentations has been truncated, see
|
|
47
|
+
# {ModerationAPI::Models::WebhookUpdateParams} for more details.
|
|
48
|
+
#
|
|
49
|
+
# @param id [String] The ID of the webhook to update.
|
|
50
|
+
#
|
|
51
|
+
# @param description [String, nil] The webhook's description
|
|
52
|
+
#
|
|
53
|
+
# @param event_types [Array<Symbol, ModerationAPI::Models::WebhookUpdateParams::EventType>] Event types this webhook subscribes to. One webhook URL receives all events you
|
|
54
|
+
#
|
|
55
|
+
# @param name [String] The webhook's name, used to identify it in the dashboard
|
|
56
|
+
#
|
|
57
|
+
# @param url [String] The webhook's URL. We'll call this URL when an event occurs.
|
|
58
|
+
#
|
|
59
|
+
# @param request_options [ModerationAPI::RequestOptions, Hash{Symbol=>Object}]
|
|
60
|
+
|
|
61
|
+
module EventType
|
|
62
|
+
extend ModerationAPI::Internal::Type::Enum
|
|
63
|
+
|
|
64
|
+
QUEUE_ITEM_NEW = :QUEUE_ITEM_NEW
|
|
65
|
+
QUEUE_ITEM_COMPLETED = :QUEUE_ITEM_COMPLETED
|
|
66
|
+
QUEUE_ITEM_ACTION = :QUEUE_ITEM_ACTION
|
|
67
|
+
QUEUE_ITEM_REJECTED = :QUEUE_ITEM_REJECTED
|
|
68
|
+
QUEUE_ITEM_ALLOWED = :QUEUE_ITEM_ALLOWED
|
|
69
|
+
AUTHOR_BLOCKED = :AUTHOR_BLOCKED
|
|
70
|
+
AUTHOR_UNBLOCKED = :AUTHOR_UNBLOCKED
|
|
71
|
+
AUTHOR_SUSPENDED = :AUTHOR_SUSPENDED
|
|
72
|
+
AUTHOR_UPDATED = :AUTHOR_UPDATED
|
|
73
|
+
AUTHOR_TRUST_LEVEL_CHANGED = :AUTHOR_TRUST_LEVEL_CHANGED
|
|
74
|
+
AUTHOR_ACTION = :AUTHOR_ACTION
|
|
75
|
+
|
|
76
|
+
# @!method self.values
|
|
77
|
+
# @return [Array<Symbol>]
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ModerationAPI
|
|
4
|
+
module Models
|
|
5
|
+
# @see ModerationAPI::Resources::Webhooks#update
|
|
6
|
+
class WebhookUpdateResponse < ModerationAPI::Internal::Type::BaseModel
|
|
7
|
+
# @!attribute id
|
|
8
|
+
# The ID of the webhook.
|
|
9
|
+
#
|
|
10
|
+
# @return [String]
|
|
11
|
+
required :id, String
|
|
12
|
+
|
|
13
|
+
# @!attribute created_at
|
|
14
|
+
# The date the webhook was created.
|
|
15
|
+
#
|
|
16
|
+
# @return [String]
|
|
17
|
+
required :created_at, String, api_name: :createdAt
|
|
18
|
+
|
|
19
|
+
# @!attribute event_types
|
|
20
|
+
# Event types this webhook subscribes to. Empty for legacy v1 webhooks, which
|
|
21
|
+
# subscribe via their single deprecated `type` instead.
|
|
22
|
+
#
|
|
23
|
+
# @return [Array<Symbol, ModerationAPI::Models::WebhookUpdateResponse::EventType>]
|
|
24
|
+
required :event_types,
|
|
25
|
+
-> { ModerationAPI::Internal::Type::ArrayOf[enum: ModerationAPI::Models::WebhookUpdateResponse::EventType] },
|
|
26
|
+
api_name: :eventTypes
|
|
27
|
+
|
|
28
|
+
# @!attribute name
|
|
29
|
+
# The webhook's name.
|
|
30
|
+
#
|
|
31
|
+
# @return [String]
|
|
32
|
+
required :name, String
|
|
33
|
+
|
|
34
|
+
# @!attribute payload_version
|
|
35
|
+
# Payload envelope version. V2 is the Stripe-style envelope; V1 is the legacy flat
|
|
36
|
+
# shape and is read-only via this API.
|
|
37
|
+
#
|
|
38
|
+
# @return [Symbol, ModerationAPI::Models::WebhookUpdateResponse::PayloadVersion]
|
|
39
|
+
required :payload_version,
|
|
40
|
+
enum: -> { ModerationAPI::Models::WebhookUpdateResponse::PayloadVersion },
|
|
41
|
+
api_name: :payloadVersion
|
|
42
|
+
|
|
43
|
+
# @!attribute url
|
|
44
|
+
# The URL we call when a subscribed event occurs.
|
|
45
|
+
#
|
|
46
|
+
# @return [String]
|
|
47
|
+
required :url, String
|
|
48
|
+
|
|
49
|
+
# @!attribute description
|
|
50
|
+
# The webhook's description.
|
|
51
|
+
#
|
|
52
|
+
# @return [String, nil]
|
|
53
|
+
optional :description, String, nil?: true
|
|
54
|
+
|
|
55
|
+
# @!method initialize(id:, created_at:, event_types:, name:, payload_version:, url:, description: nil)
|
|
56
|
+
# Some parameter documentations has been truncated, see
|
|
57
|
+
# {ModerationAPI::Models::WebhookUpdateResponse} for more details.
|
|
58
|
+
#
|
|
59
|
+
# @param id [String] The ID of the webhook.
|
|
60
|
+
#
|
|
61
|
+
# @param created_at [String] The date the webhook was created.
|
|
62
|
+
#
|
|
63
|
+
# @param event_types [Array<Symbol, ModerationAPI::Models::WebhookUpdateResponse::EventType>] Event types this webhook subscribes to. Empty for legacy v1 webhooks, which subs
|
|
64
|
+
#
|
|
65
|
+
# @param name [String] The webhook's name.
|
|
66
|
+
#
|
|
67
|
+
# @param payload_version [Symbol, ModerationAPI::Models::WebhookUpdateResponse::PayloadVersion] Payload envelope version. V2 is the Stripe-style envelope; V1 is the legacy flat
|
|
68
|
+
#
|
|
69
|
+
# @param url [String] The URL we call when a subscribed event occurs.
|
|
70
|
+
#
|
|
71
|
+
# @param description [String, nil] The webhook's description.
|
|
72
|
+
|
|
73
|
+
module EventType
|
|
74
|
+
extend ModerationAPI::Internal::Type::Enum
|
|
75
|
+
|
|
76
|
+
QUEUE_ITEM_NEW = :QUEUE_ITEM_NEW
|
|
77
|
+
QUEUE_ITEM_COMPLETED = :QUEUE_ITEM_COMPLETED
|
|
78
|
+
QUEUE_ITEM_ACTION = :QUEUE_ITEM_ACTION
|
|
79
|
+
QUEUE_ITEM_REJECTED = :QUEUE_ITEM_REJECTED
|
|
80
|
+
QUEUE_ITEM_ALLOWED = :QUEUE_ITEM_ALLOWED
|
|
81
|
+
AUTHOR_BLOCKED = :AUTHOR_BLOCKED
|
|
82
|
+
AUTHOR_UNBLOCKED = :AUTHOR_UNBLOCKED
|
|
83
|
+
AUTHOR_SUSPENDED = :AUTHOR_SUSPENDED
|
|
84
|
+
AUTHOR_UPDATED = :AUTHOR_UPDATED
|
|
85
|
+
AUTHOR_TRUST_LEVEL_CHANGED = :AUTHOR_TRUST_LEVEL_CHANGED
|
|
86
|
+
AUTHOR_ACTION = :AUTHOR_ACTION
|
|
87
|
+
|
|
88
|
+
# @!method self.values
|
|
89
|
+
# @return [Array<Symbol>]
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Payload envelope version. V2 is the Stripe-style envelope; V1 is the legacy flat
|
|
93
|
+
# shape and is read-only via this API.
|
|
94
|
+
#
|
|
95
|
+
# @see ModerationAPI::Models::WebhookUpdateResponse#payload_version
|
|
96
|
+
module PayloadVersion
|
|
97
|
+
extend ModerationAPI::Internal::Type::Enum
|
|
98
|
+
|
|
99
|
+
V1 = :V1
|
|
100
|
+
V2 = :V2
|
|
101
|
+
|
|
102
|
+
# @!method self.values
|
|
103
|
+
# @return [Array<Symbol>]
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
@@ -70,6 +70,8 @@ module ModerationAPI
|
|
|
70
70
|
|
|
71
71
|
AuthRetrieveParams = ModerationAPI::Models::AuthRetrieveParams
|
|
72
72
|
|
|
73
|
+
ContentStreamParams = ModerationAPI::Models::ContentStreamParams
|
|
74
|
+
|
|
73
75
|
ContentSubmitParams = ModerationAPI::Models::ContentSubmitParams
|
|
74
76
|
|
|
75
77
|
Queue = ModerationAPI::Models::Queue
|
|
@@ -78,8 +80,20 @@ module ModerationAPI
|
|
|
78
80
|
|
|
79
81
|
QueueRetrieveParams = ModerationAPI::Models::QueueRetrieveParams
|
|
80
82
|
|
|
83
|
+
WebhookCreateParams = ModerationAPI::Models::WebhookCreateParams
|
|
84
|
+
|
|
85
|
+
WebhookDeleteParams = ModerationAPI::Models::WebhookDeleteParams
|
|
86
|
+
|
|
81
87
|
WebhookEvent = ModerationAPI::Models::WebhookEvent
|
|
82
88
|
|
|
89
|
+
WebhookListParams = ModerationAPI::Models::WebhookListParams
|
|
90
|
+
|
|
91
|
+
WebhookRetrieveParams = ModerationAPI::Models::WebhookRetrieveParams
|
|
92
|
+
|
|
93
|
+
WebhookSecretRetrieveParams = ModerationAPI::Models::WebhookSecretRetrieveParams
|
|
94
|
+
|
|
95
|
+
WebhookUpdateParams = ModerationAPI::Models::WebhookUpdateParams
|
|
96
|
+
|
|
83
97
|
Wordlist = ModerationAPI::Models::Wordlist
|
|
84
98
|
|
|
85
99
|
WordlistGetEmbeddingStatusParams = ModerationAPI::Models::WordlistGetEmbeddingStatusParams
|
|
@@ -3,6 +3,48 @@
|
|
|
3
3
|
module ModerationAPI
|
|
4
4
|
module Resources
|
|
5
5
|
class Content
|
|
6
|
+
# Open a WebSocket to moderate live voice/call audio in real time. Speech is
|
|
7
|
+
# transcribed and each finalized utterance is moderated by your enabled text
|
|
8
|
+
# policies; you receive a verdict per utterance as it's spoken.
|
|
9
|
+
#
|
|
10
|
+
# **This is a WebSocket upgrade, not a regular HTTP call.** The request body below
|
|
11
|
+
# documents the frames you _send_ over the socket; the `101` response documents
|
|
12
|
+
# the events you _receive_.
|
|
13
|
+
#
|
|
14
|
+
# - **Auth:** `Authorization: Bearer <api_key>` on the upgrade. A missing/invalid
|
|
15
|
+
# key closes `4401`; voice not enabled on the plan/channel closes `4403`.
|
|
16
|
+
# - **Subprotocol:** request `moderationapi.v1`.
|
|
17
|
+
# - **Flow:** send one `start` frame, then `media` frames as audio arrives, then
|
|
18
|
+
# `stop` (or disconnect). You receive `session.started`, `utterance.final` per
|
|
19
|
+
# utterance, optional `utterance.partial`/`warning`, and `session.ended`.
|
|
20
|
+
# - **Close codes:** `1000` normal · `1011` server error · `4400` bad request ·
|
|
21
|
+
# `4401` auth failed · `4403` voice not enabled · `4429` concurrency limit.
|
|
22
|
+
#
|
|
23
|
+
# See the
|
|
24
|
+
# [Real-time voice guide](https://docs.moderationapi.com/content-moderation/real-time-voice)
|
|
25
|
+
# for the full walkthrough and code examples.
|
|
26
|
+
#
|
|
27
|
+
# @overload stream(sec_web_socket_protocol:, request_options: {})
|
|
28
|
+
#
|
|
29
|
+
# @param sec_web_socket_protocol [Symbol, ModerationAPI::Models::ContentStreamParams::SecWebSocketProtocol] Requested subprotocol.
|
|
30
|
+
#
|
|
31
|
+
# @param request_options [ModerationAPI::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
32
|
+
#
|
|
33
|
+
# @return [nil]
|
|
34
|
+
#
|
|
35
|
+
# @see ModerationAPI::Models::ContentStreamParams
|
|
36
|
+
def stream(params)
|
|
37
|
+
parsed, options = ModerationAPI::ContentStreamParams.dump_request(params)
|
|
38
|
+
path = @client.base_url_overridden? ? "stream" : "wss://voice.moderationapi.com/v1/stream"
|
|
39
|
+
@client.request(
|
|
40
|
+
method: :get,
|
|
41
|
+
path: path,
|
|
42
|
+
headers: parsed.transform_keys(sec_web_socket_protocol: "sec-websocket-protocol"),
|
|
43
|
+
model: NilClass,
|
|
44
|
+
options: options
|
|
45
|
+
)
|
|
46
|
+
end
|
|
47
|
+
|
|
6
48
|
# Some parameter documentations has been truncated, see
|
|
7
49
|
# {ModerationAPI::Models::ContentSubmitParams} for more details.
|
|
8
50
|
#
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ModerationAPI
|
|
4
|
+
module Resources
|
|
5
|
+
class WebhookSecret
|
|
6
|
+
# Get the signing secret used to sign webhook deliveries for this project,
|
|
7
|
+
# creating one if none exists yet. Verify deliveries by comparing the
|
|
8
|
+
# `modapi-signature` header to HMAC-SHA256(raw request body, secret) hex-encoded.
|
|
9
|
+
#
|
|
10
|
+
# @overload retrieve(request_options: {})
|
|
11
|
+
#
|
|
12
|
+
# @param request_options [ModerationAPI::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
13
|
+
#
|
|
14
|
+
# @return [ModerationAPI::Models::WebhookSecretRetrieveResponse]
|
|
15
|
+
#
|
|
16
|
+
# @see ModerationAPI::Models::WebhookSecretRetrieveParams
|
|
17
|
+
def retrieve(params = {})
|
|
18
|
+
@client.request(
|
|
19
|
+
method: :get,
|
|
20
|
+
path: "webhook-secret",
|
|
21
|
+
model: ModerationAPI::Models::WebhookSecretRetrieveResponse,
|
|
22
|
+
options: params[:request_options]
|
|
23
|
+
)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# @api private
|
|
27
|
+
#
|
|
28
|
+
# @param client [ModerationAPI::Client]
|
|
29
|
+
def initialize(client:)
|
|
30
|
+
@client = client
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ModerationAPI
|
|
4
|
+
module Resources
|
|
5
|
+
class Webhooks
|
|
6
|
+
# Some parameter documentations has been truncated, see
|
|
7
|
+
# {ModerationAPI::Models::WebhookCreateParams} for more details.
|
|
8
|
+
#
|
|
9
|
+
# Create a webhook subscribed to one or more event types. Deliveries use the v2
|
|
10
|
+
# envelope and are signed with the project signing secret (see the signing secret
|
|
11
|
+
# endpoint).
|
|
12
|
+
#
|
|
13
|
+
# @overload create(event_types:, name:, url:, description: nil, request_options: {})
|
|
14
|
+
#
|
|
15
|
+
# @param event_types [Array<Symbol, ModerationAPI::Models::WebhookCreateParams::EventType>] Event types this webhook subscribes to. One webhook URL receives all events you
|
|
16
|
+
#
|
|
17
|
+
# @param name [String] The webhook's name, used to identify it in the dashboard
|
|
18
|
+
#
|
|
19
|
+
# @param url [String] The webhook's URL. We'll call this URL when an event occurs.
|
|
20
|
+
#
|
|
21
|
+
# @param description [String, nil] The webhook's description
|
|
22
|
+
#
|
|
23
|
+
# @param request_options [ModerationAPI::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
24
|
+
#
|
|
25
|
+
# @return [ModerationAPI::Models::WebhookCreateResponse]
|
|
26
|
+
#
|
|
27
|
+
# @see ModerationAPI::Models::WebhookCreateParams
|
|
28
|
+
def create(params)
|
|
29
|
+
parsed, options = ModerationAPI::WebhookCreateParams.dump_request(params)
|
|
30
|
+
@client.request(
|
|
31
|
+
method: :post,
|
|
32
|
+
path: "webhooks",
|
|
33
|
+
body: parsed,
|
|
34
|
+
model: ModerationAPI::Models::WebhookCreateResponse,
|
|
35
|
+
options: options
|
|
36
|
+
)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Get a webhook by ID.
|
|
40
|
+
#
|
|
41
|
+
# @overload retrieve(id, request_options: {})
|
|
42
|
+
#
|
|
43
|
+
# @param id [String] The ID of the webhook to get.
|
|
44
|
+
#
|
|
45
|
+
# @param request_options [ModerationAPI::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
46
|
+
#
|
|
47
|
+
# @return [ModerationAPI::Models::WebhookRetrieveResponse]
|
|
48
|
+
#
|
|
49
|
+
# @see ModerationAPI::Models::WebhookRetrieveParams
|
|
50
|
+
def retrieve(id, params = {})
|
|
51
|
+
@client.request(
|
|
52
|
+
method: :get,
|
|
53
|
+
path: ["webhooks/%1$s", id],
|
|
54
|
+
model: ModerationAPI::Models::WebhookRetrieveResponse,
|
|
55
|
+
options: params[:request_options]
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Some parameter documentations has been truncated, see
|
|
60
|
+
# {ModerationAPI::Models::WebhookUpdateParams} for more details.
|
|
61
|
+
#
|
|
62
|
+
# Update a webhook. Legacy v1 webhooks are read-only: delete them and create a new
|
|
63
|
+
# webhook instead.
|
|
64
|
+
#
|
|
65
|
+
# @overload update(id, description: nil, event_types: nil, name: nil, url: nil, request_options: {})
|
|
66
|
+
#
|
|
67
|
+
# @param id [String] The ID of the webhook to update.
|
|
68
|
+
#
|
|
69
|
+
# @param description [String, nil] The webhook's description
|
|
70
|
+
#
|
|
71
|
+
# @param event_types [Array<Symbol, ModerationAPI::Models::WebhookUpdateParams::EventType>] Event types this webhook subscribes to. One webhook URL receives all events you
|
|
72
|
+
#
|
|
73
|
+
# @param name [String] The webhook's name, used to identify it in the dashboard
|
|
74
|
+
#
|
|
75
|
+
# @param url [String] The webhook's URL. We'll call this URL when an event occurs.
|
|
76
|
+
#
|
|
77
|
+
# @param request_options [ModerationAPI::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
78
|
+
#
|
|
79
|
+
# @return [ModerationAPI::Models::WebhookUpdateResponse]
|
|
80
|
+
#
|
|
81
|
+
# @see ModerationAPI::Models::WebhookUpdateParams
|
|
82
|
+
def update(id, params = {})
|
|
83
|
+
parsed, options = ModerationAPI::WebhookUpdateParams.dump_request(params)
|
|
84
|
+
@client.request(
|
|
85
|
+
method: :put,
|
|
86
|
+
path: ["webhooks/%1$s", id],
|
|
87
|
+
body: parsed,
|
|
88
|
+
model: ModerationAPI::Models::WebhookUpdateResponse,
|
|
89
|
+
options: options
|
|
90
|
+
)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# List all webhooks for the authenticated project.
|
|
94
|
+
#
|
|
95
|
+
# @overload list(request_options: {})
|
|
96
|
+
#
|
|
97
|
+
# @param request_options [ModerationAPI::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
98
|
+
#
|
|
99
|
+
# @return [Array<ModerationAPI::Models::WebhookListResponseItem>]
|
|
100
|
+
#
|
|
101
|
+
# @see ModerationAPI::Models::WebhookListParams
|
|
102
|
+
def list(params = {})
|
|
103
|
+
@client.request(
|
|
104
|
+
method: :get,
|
|
105
|
+
path: "webhooks",
|
|
106
|
+
model: ModerationAPI::Internal::Type::ArrayOf[ModerationAPI::Models::WebhookListResponseItem],
|
|
107
|
+
options: params[:request_options]
|
|
108
|
+
)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Delete a webhook.
|
|
112
|
+
#
|
|
113
|
+
# @overload delete(id, request_options: {})
|
|
114
|
+
#
|
|
115
|
+
# @param id [String] The ID of the webhook to delete.
|
|
116
|
+
#
|
|
117
|
+
# @param request_options [ModerationAPI::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
118
|
+
#
|
|
119
|
+
# @return [ModerationAPI::Models::WebhookDeleteResponse]
|
|
120
|
+
#
|
|
121
|
+
# @see ModerationAPI::Models::WebhookDeleteParams
|
|
122
|
+
def delete(id, params = {})
|
|
123
|
+
@client.request(
|
|
124
|
+
method: :delete,
|
|
125
|
+
path: ["webhooks/%1$s", id],
|
|
126
|
+
model: ModerationAPI::Models::WebhookDeleteResponse,
|
|
127
|
+
options: params[:request_options]
|
|
128
|
+
)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# @api private
|
|
132
|
+
#
|
|
133
|
+
# @param client [ModerationAPI::Client]
|
|
134
|
+
def initialize(client:)
|
|
135
|
+
@client = client
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
data/lib/moderation_api.rb
CHANGED
|
@@ -82,6 +82,7 @@ require_relative "moderation_api/models/author_update_params"
|
|
|
82
82
|
require_relative "moderation_api/models/author_update_response"
|
|
83
83
|
require_relative "moderation_api/models/auth_retrieve_params"
|
|
84
84
|
require_relative "moderation_api/models/auth_retrieve_response"
|
|
85
|
+
require_relative "moderation_api/models/content_stream_params"
|
|
85
86
|
require_relative "moderation_api/models/content_submit_params"
|
|
86
87
|
require_relative "moderation_api/models/content_submit_response"
|
|
87
88
|
require_relative "moderation_api/models/queue/item_list_params"
|
|
@@ -94,7 +95,19 @@ require_relative "moderation_api/models/queue_get_stats_params"
|
|
|
94
95
|
require_relative "moderation_api/models/queue_get_stats_response"
|
|
95
96
|
require_relative "moderation_api/models/queue_retrieve_params"
|
|
96
97
|
require_relative "moderation_api/models/queue_retrieve_response"
|
|
98
|
+
require_relative "moderation_api/models/webhook_create_params"
|
|
99
|
+
require_relative "moderation_api/models/webhook_create_response"
|
|
100
|
+
require_relative "moderation_api/models/webhook_delete_params"
|
|
101
|
+
require_relative "moderation_api/models/webhook_delete_response"
|
|
97
102
|
require_relative "moderation_api/models/webhook_event"
|
|
103
|
+
require_relative "moderation_api/models/webhook_list_params"
|
|
104
|
+
require_relative "moderation_api/models/webhook_list_response"
|
|
105
|
+
require_relative "moderation_api/models/webhook_retrieve_params"
|
|
106
|
+
require_relative "moderation_api/models/webhook_retrieve_response"
|
|
107
|
+
require_relative "moderation_api/models/webhook_secret_retrieve_params"
|
|
108
|
+
require_relative "moderation_api/models/webhook_secret_retrieve_response"
|
|
109
|
+
require_relative "moderation_api/models/webhook_update_params"
|
|
110
|
+
require_relative "moderation_api/models/webhook_update_response"
|
|
98
111
|
require_relative "moderation_api/models/wordlist/word_add_params"
|
|
99
112
|
require_relative "moderation_api/models/wordlist/word_add_response"
|
|
100
113
|
require_relative "moderation_api/models/wordlist/word_remove_params"
|
|
@@ -116,5 +129,7 @@ require_relative "moderation_api/resources/authors"
|
|
|
116
129
|
require_relative "moderation_api/resources/content"
|
|
117
130
|
require_relative "moderation_api/resources/queue"
|
|
118
131
|
require_relative "moderation_api/resources/queue/items"
|
|
132
|
+
require_relative "moderation_api/resources/webhooks"
|
|
133
|
+
require_relative "moderation_api/resources/webhook_secret"
|
|
119
134
|
require_relative "moderation_api/resources/wordlist"
|
|
120
135
|
require_relative "moderation_api/resources/wordlist/words"
|
|
@@ -34,11 +34,22 @@ module ModerationAPI
|
|
|
34
34
|
sig { returns(ModerationAPI::Resources::Wordlist) }
|
|
35
35
|
attr_reader :wordlist
|
|
36
36
|
|
|
37
|
+
sig { returns(ModerationAPI::Resources::Webhooks) }
|
|
38
|
+
attr_reader :webhooks
|
|
39
|
+
|
|
40
|
+
sig { returns(ModerationAPI::Resources::WebhookSecret) }
|
|
41
|
+
attr_reader :webhook_secret
|
|
42
|
+
|
|
37
43
|
# @api private
|
|
38
44
|
sig { override.returns(T::Hash[String, String]) }
|
|
39
45
|
private def auth_headers
|
|
40
46
|
end
|
|
41
47
|
|
|
48
|
+
# @api private
|
|
49
|
+
sig { returns(T::Boolean) }
|
|
50
|
+
def base_url_overridden?
|
|
51
|
+
end
|
|
52
|
+
|
|
42
53
|
# Creates and returns a new client for interacting with the API.
|
|
43
54
|
sig do
|
|
44
55
|
params(
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module ModerationAPI
|
|
4
|
+
module Models
|
|
5
|
+
class ContentStreamParams < ModerationAPI::Internal::Type::BaseModel
|
|
6
|
+
extend ModerationAPI::Internal::Type::RequestParameters::Converter
|
|
7
|
+
include ModerationAPI::Internal::Type::RequestParameters
|
|
8
|
+
|
|
9
|
+
OrHash =
|
|
10
|
+
T.type_alias do
|
|
11
|
+
T.any(
|
|
12
|
+
ModerationAPI::ContentStreamParams,
|
|
13
|
+
ModerationAPI::Internal::AnyHash
|
|
14
|
+
)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
sig do
|
|
18
|
+
returns(
|
|
19
|
+
ModerationAPI::ContentStreamParams::SecWebSocketProtocol::OrSymbol
|
|
20
|
+
)
|
|
21
|
+
end
|
|
22
|
+
attr_accessor :sec_web_socket_protocol
|
|
23
|
+
|
|
24
|
+
sig do
|
|
25
|
+
params(
|
|
26
|
+
sec_web_socket_protocol:
|
|
27
|
+
ModerationAPI::ContentStreamParams::SecWebSocketProtocol::OrSymbol,
|
|
28
|
+
request_options: ModerationAPI::RequestOptions::OrHash
|
|
29
|
+
).returns(T.attached_class)
|
|
30
|
+
end
|
|
31
|
+
def self.new(sec_web_socket_protocol:, request_options: {})
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
sig do
|
|
35
|
+
override.returns(
|
|
36
|
+
{
|
|
37
|
+
sec_web_socket_protocol:
|
|
38
|
+
ModerationAPI::ContentStreamParams::SecWebSocketProtocol::OrSymbol,
|
|
39
|
+
request_options: ModerationAPI::RequestOptions
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
def to_hash
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
module SecWebSocketProtocol
|
|
47
|
+
extend ModerationAPI::Internal::Type::Enum
|
|
48
|
+
|
|
49
|
+
TaggedSymbol =
|
|
50
|
+
T.type_alias do
|
|
51
|
+
T.all(
|
|
52
|
+
Symbol,
|
|
53
|
+
ModerationAPI::ContentStreamParams::SecWebSocketProtocol
|
|
54
|
+
)
|
|
55
|
+
end
|
|
56
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
|
57
|
+
|
|
58
|
+
MODERATIONAPI_V1 =
|
|
59
|
+
T.let(
|
|
60
|
+
:"moderationapi.v1",
|
|
61
|
+
ModerationAPI::ContentStreamParams::SecWebSocketProtocol::TaggedSymbol
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
sig do
|
|
65
|
+
override.returns(
|
|
66
|
+
T::Array[
|
|
67
|
+
ModerationAPI::ContentStreamParams::SecWebSocketProtocol::TaggedSymbol
|
|
68
|
+
]
|
|
69
|
+
)
|
|
70
|
+
end
|
|
71
|
+
def self.values
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -260,6 +260,12 @@ module ModerationAPI
|
|
|
260
260
|
sig { params(languages: T::Array[String]).void }
|
|
261
261
|
attr_writer :languages
|
|
262
262
|
|
|
263
|
+
sig { returns(T.nilable(Integer)) }
|
|
264
|
+
attr_reader :max_severity
|
|
265
|
+
|
|
266
|
+
sig { params(max_severity: Integer).void }
|
|
267
|
+
attr_writer :max_severity
|
|
268
|
+
|
|
263
269
|
sig do
|
|
264
270
|
returns(
|
|
265
271
|
T.nilable(
|
|
@@ -281,6 +287,12 @@ module ModerationAPI
|
|
|
281
287
|
end
|
|
282
288
|
attr_writer :media_types
|
|
283
289
|
|
|
290
|
+
sig { returns(T.nilable(Integer)) }
|
|
291
|
+
attr_reader :min_severity
|
|
292
|
+
|
|
293
|
+
sig { params(min_severity: Integer).void }
|
|
294
|
+
attr_writer :min_severity
|
|
295
|
+
|
|
284
296
|
sig do
|
|
285
297
|
returns(
|
|
286
298
|
T.nilable(
|
|
@@ -358,10 +370,12 @@ module ModerationAPI
|
|
|
358
370
|
ModerationAPI::Models::QueueRetrieveResponse::Queue::Filter::IsFlagged::OrSymbol,
|
|
359
371
|
labels: T::Array[String],
|
|
360
372
|
languages: T::Array[String],
|
|
373
|
+
max_severity: Integer,
|
|
361
374
|
media_types:
|
|
362
375
|
T::Array[
|
|
363
376
|
ModerationAPI::Models::QueueRetrieveResponse::Queue::Filter::MediaType::OrSymbol
|
|
364
377
|
],
|
|
378
|
+
min_severity: Integer,
|
|
365
379
|
recommendation_actions:
|
|
366
380
|
T::Array[
|
|
367
381
|
ModerationAPI::Models::QueueRetrieveResponse::Queue::Filter::RecommendationAction::OrSymbol
|
|
@@ -388,7 +402,9 @@ module ModerationAPI
|
|
|
388
402
|
is_flagged: nil,
|
|
389
403
|
labels: nil,
|
|
390
404
|
languages: nil,
|
|
405
|
+
max_severity: nil,
|
|
391
406
|
media_types: nil,
|
|
407
|
+
min_severity: nil,
|
|
392
408
|
recommendation_actions: nil,
|
|
393
409
|
search: nil,
|
|
394
410
|
within: nil,
|
|
@@ -424,10 +440,12 @@ module ModerationAPI
|
|
|
424
440
|
ModerationAPI::Models::QueueRetrieveResponse::Queue::Filter::IsFlagged::TaggedSymbol,
|
|
425
441
|
labels: T::Array[String],
|
|
426
442
|
languages: T::Array[String],
|
|
443
|
+
max_severity: Integer,
|
|
427
444
|
media_types:
|
|
428
445
|
T::Array[
|
|
429
446
|
ModerationAPI::Models::QueueRetrieveResponse::Queue::Filter::MediaType::TaggedSymbol
|
|
430
447
|
],
|
|
448
|
+
min_severity: Integer,
|
|
431
449
|
recommendation_actions:
|
|
432
450
|
T::Array[
|
|
433
451
|
ModerationAPI::Models::QueueRetrieveResponse::Queue::Filter::RecommendationAction::TaggedSymbol
|