-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updating readme and docs for new api methods (#10)
* updating readme and docs for new api methods * shift client w/ options up in docs
- Loading branch information
1 parent
433080d
commit 7aa5eba
Showing
2 changed files
with
15 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,20 +5,26 @@ Slack API Client for Deno Run on Slack projects | |
```ts | ||
import { SlackAPI } from "https://deno.land/x/[email protected]/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: "...", | ||
}); | ||
|
||
// 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,15 +4,15 @@ | |
|
||
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/"` | ||
|
||
|
||
```ts | ||
import { SlackAPI } from "https://deno.land/x/[email protected]/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. | ||
|