moderation_api 2.33.0 → 2.35.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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/README.md +1 -1
  4. data/lib/moderation_api/client.rb +15 -0
  5. data/lib/moderation_api/models/content_stream_params.rb +29 -0
  6. data/lib/moderation_api/models/content_submit_response.rb +119 -1
  7. data/lib/moderation_api/models/webhook_create_params.rb +73 -0
  8. data/lib/moderation_api/models/webhook_create_response.rb +107 -0
  9. data/lib/moderation_api/models/webhook_delete_params.rb +22 -0
  10. data/lib/moderation_api/models/webhook_delete_response.rb +25 -0
  11. data/lib/moderation_api/models/webhook_list_params.rb +14 -0
  12. data/lib/moderation_api/models/webhook_list_response.rb +110 -0
  13. data/lib/moderation_api/models/webhook_retrieve_params.rb +22 -0
  14. data/lib/moderation_api/models/webhook_retrieve_response.rb +107 -0
  15. data/lib/moderation_api/models/webhook_secret_retrieve_params.rb +14 -0
  16. data/lib/moderation_api/models/webhook_secret_retrieve_response.rb +22 -0
  17. data/lib/moderation_api/models/webhook_update_params.rb +81 -0
  18. data/lib/moderation_api/models/webhook_update_response.rb +107 -0
  19. data/lib/moderation_api/models.rb +14 -0
  20. data/lib/moderation_api/resources/content.rb +42 -0
  21. data/lib/moderation_api/resources/webhook_secret.rb +34 -0
  22. data/lib/moderation_api/resources/webhooks.rb +139 -0
  23. data/lib/moderation_api/version.rb +1 -1
  24. data/lib/moderation_api.rb +15 -0
  25. data/rbi/moderation_api/client.rbi +11 -0
  26. data/rbi/moderation_api/models/content_stream_params.rbi +76 -0
  27. data/rbi/moderation_api/models/content_submit_response.rbi +226 -0
  28. data/rbi/moderation_api/models/webhook_create_params.rbi +154 -0
  29. data/rbi/moderation_api/models/webhook_create_response.rbi +225 -0
  30. data/rbi/moderation_api/models/webhook_delete_params.rbi +43 -0
  31. data/rbi/moderation_api/models/webhook_delete_response.rbi +36 -0
  32. data/rbi/moderation_api/models/webhook_list_params.rbi +32 -0
  33. data/rbi/moderation_api/models/webhook_list_response.rbi +233 -0
  34. data/rbi/moderation_api/models/webhook_retrieve_params.rbi +43 -0
  35. data/rbi/moderation_api/models/webhook_retrieve_response.rbi +225 -0
  36. data/rbi/moderation_api/models/webhook_secret_retrieve_params.rbi +32 -0
  37. data/rbi/moderation_api/models/webhook_secret_retrieve_response.rbi +34 -0
  38. data/rbi/moderation_api/models/webhook_update_params.rbi +178 -0
  39. data/rbi/moderation_api/models/webhook_update_response.rbi +225 -0
  40. data/rbi/moderation_api/models.rbi +15 -0
  41. data/rbi/moderation_api/resources/content.rbi +34 -0
  42. data/rbi/moderation_api/resources/webhook_secret.rbi +23 -0
  43. data/rbi/moderation_api/resources/webhooks.rbi +105 -0
  44. data/sig/moderation_api/client.rbs +6 -0
  45. data/sig/moderation_api/models/content_stream_params.rbs +36 -0
  46. data/sig/moderation_api/models/content_submit_response.rbs +72 -0
  47. data/sig/moderation_api/models/webhook_create_params.rbs +72 -0
  48. data/sig/moderation_api/models/webhook_create_response.rbs +92 -0
  49. data/sig/moderation_api/models/webhook_delete_params.rbs +23 -0
  50. data/sig/moderation_api/models/webhook_delete_response.rbs +15 -0
  51. data/sig/moderation_api/models/webhook_list_params.rbs +15 -0
  52. data/sig/moderation_api/models/webhook_list_response.rbs +97 -0
  53. data/sig/moderation_api/models/webhook_retrieve_params.rbs +23 -0
  54. data/sig/moderation_api/models/webhook_retrieve_response.rbs +92 -0
  55. data/sig/moderation_api/models/webhook_secret_retrieve_params.rbs +15 -0
  56. data/sig/moderation_api/models/webhook_secret_retrieve_response.rbs +13 -0
  57. data/sig/moderation_api/models/webhook_update_params.rbs +85 -0
  58. data/sig/moderation_api/models/webhook_update_response.rbs +92 -0
  59. data/sig/moderation_api/models.rbs +14 -0
  60. data/sig/moderation_api/resources/content.rbs +5 -0
  61. data/sig/moderation_api/resources/webhook_secret.rbs +11 -0
  62. data/sig/moderation_api/resources/webhooks.rbs +38 -0
  63. metadata +47 -2
