moderation_api 2.1.1 → 2.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8644cce5a8b3f207674222d3aec5071b5530d17576be7e2faec0654a8ce47cbb
4
- data.tar.gz: 590563eecf7a6ad0a0e7e3e9c9574636530546393fc078dc0f78259660afe790
3
+ metadata.gz: c8bceac424320522543b08e3166f8bbb4d30114cf0423f8b541949d2c707d970
4
+ data.tar.gz: b561c83bff94f0e046888ddb2ae76aaf4420eb949e6cd4095691af1d23f59cbf
5
5
  SHA512:
6
- metadata.gz: e2cc1d9b313deeba0b7aba78c0a236a2d9c450ff65f3465782373eca2f39b9f39a5bd01ae6370d0b3f0f482d734b120ef1b45bb733f8db6abe2838be71431a7c
7
- data.tar.gz: 896b4922a56f9d5700544524db3fbf73408675347e2287e84bcdd51f632ece030a60b189c3ce7e743dae2af8c97ba06c96414485f3098822acc34d49d15a2048
6
+ metadata.gz: b1f5be4bb5ef3041f0ccf9d8b3301fc0d7d4506a59ed4b62eba5f682257ccda11fd7ee6c9f0b156bd94b70b4a5e1af321ad26e106234451042b04f7f24fb4562
7
+ data.tar.gz: 6a27664404d10ee26c5e01e19dc5b40fa6a097af71fd71e99c57a883457e46540006c0ec06e5a8dec6041d7941f1f21bac061322be7fceecef48ec8e698ce2ef
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.2.1 (2025-12-19)
4
+
5
+ Full Changelog: [v2.2.0...v2.2.1](https://github.com/moderation-api/sdk-ruby/compare/v2.2.0...v2.2.1)
6
+
7
+ ### Bug Fixes
8
+
9
+ * issue where json.parse errors when receiving HTTP 204 with nobody ([fb1960a](https://github.com/moderation-api/sdk-ruby/commit/fb1960aab2de9c04cdb3985f7d75f503eca0b3b8))
10
+
11
+ ## 2.2.0 (2025-12-18)
12
+
13
+ Full Changelog: [v2.1.1...v2.2.0](https://github.com/moderation-api/sdk-ruby/compare/v2.1.1...v2.2.0)
14
+
15
+ ### Features
16
+
17
+ * **api:** api update ([37d5a3d](https://github.com/moderation-api/sdk-ruby/commit/37d5a3d6185eaddfce7a79d9b4799568d694782a))
18
+
3
19
  ## 2.1.1 (2025-12-17)
4
20
 
5
21
  Full Changelog: [v2.1.0...v2.1.1](https://github.com/moderation-api/sdk-ruby/compare/v2.1.0...v2.1.1)
data/README.md CHANGED
@@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application
15
15
  <!-- x-release-please-start-version -->
16
16
 
17
17
  ```ruby
18
- gem "moderation_api", "~> 2.1.1"
18
+ gem "moderation_api", "~> 2.2.1"
19
19
  ```
20
20
 
21
21
  <!-- x-release-please-end -->
@@ -657,7 +657,8 @@ module ModerationAPI
657
657
  def decode_content(headers, stream:, suppress_error: false)
658
658
  case (content_type = headers["content-type"])
659
659
  in ModerationAPI::Internal::Util::JSON_CONTENT
660
- json = stream.to_a.join
660
+ return nil if (json = stream.to_a.join).empty?
661
+
661
662
  begin
662
663
  JSON.parse(json, symbolize_names: true)
663
664
  rescue JSON::ParserError => e
@@ -667,7 +668,11 @@ module ModerationAPI
667
668
  in ModerationAPI::Internal::Util::JSONL_CONTENT
668
669
  lines = decode_lines(stream)
669
670
  chain_fused(lines) do |y|
670
- lines.each { y << JSON.parse(_1, symbolize_names: true) }
671
+ lines.each do
672
+ next if _1.empty?
673
+
674
+ y << JSON.parse(_1, symbolize_names: true)
675
+ end
671
676
  end
672
677
  in %r{^text/event-stream}
673
678
  lines = decode_lines(stream)
@@ -388,8 +388,14 @@ module ModerationAPI
388
388
  # @return [Boolean]
389
389
  required :flag, ModerationAPI::Internal::Type::Boolean
390
390
 
391
- # @!method initialize(flag:, id: :toxicity)
391
+ # @!attribute threshold
392
+ #
393
+ # @return [Float, nil]
394
+ optional :threshold, Float
395
+
396
+ # @!method initialize(flag:, threshold: nil, id: :toxicity)
392
397
  # @param flag [Boolean]
398
+ # @param threshold [Float]
393
399
  # @param id [Symbol, :toxicity]
394
400
  end
395
401
 
@@ -404,8 +410,14 @@ module ModerationAPI
404
410
  # @return [Boolean]
405
411
  required :flag, ModerationAPI::Internal::Type::Boolean
406
412
 
407
- # @!method initialize(flag:, id: :personal_information)
413
+ # @!attribute threshold
414
+ #
415
+ # @return [Float, nil]
416
+ optional :threshold, Float
417
+
418
+ # @!method initialize(flag:, threshold: nil, id: :personal_information)
408
419
  # @param flag [Boolean]
420
+ # @param threshold [Float]
409
421
  # @param id [Symbol, :personal_information]
410
422
  end
411
423
 
@@ -420,8 +432,14 @@ module ModerationAPI
420
432
  # @return [Boolean]
421
433
  required :flag, ModerationAPI::Internal::Type::Boolean
422
434
 
423
- # @!method initialize(flag:, id: :toxicity_severe)
435
+ # @!attribute threshold
436
+ #
437
+ # @return [Float, nil]
438
+ optional :threshold, Float
439
+
440
+ # @!method initialize(flag:, threshold: nil, id: :toxicity_severe)
424
441
  # @param flag [Boolean]
442
+ # @param threshold [Float]
425
443
  # @param id [Symbol, :toxicity_severe]
426
444
  end
427
445
 
@@ -436,8 +454,14 @@ module ModerationAPI
436
454
  # @return [Boolean]
437
455
  required :flag, ModerationAPI::Internal::Type::Boolean
438
456
 
439
- # @!method initialize(flag:, id: :hate)
457
+ # @!attribute threshold
458
+ #
459
+ # @return [Float, nil]
460
+ optional :threshold, Float
461
+
462
+ # @!method initialize(flag:, threshold: nil, id: :hate)
440
463
  # @param flag [Boolean]
464
+ # @param threshold [Float]
441
465
  # @param id [Symbol, :hate]
442
466
  end
443
467
 
@@ -452,8 +476,14 @@ module ModerationAPI
452
476
  # @return [Boolean]
453
477
  required :flag, ModerationAPI::Internal::Type::Boolean
454
478
 
455
- # @!method initialize(flag:, id: :illicit)
479
+ # @!attribute threshold
480
+ #
481
+ # @return [Float, nil]
482
+ optional :threshold, Float
483
+
484
+ # @!method initialize(flag:, threshold: nil, id: :illicit)
456
485
  # @param flag [Boolean]
486
+ # @param threshold [Float]
457
487
  # @param id [Symbol, :illicit]
458
488
  end
459
489
 
@@ -468,8 +498,14 @@ module ModerationAPI
468
498
  # @return [Boolean]
469
499
  required :flag, ModerationAPI::Internal::Type::Boolean
470
500
 
471
- # @!method initialize(flag:, id: :illicit_drugs)
501
+ # @!attribute threshold
502
+ #
503
+ # @return [Float, nil]
504
+ optional :threshold, Float
505
+
506
+ # @!method initialize(flag:, threshold: nil, id: :illicit_drugs)
472
507
  # @param flag [Boolean]
508
+ # @param threshold [Float]
473
509
  # @param id [Symbol, :illicit_drugs]
474
510
  end
475
511
 
@@ -484,8 +520,14 @@ module ModerationAPI
484
520
  # @return [Boolean]
485
521
  required :flag, ModerationAPI::Internal::Type::Boolean
486
522
 
487
- # @!method initialize(flag:, id: :illicit_alcohol)
523
+ # @!attribute threshold
524
+ #
525
+ # @return [Float, nil]
526
+ optional :threshold, Float
527
+
528
+ # @!method initialize(flag:, threshold: nil, id: :illicit_alcohol)
488
529
  # @param flag [Boolean]
530
+ # @param threshold [Float]
489
531
  # @param id [Symbol, :illicit_alcohol]
490
532
  end
491
533
 
@@ -500,8 +542,14 @@ module ModerationAPI
500
542
  # @return [Boolean]
501
543
  required :flag, ModerationAPI::Internal::Type::Boolean
502
544
 
503
- # @!method initialize(flag:, id: :illicit_firearms)
545
+ # @!attribute threshold
546
+ #
547
+ # @return [Float, nil]
548
+ optional :threshold, Float
549
+
550
+ # @!method initialize(flag:, threshold: nil, id: :illicit_firearms)
504
551
  # @param flag [Boolean]
552
+ # @param threshold [Float]
505
553
  # @param id [Symbol, :illicit_firearms]
506
554
  end
507
555
 
@@ -516,8 +564,14 @@ module ModerationAPI
516
564
  # @return [Boolean]
517
565
  required :flag, ModerationAPI::Internal::Type::Boolean
518
566
 
519
- # @!method initialize(flag:, id: :illicit_tobacco)
567
+ # @!attribute threshold
568
+ #
569
+ # @return [Float, nil]
570
+ optional :threshold, Float
571
+
572
+ # @!method initialize(flag:, threshold: nil, id: :illicit_tobacco)
520
573
  # @param flag [Boolean]
574
+ # @param threshold [Float]
521
575
  # @param id [Symbol, :illicit_tobacco]
522
576
  end
523
577
 
@@ -532,8 +586,14 @@ module ModerationAPI
532
586
  # @return [Boolean]
533
587
  required :flag, ModerationAPI::Internal::Type::Boolean
534
588
 
535
- # @!method initialize(flag:, id: :illicit_gambling)
589
+ # @!attribute threshold
590
+ #
591
+ # @return [Float, nil]
592
+ optional :threshold, Float
593
+
594
+ # @!method initialize(flag:, threshold: nil, id: :illicit_gambling)
536
595
  # @param flag [Boolean]
596
+ # @param threshold [Float]
537
597
  # @param id [Symbol, :illicit_gambling]
538
598
  end
539
599
 
@@ -548,8 +608,14 @@ module ModerationAPI
548
608
  # @return [Boolean]
549
609
  required :flag, ModerationAPI::Internal::Type::Boolean
550
610
 
551
- # @!method initialize(flag:, id: :sexual)
611
+ # @!attribute threshold
612
+ #
613
+ # @return [Float, nil]
614
+ optional :threshold, Float
615
+
616
+ # @!method initialize(flag:, threshold: nil, id: :sexual)
552
617
  # @param flag [Boolean]
618
+ # @param threshold [Float]
553
619
  # @param id [Symbol, :sexual]
554
620
  end
555
621
 
@@ -564,8 +630,14 @@ module ModerationAPI
564
630
  # @return [Boolean]
565
631
  required :flag, ModerationAPI::Internal::Type::Boolean
566
632
 
567
- # @!method initialize(flag:, id: :flirtation)
633
+ # @!attribute threshold
634
+ #
635
+ # @return [Float, nil]
636
+ optional :threshold, Float
637
+
638
+ # @!method initialize(flag:, threshold: nil, id: :flirtation)
568
639
  # @param flag [Boolean]
640
+ # @param threshold [Float]
569
641
  # @param id [Symbol, :flirtation]
570
642
  end
571
643
 
@@ -580,8 +652,14 @@ module ModerationAPI
580
652
  # @return [Boolean]
581
653
  required :flag, ModerationAPI::Internal::Type::Boolean
582
654
 
583
- # @!method initialize(flag:, id: :profanity)
655
+ # @!attribute threshold
656
+ #
657
+ # @return [Float, nil]
658
+ optional :threshold, Float
659
+
660
+ # @!method initialize(flag:, threshold: nil, id: :profanity)
584
661
  # @param flag [Boolean]
662
+ # @param threshold [Float]
585
663
  # @param id [Symbol, :profanity]
586
664
  end
587
665
 
@@ -596,8 +674,14 @@ module ModerationAPI
596
674
  # @return [Boolean]
597
675
  required :flag, ModerationAPI::Internal::Type::Boolean
598
676
 
599
- # @!method initialize(flag:, id: :violence)
677
+ # @!attribute threshold
678
+ #
679
+ # @return [Float, nil]
680
+ optional :threshold, Float
681
+
682
+ # @!method initialize(flag:, threshold: nil, id: :violence)
600
683
  # @param flag [Boolean]
684
+ # @param threshold [Float]
601
685
  # @param id [Symbol, :violence]
602
686
  end
603
687
 
@@ -612,8 +696,14 @@ module ModerationAPI
612
696
  # @return [Boolean]
613
697
  required :flag, ModerationAPI::Internal::Type::Boolean
614
698
 
615
- # @!method initialize(flag:, id: :self_harm)
699
+ # @!attribute threshold
700
+ #
701
+ # @return [Float, nil]
702
+ optional :threshold, Float
703
+
704
+ # @!method initialize(flag:, threshold: nil, id: :self_harm)
616
705
  # @param flag [Boolean]
706
+ # @param threshold [Float]
617
707
  # @param id [Symbol, :self_harm]
618
708
  end
619
709
 
@@ -628,8 +718,14 @@ module ModerationAPI
628
718
  # @return [Boolean]
629
719
  required :flag, ModerationAPI::Internal::Type::Boolean
630
720
 
631
- # @!method initialize(flag:, id: :spam)
721
+ # @!attribute threshold
722
+ #
723
+ # @return [Float, nil]
724
+ optional :threshold, Float
725
+
726
+ # @!method initialize(flag:, threshold: nil, id: :spam)
632
727
  # @param flag [Boolean]
728
+ # @param threshold [Float]
633
729
  # @param id [Symbol, :spam]
634
730
  end
635
731
 
@@ -644,8 +740,14 @@ module ModerationAPI
644
740
  # @return [Boolean]
645
741
  required :flag, ModerationAPI::Internal::Type::Boolean
646
742
 
647
- # @!method initialize(flag:, id: :self_promotion)
743
+ # @!attribute threshold
744
+ #
745
+ # @return [Float, nil]
746
+ optional :threshold, Float
747
+
748
+ # @!method initialize(flag:, threshold: nil, id: :self_promotion)
648
749
  # @param flag [Boolean]
750
+ # @param threshold [Float]
649
751
  # @param id [Symbol, :self_promotion]
650
752
  end
651
753
 
@@ -660,8 +762,14 @@ module ModerationAPI
660
762
  # @return [Boolean]
661
763
  required :flag, ModerationAPI::Internal::Type::Boolean
662
764
 
663
- # @!method initialize(flag:, id: :political)
765
+ # @!attribute threshold
766
+ #
767
+ # @return [Float, nil]
768
+ optional :threshold, Float
769
+
770
+ # @!method initialize(flag:, threshold: nil, id: :political)
664
771
  # @param flag [Boolean]
772
+ # @param threshold [Float]
665
773
  # @param id [Symbol, :political]
666
774
  end
667
775
 
@@ -676,8 +784,14 @@ module ModerationAPI
676
784
  # @return [Boolean]
677
785
  required :flag, ModerationAPI::Internal::Type::Boolean
678
786
 
679
- # @!method initialize(flag:, id: :religion)
787
+ # @!attribute threshold
788
+ #
789
+ # @return [Float, nil]
790
+ optional :threshold, Float
791
+
792
+ # @!method initialize(flag:, threshold: nil, id: :religion)
680
793
  # @param flag [Boolean]
794
+ # @param threshold [Float]
681
795
  # @param id [Symbol, :religion]
682
796
  end
683
797
 
@@ -692,8 +806,14 @@ module ModerationAPI
692
806
  # @return [Boolean]
693
807
  required :flag, ModerationAPI::Internal::Type::Boolean
694
808
 
695
- # @!method initialize(flag:, id: :code_abuse)
809
+ # @!attribute threshold
810
+ #
811
+ # @return [Float, nil]
812
+ optional :threshold, Float
813
+
814
+ # @!method initialize(flag:, threshold: nil, id: :code_abuse)
696
815
  # @param flag [Boolean]
816
+ # @param threshold [Float]
697
817
  # @param id [Symbol, :code_abuse]
698
818
  end
699
819
 
@@ -856,10 +976,16 @@ module ModerationAPI
856
976
  # @return [String]
857
977
  required :instructions, String
858
978
 
859
- # @!method initialize(flag:, guideline_key:, instructions:, id: :guideline)
979
+ # @!attribute threshold
980
+ #
981
+ # @return [Float, nil]
982
+ optional :threshold, Float
983
+
984
+ # @!method initialize(flag:, guideline_key:, instructions:, threshold: nil, id: :guideline)
860
985
  # @param flag [Boolean]
861
986
  # @param guideline_key [String]
862
987
  # @param instructions [String]
988
+ # @param threshold [Float]
863
989
  # @param id [Symbol, :guideline]
864
990
  end
865
991
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ModerationAPI
4
- VERSION = "2.1.1"
4
+ VERSION = "2.2.1"
5
5
  end