From 7aa5eba3ba0cd1a22dfcbfc995cfc6b57284b30c Mon Sep 17 00:00:00 2001 From: Brad Harris Date: Wed, 27 Apr 2022 15:05:03 -0600 Subject: [PATCH] updating readme and docs for new api methods (#10) * updating readme and docs for new api methods * shift client w/ options up in docs --- README.md | 18 ++++++++++++------ docs/client.md | 6 +++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index c4364c6..76af520 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,14 @@ Slack API Client for Deno Run on Slack projects ```ts import { SlackAPI } from "https://deno.land/x/deno_slack_api@0.0.2/mod.ts" -const client = SlackAPI(token, {}); +const client = SlackAPI(token); -await client.apiCall("chat.postMessage", { +// ...or create a client with options +const client = SlackAPI(token, { + slackApiUrl: "..." +}); + +await client.chat.postMessage({ text: "hello there", channel: "...", }); @@ -15,10 +20,11 @@ await client.apiCall("chat.postMessage", { // respond to a response_url await client.response("...", payload); -// create a client with options -const client = SlackAPI(token, { - slackApiUrl: "..." -}) +// use apiCall() w/ method name +await client.apiCall("chat.postMessage", { + text: "hello there", + channel: "...", +}); ``` ## Requirements diff --git a/docs/client.md b/docs/client.md index cdd38d2..3e1de1f 100644 --- a/docs/client.md +++ b/docs/client.md @@ -4,7 +4,7 @@ To instantiate the Slack API Client, use the top level `SlackAPI` export. `SlackAPI` accepts two arguments: - `token`: Your application's access token -- `options`: An object with parameters to customize the client +- `options`: An optional object with parameters to customize the client - `slackApiUrl`: an optional string parameter to specify the Slack API URL. By default this is set to `"https://slack.com/api/"` @@ -12,7 +12,7 @@ To instantiate the Slack API Client, use the top level `SlackAPI` export. `Slack import { SlackAPI } from "https://deno.land/x/deno_slack_api@0.0.2/mod.ts" // create a client with defaults -const client = SlackAPI(token, {}); +const client = SlackAPI(token); // create a client with options const customClient = SlackAPI(token, { @@ -22,7 +22,7 @@ const customClient = SlackAPI(token, { ### Using the Slack API Client -Now that you have an instance of the Slack API Client, you have access to its methods: +Now that you have an instance of the Slack API Client, you have access to its methods. You can call Slack API methods by directly referencing them on the client, such as `client.chat.postMessage()` or `client.pins.add()`. You also have access to the following methods: - `apiCall`: An async function that accepts two arguments: 1. `method`: a string which defines which API method you wish to invoke. 2. `data`: a JSON object representing parameter data to be passed to the API method you wish to invoke; the client will handle serializing it appropriately.