Skip to content

Commit

Permalink
updating readme and docs for new api methods (#10)
Browse files Browse the repository at this point in the history
* updating readme and docs for new api methods

* shift client w/ options up in docs
  • Loading branch information
selfcontained authored Apr 27, 2022
1 parent 433080d commit 7aa5eba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions docs/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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.
Expand Down

0 comments on commit 7aa5eba

Please sign in to comment.