Class: SlackWebApi::PinsController

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

Overview

PinsController

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

#pins_add(token, channel, timestamp: nil) ⇒ ApiResponse

Pins an item to a channel. scope: pins:write pin.

Parameters:

  • token (String)

    Required parameter: Authentication token. Requires

  • channel (String)

    Required parameter: Channel to pin the item in.

  • timestamp (String) (defaults to: nil)

    Optional parameter: Timestamp of the message to

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/slack_web_api/controllers/pins_controller.rb', line 16

def pins_add(token,
             channel,
             timestamp: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/pins.add',
                                 Server::DEFAULT)
               .header_param(new_parameter(token, key: 'token')
                              .is_required(true))
               .form_param(new_parameter(channel, key: 'channel')
                            .is_required(true))
               .form_param(new_parameter(timestamp, key: 'timestamp'))
               .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(PinsAddSchema.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             PinsAddErrorSchemaException))
    .execute
end

#pins_list(token, channel) ⇒ ApiResponse

Lists items pinned to a channel. scope: pins:read for.

Parameters:

  • token (String)

    Required parameter: Authentication token. Requires

  • channel (String)

    Required parameter: Channel to get pinned items

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/slack_web_api/controllers/pins_controller.rb', line 47

def pins_list(token,
              channel)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/pins.list',
                                 Server::DEFAULT)
               .query_param(new_parameter(token, key: 'token')
                             .is_required(true))
               .query_param(new_parameter(channel, key: 'channel')
                             .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(:dynamic_deserializer))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             PinsListErrorSchemaException))
    .execute
end

#pins_remove(token, channel, timestamp: nil) ⇒ ApiResponse

Un-pins an item from a channel. scope: pins:write pinned to. un-pin.

Parameters:

  • token (String)

    Required parameter: Authentication token. Requires

  • channel (String)

    Required parameter: Channel where the item is

  • timestamp (String) (defaults to: nil)

    Optional parameter: Timestamp of the message to

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/slack_web_api/controllers/pins_controller.rb', line 77

def pins_remove(token,
                channel,
                timestamp: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/pins.remove',
                                 Server::DEFAULT)
               .header_param(new_parameter(token, key: 'token')
                              .is_required(true))
               .form_param(new_parameter(channel, key: 'channel')
                            .is_required(true))
               .form_param(new_parameter(timestamp, key: 'timestamp'))
               .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(PinsRemoveSchema.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             PinsRemoveErrorSchemaException))
    .execute
end