@@ -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
@@ -28,6 +28,28 @@ module ModerationAPI
28
28
  end
29
29
  attr_writer :author
30
30
 
31
+ # What your casebook — the record of your past moderation decisions — found for
32
+ # this content, or null when it had nothing close enough to say, when the matching
33
+ # cases disagreed, or when casebook lookups are not switched on for this channel.
34
+ # Reports what the casebook found; whether it decided the outcome is shown in
35
+ # `recommendation`, where a higher-priority rule may have settled the item first.
36
+ sig do
37
+ returns(
38
+ T.nilable(ModerationAPI::Models::ContentSubmitResponse::Casebook)
39
+ )
40
+ end
41
+ attr_reader :casebook
42
+
43
+ sig do
44
+ params(
45
+ casebook:
46
+ T.nilable(
47
+ ModerationAPI::Models::ContentSubmitResponse::Casebook::OrHash
48
+ )
49
+ ).void
50
+ end
51
+ attr_writer :casebook
52
+
31
53
  # Potentially modified content.
32
54
  sig { returns(ModerationAPI::Models::ContentSubmitResponse::Content) }
33
55
  attr_reader :content
@@ -122,6 +144,10 @@ module ModerationAPI
122
144
  T.nilable(
123
145
  ModerationAPI::Models::ContentSubmitResponse::Author::OrHash
124
146
  ),
147
+ casebook:
148
+ T.nilable(
149
+ ModerationAPI::Models::ContentSubmitResponse::Casebook::OrHash
150
+ ),
125
151
  content:
126
152
  ModerationAPI::Models::ContentSubmitResponse::Content::OrHash,
127
153
  evaluation:
@@ -153,6 +179,12 @@ module ModerationAPI
153
179
  # The author of the content if your account has authors enabled. Requires you to
154
180
  # send authorId when submitting content.
155
181
  author:,
182
+ # What your casebook — the record of your past moderation decisions — found for
183
+ # this content, or null when it had nothing close enough to say, when the matching
184
+ # cases disagreed, or when casebook lookups are not switched on for this channel.
185
+ # Reports what the casebook found; whether it decided the outcome is shown in
186
+ # `recommendation`, where a higher-priority rule may have settled the item first.
187
+ casebook:,
156
188
  # Potentially modified content.
157
189
  content:,
158
190
  # The evaluation of the content after running the channel policies.
