Skip to content

Commit

Permalink
Switch canvases.* APIs to application/json format for more stability (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch authored Oct 25, 2024
1 parent 5fb245a commit 3b9652a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 34 deletions.
48 changes: 32 additions & 16 deletions integration_tests/web/test_canvases.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ def test_sync(self):
document_content={
"type": "markdown",
"markdown": """# My canvas
---
## Hey
What's up?
""",
## Hey
What's up?
- foo
- bar
""",
},
)
self.assertIsNone(channel_canvas.get("error"))
Expand All @@ -46,10 +50,14 @@ def test_sync(self):
document_content={
"type": "markdown",
"markdown": """# My canvas
---
## Hey
What's up?
""",
## Hey
What's up?
- foo
- bar
""",
},
)
self.assertIsNone(standalone_canvas.get("error"))
Expand Down Expand Up @@ -96,10 +104,14 @@ async def test_async(self):
document_content={
"type": "markdown",
"markdown": """# My canvas
---
## Hey
What's up?
""",
## Hey
What's up?
- foo
- bar
""",
},
)
self.assertIsNone(channel_canvas.get("error"))
Expand All @@ -110,10 +122,14 @@ async def test_async(self):
document_content={
"type": "markdown",
"markdown": """# My canvas
---
## Hey
What's up?
""",
## Hey
What's up?
- foo
- bar
""",
},
)
self.assertIsNone(standalone_canvas.get("error"))
Expand Down
12 changes: 6 additions & 6 deletions slack_sdk/web/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2300,8 +2300,8 @@ async def canvases_create(
"""Create Canvas for a user
https://api.slack.com/methods/canvases.create
"""
kwargs.update({"title": title, "document_content": json.dumps(document_content)})
return await self.api_call("canvases.create", params=kwargs)
kwargs.update({"title": title, "document_content": document_content})
return await self.api_call("canvases.create", json=kwargs)

async def canvases_edit(
self,
Expand All @@ -2313,8 +2313,8 @@ async def canvases_edit(
"""Update an existing canvas
https://api.slack.com/methods/canvases.edit
"""
kwargs.update({"canvas_id": canvas_id, "changes": json.dumps(changes)})
return await self.api_call("canvases.edit", params=kwargs)
kwargs.update({"canvas_id": canvas_id, "changes": changes})
return await self.api_call("canvases.edit", json=kwargs)

async def canvases_delete(
self,
Expand Down Expand Up @@ -3353,8 +3353,8 @@ async def conversations_canvases_create(
"""Create a Channel Canvas for a channel
https://api.slack.com/methods/conversations.canvases.create
"""
kwargs.update({"channel_id": channel_id, "document_content": json.dumps(document_content)})
return await self.api_call("conversations.canvases.create", params=kwargs)
kwargs.update({"channel_id": channel_id, "document_content": document_content})
return await self.api_call("conversations.canvases.create", json=kwargs)

async def dialog_open(
self,
Expand Down
12 changes: 6 additions & 6 deletions slack_sdk/web/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2291,8 +2291,8 @@ def canvases_create(
"""Create Canvas for a user
https://api.slack.com/methods/canvases.create
"""
kwargs.update({"title": title, "document_content": json.dumps(document_content)})
return self.api_call("canvases.create", params=kwargs)
kwargs.update({"title": title, "document_content": document_content})
return self.api_call("canvases.create", json=kwargs)

def canvases_edit(
self,
Expand All @@ -2304,8 +2304,8 @@ def canvases_edit(
"""Update an existing canvas
https://api.slack.com/methods/canvases.edit
"""
kwargs.update({"canvas_id": canvas_id, "changes": json.dumps(changes)})
return self.api_call("canvases.edit", params=kwargs)
kwargs.update({"canvas_id": canvas_id, "changes": changes})
return self.api_call("canvases.edit", json=kwargs)

def canvases_delete(
self,
Expand Down Expand Up @@ -3344,8 +3344,8 @@ def conversations_canvases_create(
"""Create a Channel Canvas for a channel
https://api.slack.com/methods/conversations.canvases.create
"""
kwargs.update({"channel_id": channel_id, "document_content": json.dumps(document_content)})
return self.api_call("conversations.canvases.create", params=kwargs)
kwargs.update({"channel_id": channel_id, "document_content": document_content})
return self.api_call("conversations.canvases.create", json=kwargs)

def dialog_open(
self,
Expand Down
12 changes: 6 additions & 6 deletions slack_sdk/web/legacy_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2302,8 +2302,8 @@ def canvases_create(
"""Create Canvas for a user
https://api.slack.com/methods/canvases.create
"""
kwargs.update({"title": title, "document_content": json.dumps(document_content)})
return self.api_call("canvases.create", params=kwargs)
kwargs.update({"title": title, "document_content": document_content})
return self.api_call("canvases.create", json=kwargs)

def canvases_edit(
self,
Expand All @@ -2315,8 +2315,8 @@ def canvases_edit(
"""Update an existing canvas
https://api.slack.com/methods/canvases.edit
"""
kwargs.update({"canvas_id": canvas_id, "changes": json.dumps(changes)})
return self.api_call("canvases.edit", params=kwargs)
kwargs.update({"canvas_id": canvas_id, "changes": changes})
return self.api_call("canvases.edit", json=kwargs)

def canvases_delete(
self,
Expand Down Expand Up @@ -3355,8 +3355,8 @@ def conversations_canvases_create(
"""Create a Channel Canvas for a channel
https://api.slack.com/methods/conversations.canvases.create
"""
kwargs.update({"channel_id": channel_id, "document_content": json.dumps(document_content)})
return self.api_call("conversations.canvases.create", params=kwargs)
kwargs.update({"channel_id": channel_id, "document_content": document_content})
return self.api_call("conversations.canvases.create", json=kwargs)

def dialog_open(
self,
Expand Down

0 comments on commit 3b9652a

Please sign in to comment.