Class: ModerationAPI::Resources::Wordlist::Words

Inherits:
Object
  • Object
show all
Defined in:
lib/moderation_api/resources/wordlist/words.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Words

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Words.

Parameters:



59
60
61
# File 'lib/moderation_api/resources/wordlist/words.rb', line 59

def initialize(client:)
  @client = client
end

Instance Method Details

#add(id, words:, request_options: {}) ⇒ ModerationAPI::Models::Wordlist::WordAddResponse

Add words to an existing wordlist

Parameters:

  • id (String)

    ID of the wordlist to add words to

  • words (Array<String>)

    Array of words to add to the wordlist. Duplicate words will be ignored.

  • request_options (ModerationAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



20
21
22
23
24
25
26
27
28
29
# File 'lib/moderation_api/resources/wordlist/words.rb', line 20

def add(id, params)
  parsed, options = ModerationAPI::Wordlist::WordAddParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["wordlist/%1$s/words", id],
    body: parsed,
    model: ModerationAPI::Models::Wordlist::WordAddResponse,
    options: options
  )
end

#remove(id, words:, request_options: {}) ⇒ ModerationAPI::Models::Wordlist::WordRemoveResponse

Remove words from an existing wordlist

Parameters:

  • id (String)

    ID of the wordlist to remove words from

  • words (Array<String>)

    Array of words to remove from the wordlist

  • request_options (ModerationAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/moderation_api/resources/wordlist/words.rb', line 44

def remove(id, params)
  parsed, options = ModerationAPI::Wordlist::WordRemoveParams.dump_request(params)
  query = ModerationAPI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :delete,
    path: ["wordlist/%1$s/words", id],
    query: query,
    model: ModerationAPI::Models::Wordlist::WordRemoveResponse,
    options: options
  )
end