@@ -175,6 +207,8 @@ module ModerationAPI
175
207
  {
176
208
  author:
177
209
  T.nilable(ModerationAPI::Models::ContentSubmitResponse::Author),
210
+ casebook:
211
+ T.nilable(ModerationAPI::Models::ContentSubmitResponse::Casebook),
178
212
  content: ModerationAPI::Models::ContentSubmitResponse::Content,
179
213
  evaluation:
180
214
  ModerationAPI::Models::ContentSubmitResponse::Evaluation,
@@ -419,6 +453,193 @@ module ModerationAPI
419
453
  end
420
454
  end
421
455
 
456
+ class Casebook < ModerationAPI::Internal::Type::BaseModel
457
+ OrHash =
458
+ T.type_alias do
459
+ T.any(
460
+ ModerationAPI::Models::ContentSubmitResponse::Casebook,
461
+ ModerationAPI::Internal::AnyHash
462
+ )
463
+ end
464
+
465
+ # How unanimous the matching cases are, from 0 to 1: the share of them that
466
+ # decided this way, ignoring how many there are. Always at least 0.8 when a ruling
467
+ # is returned — below that the casebook reports a disagreement instead of picking
468
+ # a side — so it tells you how clean the consensus was, and is not a threshold to
469
+ # re-apply yourself.
470
+ sig { returns(Float) }
471
+ attr_accessor :agreement
472
+
473
+ # How many of your past cases backed this ruling.
474
+ sig { returns(Float) }
475
+ attr_accessor :case_count
476
+
477
+ # How strongly the casebook holds this ruling, from 0 to 1: the agreement scaled
478
+ # by how much evidence backs it, so a handful of close, recent cases outweighs one
479
+ # distant one. Older cases count for less, halving in weight roughly every 180
480
+ # days. This is the number to use in rules when you want a strength condition.
481
+ sig { returns(Float) }
482
+ attr_accessor :confidence
483
+
484
+ # How close the nearest matching case is, from 0 to 1. 1 means the content is
485
+ # identical to something you have already decided.
486
+ sig { returns(Float) }
487
+ attr_accessor :similarity
488
+
489
+ # The topic the closest matching case is filed under, or null when it has not been
490
+ # grouped into one yet.
491
+ sig do
492
+ returns(
493
+ T.nilable(
494
+ ModerationAPI::Models::ContentSubmitResponse::Casebook::Topic
495
+ )
496
+ )
497
+ end
498
+ attr_reader :topic
499
+
500
+ sig do
501
+ params(
502
+ topic:
503
+ T.nilable(
504
+ ModerationAPI::Models::ContentSubmitResponse::Casebook::Topic::OrHash
505
+ )
506
+ ).void
507
+ end
508
+ attr_writer :topic
509
+
510
+ # The ruling your past decisions point to for this content.
511
+ sig do
512
+ returns(
513
+ ModerationAPI::Models::ContentSubmitResponse::Casebook::Verdict::TaggedSymbol
514
+ )
515
+ end
516
+ attr_accessor :verdict
517
+
518
+ # What your casebook — the record of your past moderation decisions — found for
519
+ # this content, or null when it had nothing close enough to say, when the matching
520
+ # cases disagreed, or when casebook lookups are not switched on for this channel.
521
+ # Reports what the casebook found; whether it decided the outcome is shown in
522
+ # `recommendation`, where a higher-priority rule may have settled the item first.
523
+ sig do
524
+ params(
525
+ agreement: Float,
526
+ case_count: Float,
527
+ confidence: Float,
528
+ similarity: Float,
529
+ topic:
530
+ T.nilable(
531
+ ModerationAPI::Models::ContentSubmitResponse::Casebook::Topic::OrHash
532
+ ),
533
+ verdict:
534
+ ModerationAPI::Models::ContentSubmitResponse::Casebook::Verdict::OrSymbol
535
+ ).returns(T.attached_class)
536
+ end
537
+ def self.new(
538
+ # How unanimous the matching cases are, from 0 to 1: the share of them that
539
+ # decided this way, ignoring how many there are. Always at least 0.8 when a ruling
540
+ # is returned — below that the casebook reports a disagreement instead of picking
541
+ # a side — so it tells you how clean the consensus was, and is not a threshold to
542
+ # re-apply yourself.
543
+ agreement:,
544
+ # How many of your past cases backed this ruling.
545
+ case_count:,
546
+ # How strongly the casebook holds this ruling, from 0 to 1: the agreement scaled
547
+ # by how much evidence backs it, so a handful of close, recent cases outweighs one
548
+ # distant one. Older cases count for less, halving in weight roughly every 180
549
+ # days. This is the number to use in rules when you want a strength condition.
550
+ confidence:,
551
+ # How close the nearest matching case is, from 0 to 1. 1 means the content is
552
+ # identical to something you have already decided.
553
+ similarity:,
554
+ # The topic the closest matching case is filed under, or null when it has not been
555
+ # grouped into one yet.
556
+ topic:,
557
+ # The ruling your past decisions point to for this content.
558
+ verdict:
559
+ )
560
+ end
561
+
562
+ sig do
563
+ override.returns(
564
+ {
565
+ agreement: Float,
566
+ case_count: Float,
567
+ confidence: Float,
568
+ similarity: Float,
569
+ topic:
570
+ T.nilable(
571
+ ModerationAPI::Models::ContentSubmitResponse::Casebook::Topic
572
+ ),
573
+ verdict:
574
+ ModerationAPI::Models::ContentSubmitResponse::Casebook::Verdict::TaggedSymbol
575
+ }
576
+ )
577
+ end
578
+ def to_hash
579
+ end
580
+
581
+ class Topic < ModerationAPI::Internal::Type::BaseModel
582
+ OrHash =
583
+ T.type_alias do
584
+ T.any(
585
+ ModerationAPI::Models::ContentSubmitResponse::Casebook::Topic,
586
+ ModerationAPI::Internal::AnyHash
587
+ )
588
+ end
589
+
590
+ sig { returns(String) }
591
+ attr_accessor :id
592
+
593
+ sig { returns(String) }
594
+ attr_accessor :label
595
+
596
+ # The topic the closest matching case is filed under, or null when it has not been
597
+ # grouped into one yet.
598
+ sig { params(id: String, label: String).returns(T.attached_class) }
599
+ def self.new(id:, label:)
600
+ end
601
+
602
+ sig { override.returns({ id: String, label: String }) }
603
+ def to_hash
604
+ end
605
+ end
606
+
607
+ # The ruling your past decisions point to for this content.
608
+ module Verdict
609
+ extend ModerationAPI::Internal::Type::Enum
610
+
611
+ TaggedSymbol =
612
+ T.type_alias do
613
+ T.all(
614
+ Symbol,
615
+ ModerationAPI::Models::ContentSubmitResponse::Casebook::Verdict
616
+ )
617
+ end
618
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
619
+
620
+ ALLOW =
621
+ T.let(
622
+ :allow,
623
+ ModerationAPI::Models::ContentSubmitResponse::Casebook::Verdict::TaggedSymbol
624
+ )
625
+ REJECT =
626
+ T.let(
627
+ :reject,
628
+ ModerationAPI::Models::ContentSubmitResponse::Casebook::Verdict::TaggedSymbol
629
+ )
630
+
631
+ sig do
632
+ override.returns(
633
+ T::Array[
634
+ ModerationAPI::Models::ContentSubmitResponse::Casebook::Verdict::TaggedSymbol
635
+ ]
636
+ )
637
+ end
638
+ def self.values
639
+ end
640
+ end
641
+ end
642
+
422
643
  class Content < ModerationAPI::Internal::Type::BaseModel
423
644
  OrHash =
424
645
  T.type_alias do
@@ -1828,6 +2049,11 @@ module ModerationAPI
1828
2049
  :client_override,
1829
2050
  ModerationAPI::Models::ContentSubmitResponse::Recommendation::ReasonCode::TaggedSymbol
1830
2051
  )
