Skip to content

Commit

Permalink
Merge pull request #43 from upwork/v1.3.7
Browse files Browse the repository at this point in the history
Add Room Messages API
  • Loading branch information
mnovozhylov authored May 8, 2020
2 parents 19d4c89 + a5a9d96 commit 147fa24
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
6 changes: 6 additions & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
Changelog
***************

.. _1.3.7:

Version 1.3.7
-------------
* Add Room Messages API

.. _1.3.6:

Version 1.3.6
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
README = readme.read()
readme.close()

VERSION = (1, 3, 6, 0, 0)
VERSION = (1, 3, 7, 0, 0)


def get_version():
Expand Down
2 changes: 1 addition & 1 deletion upwork/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"""

VERSION = '1.3.6'
VERSION = '1.3.7'


def get_version():
Expand Down
16 changes: 16 additions & 0 deletions upwork/routers/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ def get_room_details(self, company, room_id, params = {}):
result = self.get(url, data=params)
return result.get(url, result)

def get_room_messages(self, company, room_id, params = {}):
"""
Get messages from a specific room
*Parameters:*
:company: Company ID
:room_id Room ID
:params: List of parameters
"""
url = '{0}/rooms/{1}/stories'.format(company, room_id)
result = self.get(url, data=params)
return result.get(url, result)

def get_room_by_offer(self, company, offer_id, params = {}):
"""
Get a specific room by offer ID
Expand Down
8 changes: 8 additions & 0 deletions upwork/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,14 @@ def test_get_room_details():
assert messages.get_room_details("testcompany", "room-id") ==\
room_dict, messages.get_room_details("testcompany", "room-id")

@patch('urllib3.PoolManager.urlopen', patched_urlopen_room)
def test_get_room_messages():
messages = get_client().messages

#test get_room_messages
assert messages.get_room_messages("testcompany", "room-id") ==\
room_dict, messages.get_room_messages("testcompany", "room-id")

@patch('urllib3.PoolManager.urlopen', patched_urlopen_room)
def test_get_room_by_offer():
messages = get_client().messages
Expand Down

0 comments on commit 147fa24

Please sign in to comment.