Skip to content

Commit 28212ea

Browse files
committed
v0.2.1 - added Client.close and upadted readme
1 parent 61c70fe commit 28212ea

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ A small simple wrapper around the [Mystb.in](https://mystb.in/) API.
55
### Features
66

77
[x] - `POST`ing to the API, which will return the provided url. \
8-
[ ] - `GET`ting from the API, provided you know the URL or paste ID. \
8+
[x] - `GET`ting from the API, provided you know the URL or paste ID. \
99
[x] - Ability to pass in a sync or async session / parameter so it is flexible.
1010

1111
[x] - Write a real underlying Client for this, it will be required for... \
@@ -33,7 +33,7 @@ Since the project is considered multi-sync, it will work in a sync/async environ
3333
# async example - it will default to async
3434
import mystbin
3535

36-
mystbin_client = mystbin.MystClient() ## api_key kwarg for authentication also
36+
mystbin_client = mystbin.MystbinClient() ## api_key kwarg for authentication also
3737

3838
await mystbin_client.post("Hello from Mystb.in!", suffix="python")
3939
>>> 'https://mystb.in/<your generated ID>.python'
@@ -45,7 +45,7 @@ import mystbin
4545
import requests
4646

4747
sync_session = requests.Session()
48-
mystbin_client = mystbin.MystClient(session=sync_session) ## optional api_key kwarg also
48+
mystbin_client = mystbin.MystbinClient(session=sync_session) ## optional api_key kwarg also
4949

5050
mystbin_client.post("Hello from sync Mystb.in!", suffix="text")
5151
>>> 'https://mystb.in/<your generated ID>.text'

mystbin/client.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
from .errors import *
3535
from .objects import *
3636

37-
__all__ = ("MystClient", )
37+
__all__ = ("MystbinClient", )
3838

3939

40-
class MystClient:
40+
class MystbinClient:
4141
"""
4242
Client for interacting with the Mystb.in API.
4343
@@ -159,3 +159,8 @@ async def _perform_async_get(self, paste_id: str, syntax: str = None) -> PasteDa
159159
async with self.session.get(f"{API_BASE_URL}/{paste_id}", timeout=aiohttp.ClientTimeout(CLIENT_TIMEOUT)) as response:
160160
paste_data = await response.json()
161161
return PasteData(paste_id, paste_data)
162+
163+
async def close(self):
164+
""" Async only - close the session. """
165+
if self.session and isinstance(self.session, aiohttp.ClientSession):
166+
await self.session.close()

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "mystbin.py"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
description = "A small simple wrapper around the mystb.in API."
55
authors = ["AbstractUmbra <Umbra@AbstractUmbra.xyz>"]
66
license = "MIT"

0 commit comments

Comments
 (0)