Class: SlackWebApi::DndController

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

Overview

DndController

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

#dnd_end_dnd(token) ⇒ ApiResponse

Ends the current user’s Do Not Disturb session immediately. scope: dnd:write

Parameters:

  • token (String)

    Required parameter: Authentication token. Requires

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/slack_web_api/controllers/dnd_controller.rb', line 13

def dnd_end_dnd(token)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/dnd.endDnd',
                                 Server::DEFAULT)
               .header_param(new_parameter(token, key: 'token')
                              .is_required(true))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'Content-Type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(DndEndDndSchema.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             DndEndDndErrorSchemaException))
    .execute
end

#dnd_end_snooze(token) ⇒ ApiResponse

Ends the current user’s snooze mode immediately. scope: dnd:write

Parameters:

  • token (String)

    Required parameter: Authentication token. Requires

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/slack_web_api/controllers/dnd_controller.rb', line 37

def dnd_end_snooze(token)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/dnd.endSnooze',
                                 Server::DEFAULT)
               .header_param(new_parameter(token, key: 'token')
                              .is_required(true))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'Content-Type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(DndEndSnoozeSchema.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             DndEndSnoozeErrorSchemaException))
    .execute
end

#dnd_info(token: nil, user: nil) ⇒ ApiResponse

Retrieves a user’s current Do Not Disturb status. scope: dnd:read (defaults to current user)

Parameters:

  • token (String) (defaults to: nil)

    Optional parameter: Authentication token. Requires

  • user (String) (defaults to: nil)

    Optional parameter: User to fetch status for

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/slack_web_api/controllers/dnd_controller.rb', line 63

def dnd_info(token: nil,
             user: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/dnd.info',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'Content-Type'))
               .query_param(new_parameter(token, key: 'token'))
               .query_param(new_parameter(user, key: 'user'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(DndInfoSchema.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             DndInfoErrorSchemaException))
    .execute
end

#dnd_set_snooze(token, num_minutes) ⇒ ApiResponse

Turns on Do Not Disturb mode for the current user, or changes its duration. scope: dnd:write now, to snooze until.

Parameters:

  • token (String)

    Required parameter: Authentication token. Requires

  • num_minutes (String)

    Required parameter: Number of minutes, from

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/slack_web_api/controllers/dnd_controller.rb', line 91

def dnd_set_snooze(token,
                   num_minutes)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/dnd.setSnooze',
                                 Server::DEFAULT)
               .form_param(new_parameter(token, key: 'token')
                            .is_required(true))
               .form_param(new_parameter(num_minutes, key: 'num_minutes')
                            .is_required(true))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(DndSetSnoozeSchema.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             DndSetSnoozeErrorSchemaException))
    .execute
end

#dnd_team_info(token: nil, users: nil) ⇒ ApiResponse

Retrieves the Do Not Disturb status for up to 50 users on a team. scope: dnd:read fetch Do Not Disturb status for

Parameters:

  • token (String) (defaults to: nil)

    Optional parameter: Authentication token. Requires

  • users (String) (defaults to: nil)

    Optional parameter: Comma-separated list of users to

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/slack_web_api/controllers/dnd_controller.rb', line 120

def dnd_team_info(token: nil,
                  users: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/dnd.teamInfo',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'Content-Type'))
               .query_param(new_parameter(token, key: 'token'))
               .query_param(new_parameter(users, key: 'users'))
               .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