2052
+ CASEBOOK_MATCH =
2053
+ T.let(
2054
+ :casebook_match,
2055
+ ModerationAPI::Models::ContentSubmitResponse::Recommendation::ReasonCode::TaggedSymbol
2056
+ )
1831
2057
  end
1832
2058
 
1833
2059
  class MatchedRule < ModerationAPI::Internal::Type::BaseModel
@@ -0,0 +1,154 @@
1
+ # typed: strong
2
+
3
+ module ModerationAPI
4
+ module Models
5
+ class WebhookCreateParams < 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::WebhookCreateParams,
13
+ ModerationAPI::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ # Event types this webhook subscribes to. One webhook URL receives all events you
18
+ # list here.
19
+ sig do
20
+ returns(
21
+ T::Array[ModerationAPI::WebhookCreateParams::EventType::OrSymbol]
22
+ )
23
+ end
24
+ attr_accessor :event_types
25
+
26
+ # The webhook's name, used to identify it in the dashboard
27
+ sig { returns(String) }
28
+ attr_accessor :name
29
+
30
+ # The webhook's URL. We'll call this URL when an event occurs.
31
+ sig { returns(String) }
32
+ attr_accessor :url
33
+
34
+ # The webhook's description
35
+ sig { returns(T.nilable(String)) }
36
+ attr_accessor :description
37
+
38
+ sig do
39
+ params(
40
+ event_types:
41
+ T::Array[ModerationAPI::WebhookCreateParams::EventType::OrSymbol],
42
+ name: String,
43
+ url: String,
44
+ description: T.nilable(String),
45
+ request_options: ModerationAPI::RequestOptions::OrHash
46
+ ).returns(T.attached_class)
47
+ end
48
+ def self.new(
49
+ # Event types this webhook subscribes to. One webhook URL receives all events you
50
+ # list here.
51
+ event_types:,
52
+ # The webhook's name, used to identify it in the dashboard
53
+ name:,
54
+ # The webhook's URL. We'll call this URL when an event occurs.
55
+ url:,
56
+ # The webhook's description
57
+ description: nil,
58
+ request_options: {}
59
+ )
60
+ end
61
+
62
+ sig do
63
+ override.returns(
64
+ {
65
+ event_types:
66
+ T::Array[ModerationAPI::WebhookCreateParams::EventType::OrSymbol],
67
+ name: String,
68
+ url: String,
69
+ description: T.nilable(String),
70
+ request_options: ModerationAPI::RequestOptions
71
+ }
72
+ )
73
+ end
74
+ def to_hash
75
+ end
76
+
77
+ module EventType
78
+ extend ModerationAPI::Internal::Type::Enum
79
+
80
+ TaggedSymbol =
81
+ T.type_alias do
82
+ T.all(Symbol, ModerationAPI::WebhookCreateParams::EventType)
83
+ end
84
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
85
+
86
+ QUEUE_ITEM_NEW =
87
+ T.let(
88
+ :QUEUE_ITEM_NEW,
89
+ ModerationAPI::WebhookCreateParams::EventType::TaggedSymbol
90
+ )
91
+ QUEUE_ITEM_COMPLETED =
92
+ T.let(
93
+ :QUEUE_ITEM_COMPLETED,
94
+ ModerationAPI::WebhookCreateParams::EventType::TaggedSymbol
95
+ )
96
+ QUEUE_ITEM_ACTION =
97
+ T.let(
98
+ :QUEUE_ITEM_ACTION,
99
+ ModerationAPI::WebhookCreateParams::EventType::TaggedSymbol
100
+ )
101
+ QUEUE_ITEM_REJECTED =
102
+ T.let(
103
+ :QUEUE_ITEM_REJECTED,
104
+ ModerationAPI::WebhookCreateParams::EventType::TaggedSymbol
105
+ )
106
+ QUEUE_ITEM_ALLOWED =
107
+ T.let(
108
+ :QUEUE_ITEM_ALLOWED,
109
+ ModerationAPI::WebhookCreateParams::EventType::TaggedSymbol
110
+ )
111
+ AUTHOR_BLOCKED =
112
+ T.let(
113
+ :AUTHOR_BLOCKED,
114
+ ModerationAPI::WebhookCreateParams::EventType::TaggedSymbol
115
+ )
116
+ AUTHOR_UNBLOCKED =
117
+ T.let(
118
+ :AUTHOR_UNBLOCKED,
119
+ ModerationAPI::WebhookCreateParams::EventType::TaggedSymbol
120
+ )
121
+ AUTHOR_SUSPENDED =
122
+ T.let(
123
+ :AUTHOR_SUSPENDED,
124
+ ModerationAPI::WebhookCreateParams::EventType::TaggedSymbol
125
+ )
126
+ AUTHOR_UPDATED =
127
+ T.let(
128
+ :AUTHOR_UPDATED,
129
+ ModerationAPI::WebhookCreateParams::EventType::TaggedSymbol
130
+ )
131
+ AUTHOR_TRUST_LEVEL_CHANGED =
132
+ T.let(
133
+ :AUTHOR_TRUST_LEVEL_CHANGED,
134
+ ModerationAPI::WebhookCreateParams::EventType::TaggedSymbol
135
+ )
136
+ AUTHOR_ACTION =
137
+ T.let(
138
+ :AUTHOR_ACTION,
139
+ ModerationAPI::WebhookCreateParams::EventType::TaggedSymbol
140
+ )
141
+
142
+ sig do
143
+ override.returns(
144
+ T::Array[
145
+ ModerationAPI::WebhookCreateParams::EventType::TaggedSymbol
146
+ ]
147
+ )
148
+ end
149
+ def self.values
150
+ end
151
+ end
152
+ end
153
+ end
154
+ end