Skip to content

Commit

Permalink
Added bucket property
Browse files Browse the repository at this point in the history
  • Loading branch information
Issei Horie committed Jun 23, 2019
1 parent 2f1aeb1 commit 141b1ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 11 additions & 2 deletions typetalk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

class Client:
def __init__(self, loop=None, token=None, run_async=False, is_bot=False):
self.http = HTTPClient(loop=loop, token=token, run_async=run_async, is_bot=is_bot)
self.http = HTTPClient(
loop=loop,
token=token,
run_async=run_async,
is_bot=is_bot)

def post_message(self, topic_id, message):
r = Route('POST', '/api/v1/topics/{topic_id}', topic_id=topic_id)
Expand All @@ -23,4 +27,9 @@ def post_message(self, topic_id, message):
return self.http.request(r, json=payload)

self.http.loop = asyncio.get_event_loop()
return self.http.loop.run_until_complete(self.http.request(r, json=payload))
return self.http.loop.run_until_complete(
self.http.request(
r,
json=payload
)
)
4 changes: 4 additions & 0 deletions typetalk/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def __init__(self, method, path, **parameters):
self.path = path
url = '{}{}'.format(self.BASE, self.path)

@property
def bucket(self):
return '{0.method}:{0.path}'.format(self)


class HTTPClient:
"""Represents an HTTP client sending HTTP requests to the Typetalk API."""
Expand Down

0 comments on commit 141b1ab

Please sign in to comment.