Module: Slack::Web::Api::Endpoints::Search

Included in:
Slack::Web::Api::Endpoints
Defined in:
lib/slack/web/api/endpoints/search.rb

Instance Method Summary collapse

Instance Method Details

#search_all(options = {}) ⇒ Object

Searches for messages and files matching a query.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :query (string)

    Search query. May contains booleans, etc.

  • :highlight (boolean)

    Pass a value of true to enable query highlight markers (see below).

  • :sort (string)

    Return matches sorted by either score or timestamp.

  • :sort_dir (string)

    Change sort direction to ascending (asc) or descending (desc).

  • :team_id (string)

    encoded team id to search in, required if org token is used.

Raises:

  • (ArgumentError)

See Also:



24
25
26
27
# File 'lib/slack/web/api/endpoints/search.rb', line 24

def search_all(options = {})
  raise ArgumentError, 'Required arguments :query missing' if options[:query].nil?
  post('search.all', options)
end

#search_files(options = {}) ⇒ Object

Searches for files matching a query.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :query (string)

    Search query.

  • :highlight (boolean)

    Pass a value of true to enable query highlight markers (see below).

  • :sort (string)

    Return matches sorted by either score or timestamp.

  • :sort_dir (string)

    Change sort direction to ascending (asc) or descending (desc).

  • :team_id (string)

    encoded team id to search in, required if org token is used.

Raises:

  • (ArgumentError)

See Also:



44
45
46
47
# File 'lib/slack/web/api/endpoints/search.rb', line 44

def search_files(options = {})
  raise ArgumentError, 'Required arguments :query missing' if options[:query].nil?
  post('search.files', options)
end

#search_messages(options = {}) ⇒ Object

Searches for messages matching a query.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :query (string)

    Search query.

  • :cursor (string)

    Use this when getting results with cursormark pagination. For first call send * for subsequent calls, send the value of next_cursor returned in the previous call’s results.

  • :highlight (boolean)

    Pass a value of true to enable query highlight markers (see below).

  • :sort (string)

    Return matches sorted by either score or timestamp.

  • :sort_dir (string)

    Change sort direction to ascending (asc) or descending (desc).

  • :team_id (string)

    encoded team id to search in, required if org token is used.

Raises:

  • (ArgumentError)

See Also:



66
67
68
69
70
71
72
73
74
75
# File 'lib/slack/web/api/endpoints/search.rb', line 66

def search_messages(options = {})
  raise ArgumentError, 'Required arguments :query missing' if options[:query].nil?
  if block_given?
    Pagination::Cursor.new(self, :search_messages, options).each do |page|
      yield page
    end
  else
    post('search.messages', options)
  end
end