ex_slack v0.2.2 Slack.RpcApi View Source
Module for interfacing the Slack HTTP API.
Examples
iex()> Slack.RpcApi.get("api.test")
{:ok,
%{"args" => %{"token" => "xoxb-2REDACTED588-tiUCREDACTEDx7sREDACTED"},
"ok" => true}}
iex()> Slack.RpcApi.post("api.test", [{"some_argument", "some value"}])
{:ok, %{"args" => %{"some_argument" => "some value", "token" => "xoxb-2REDACTED588-tiUCREDACTEDx7sREDACTED"}, "ok" => true}}
iex(3)> Slack.RpcApi.post("api.test", %{"error" => "hey something went wrong"})
{:error, "hey something went wrong"}
Calling Conventions
Calling the API is simple. you need to supply an HTTP method, an API method, and a payload.
Payload
The payload should be constructed as either:
- a list of
{"key", "value"}
- a string key’d map: %{“key” => “value”}
Link to this section Summary
Link to this section Functions
Make and HTTP GET request. see request/3
for details.
Make a HTTP POST request. see request/3
for details.
Make an RPC Request.
Args
method
- either :get, or :postrpc_method
- One of the many Slack RPC methods. see here for details.payload
- A map of the payload to be delivered.
Examples
iex()> Slack.RpcApi.request(:get, "api.test", [])
{:ok, %{"args" => %{"token" => "xoxb-2REDACTED588-tiUCREDACTEDx7sREDACTED"},
"ok" => true}}}
iex()> slack.RpcApi.request(:post, "api.test", [{"error", "uh oh"}])
{:error, "uh oh"}