class Copyleaks::CopyleaksTextModerationRequestModel
Attributes
Public Class Methods
Source
# File lib/copyleaks/models/textModeration/requests/CopyleaksTextModerationRequestModel.rb, line 33 def self.from_json(json_string) data = JSON.parse(json_string, symbolize_names: true) new( text: data[:text], sandbox: data[:sandbox], language: data[:language], labels: data[:labels] ) end
Source
# File lib/copyleaks/models/textModeration/requests/CopyleaksTextModerationRequestModel.rb, line 11 def initialize(text: '', sandbox: false, language: nil, labels: []) @text = text @sandbox = sandbox @language = language @labels = labels raise ArgumentError, "String cannot be blank" if @text.nil? raise ArgumentError, "Labels must be a non-empty array." unless labels.is_a?(Array) && !labels.empty? raise ArgumentError, "Labels cannot have more than 32 elements." if labels.length > 32 end
@param text [String] Text
to produce Text
Moderation report for. @param sandbox [Boolean] Use sandbox mode to test your integration. Default: false. @param language [String, nil] The language code. Optional; set to nil for auto-detect. @param labels [Array<Object>] A list of label configurations (min 1, max 32 elements).
Public Instance Methods
Source
# File lib/copyleaks/models/textModeration/requests/CopyleaksTextModerationRequestModel.rb, line 24 def to_json(options = {}) { text: @text, sandbox: @sandbox, language: @language, labels: @labels }.to_json(options) end