diff --git a/methods/README.md b/methods/README.md index 5044596..847080a 100644 --- a/methods/README.md +++ b/methods/README.md @@ -34,6 +34,11 @@ $ slack run chat_post_message.py # Make the request - **[blocks.validate](https://docs.slack.dev/reference/methods/blocks.validate)**: Validates blocks, messages, and views Block Kit JSON payloads. [Implementation](./src/blocks/blocks_validate.py). +### canvases + +- **[canvases.create](https://docs.slack.dev/reference/methods/canvases.create)**: Create canvas for a user. [Implementation](./src/canvases/canvases_create.py). +- **[canvases.getContent](https://docs.slack.dev/reference/methods/canvases.getContent)**: Get the content of a canvas as markdown (default) or HTML. [Implementation](./src/canvases/canvases_get_content.py). + ### chat - **[chat.postMessage](https://docs.slack.dev/reference/methods/chat.postmessage)**: Sends a message to a channel. [Implementation](./src/chat/chat_post_message.py). diff --git a/methods/src/canvases/.slack/.gitignore b/methods/src/canvases/.slack/.gitignore new file mode 100644 index 0000000..973ba60 --- /dev/null +++ b/methods/src/canvases/.slack/.gitignore @@ -0,0 +1,2 @@ +apps.dev.json +cache/ diff --git a/methods/src/canvases/.slack/config.json b/methods/src/canvases/.slack/config.json new file mode 100644 index 0000000..909afbe --- /dev/null +++ b/methods/src/canvases/.slack/config.json @@ -0,0 +1,6 @@ +{ + "manifest": { + "source": "local" + }, + "project_id": "00000000-0000-0000-0000-000000000000" +} diff --git a/methods/src/canvases/.slack/hooks.json b/methods/src/canvases/.slack/hooks.json new file mode 100644 index 0000000..ce474c9 --- /dev/null +++ b/methods/src/canvases/.slack/hooks.json @@ -0,0 +1,5 @@ +{ + "hooks": { + "get-hooks": "python3 -m slack_cli_hooks.hooks.get_hooks" + } +} diff --git a/methods/src/canvases/__init__.py b/methods/src/canvases/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/methods/src/canvases/canvases_create.py b/methods/src/canvases/canvases_create.py new file mode 100644 index 0000000..2ba7927 --- /dev/null +++ b/methods/src/canvases/canvases_create.py @@ -0,0 +1,21 @@ +import os + +from slack_sdk import WebClient + +# Read a token from an environment variable +token = os.environ.get("SLACK_TOKEN") + +# Initialize +client = WebClient(token=token) + +# Call the canvases.create method +response = client.canvases_create( + title="Your Brilliant Title", + document_content={ + "type": "markdown", + "markdown": "> standalone canvas!", + }, +) + +# Inspect the response +print(response) diff --git a/methods/src/canvases/canvases_get_content.py b/methods/src/canvases/canvases_get_content.py new file mode 100644 index 0000000..db75a73 --- /dev/null +++ b/methods/src/canvases/canvases_get_content.py @@ -0,0 +1,18 @@ +import os + +from slack_sdk import WebClient + +# Read a token from an environment variable +token = os.environ.get("SLACK_TOKEN") + +# Initialize +client = WebClient(token=token) + +# Call the canvases.getContent method +response = client.canvases_getContent( + canvas_id="F1234ABCD", + content_type="markdown", +) + +# Inspect the response +print(response) diff --git a/methods/src/canvases/manifest.json b/methods/src/canvases/manifest.json new file mode 100644 index 0000000..9e56919 --- /dev/null +++ b/methods/src/canvases/manifest.json @@ -0,0 +1,22 @@ +{ + "display_information": { + "name": "Slack API Methods", + "description": "Example implementations to call \"canvases\" methods" + }, + "features": { + "bot_user": { + "display_name": "Slack API Methods", + "always_online": true + } + }, + "oauth_config": { + "scopes": { + "bot": ["canvases:read", "canvases:write"] + } + }, + "settings": { + "org_deploy_enabled": true, + "socket_mode_enabled": false, + "token_rotation_enabled": false + } +}