Module: Mastodon::REST::Filters

Includes:
Utils
Included in:
API
Defined in:
lib/mastodon/rest/filters.rb

Instance Method Summary collapse

Methods included from Utils

#array_param, #perform_request, #perform_request_with_collection, #perform_request_with_object

Instance Method Details

#create_filter(params = {}) ⇒ Mastodon::Filter

Create a filter

Parameters:

  • params (Hash) (defaults to: {})

Options Hash (params):

  • :phrase (String)
  • :context (Array<String>)
  • :irreversible (Boolean)
  • :whole_word (Boolean)
  • :expires_in (Integer)

Returns:



35
36
37
38
# File 'lib/mastodon/rest/filters.rb', line 35

def create_filter(params = {})
  params[:'context[]'] = params.delete(:context) if params.key?(:context)
  perform_request_with_object(:post, '/api/v1/filters', params, Mastodon::Filter)
end

#delete_filter(id) ⇒ Object

Delete a filter

Parameters:

  • id (Integer)


56
57
58
# File 'lib/mastodon/rest/filters.rb', line 56

def delete_filter(id)
  perform_request(:delete, "/api/v1/filters/#{id}")
end

#filter(id) ⇒ Mastodon::Filter

Retrieve a filter

Parameters:

  • id (Integer)

Returns:



23
24
25
# File 'lib/mastodon/rest/filters.rb', line 23

def filter(id)
  perform_request_with_object(:put, "/api/v1/filters/#{id}", {}, Mastodon::Filter)
end

#filters(options = {}) ⇒ Mastodon::Collection<Mastodon::Filter>

Get a list of filters

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :max_id (Integer)
  • :since_id (Integer)
  • :min_id (Integer)
  • :limit (Integer)

Returns:



16
17
18
# File 'lib/mastodon/rest/filters.rb', line 16

def filters(options = {})
  perform_request_with_collection('/api/v1/filters', options, Mastodon::Filter)
end

#update_filter(id, params = {}) ⇒ Mastodon::Filter

Update a filter

Parameters:

  • id (Integer)
  • params (Hash) (defaults to: {})

Options Hash (params):

  • :phrase (String)
  • :context (Array<String>)
  • :irreversible (Boolean)
  • :whole_word (Boolean)
  • :expires_in (Integer)

Returns:



49
50
51
52
# File 'lib/mastodon/rest/filters.rb', line 49

def update_filter(id, params = {})
  params[:'context[]'] = params.delete(:context) if params.key?(:context)
  perform_request_with_object(:put, "/api/v1/filters/#{id}", params, Mastodon::Filter)
end