Class: SlackWebApi::SearchController

Inherits:
BaseController show all
Defined in:
lib/slack_web_api/controllers/search_controller.rb

Overview

SearchController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from SlackWebApi::BaseController

Instance Method Details

#search_messages(token, query, count: nil, highlight: nil, page: nil, sort: nil, sort_dir: nil) ⇒ ApiResponse

Searches for messages matching a query. scope: search:read want per “page”. Maximum of 100. of true to enable query highlight markers (see below). score or timestamp. ascending (asc) or descending (desc).

Parameters:

  • token (String)

    Required parameter: Authentication token. Requires

  • query (String)

    Required parameter: Search query.

  • count (Integer) (defaults to: nil)

    Optional parameter: Pass the number of results you

  • highlight (TrueClass | FalseClass) (defaults to: nil)

    Optional parameter: Pass a value

  • page (Integer) (defaults to: nil)

    Optional parameter: TODO: type description here

  • sort (String) (defaults to: nil)

    Optional parameter: Return matches sorted by either

  • sort_dir (String) (defaults to: nil)

    Optional parameter: Change sort direction to

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/slack_web_api/controllers/search_controller.rb', line 23

def search_messages(token,
                    query,
                    count: nil,
                    highlight: nil,
                    page: nil,
                    sort: nil,
                    sort_dir: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/search.messages',
                                 Server::DEFAULT)
               .query_param(new_parameter(token, key: 'token')
                             .is_required(true))
               .query_param(new_parameter(query, key: 'query')
                             .is_required(true))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'Content-Type'))
               .query_param(new_parameter(count, key: 'count'))
               .query_param(new_parameter(highlight, key: 'highlight'))
               .query_param(new_parameter(page, key: 'page'))
               .query_param(new_parameter(sort, key: 'sort'))
               .query_param(new_parameter(sort_dir, key: 'sort_dir'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(DefaultSuccessTemplate.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             DefaultErrorTemplateException))
    .execute
end