Skip to content

Commit

Permalink
feat: Add share_history field to Chats API
Browse files Browse the repository at this point in the history
  • Loading branch information
nidemidovich committed Aug 1, 2022
1 parent eb5b3ee commit 6d4c550
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pybotx/client/chats_api/chat_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class BotXAPIChatInfoResult(VerifiedPayloadBaseModel):
inserted_at: dt
members: List[BotXAPIChatInfoMember]
name: str
shared_history: bool


class BotXAPIChatInfoResponsePayload(VerifiedPayloadBaseModel):
Expand All @@ -61,6 +62,7 @@ def to_domain(self) -> ChatInfo:
created_at=self.result.inserted_at,
members=members,
name=self.result.name,
shared_history=self.result.shared_history,
)


Expand Down
2 changes: 2 additions & 0 deletions pybotx/client/chats_api/list_chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class BotXAPIListChatResult(VerifiedPayloadBaseModel):
members: List[UUID]
inserted_at: datetime
updated_at: datetime
shared_history: bool


class BotXAPIListChatResponsePayload(VerifiedPayloadBaseModel):
Expand All @@ -36,6 +37,7 @@ def to_domain(self) -> List[ChatListItem]:
members=chat_item.members,
created_at=chat_item.inserted_at,
updated_at=chat_item.updated_at,
shared_history=chat_item.shared_history,
)
for chat_item in self.result
if isinstance(chat_item, BotXAPIListChatResult)
Expand Down
4 changes: 4 additions & 0 deletions pybotx/models/chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ChatListItem:
members: Chat members.
created_at: Chat creation datetime.
updated_at: Last chat update datetime.
shared_history: Is shared history enabled.
"""

chat_id: UUID
Expand All @@ -34,6 +35,7 @@ class ChatListItem:
members: List[UUID]
created_at: datetime
updated_at: datetime
shared_history: bool


@dataclass
Expand Down Expand Up @@ -63,6 +65,7 @@ class ChatInfo:
created_at: Chat creation datetime.
members: Chat members.
name: Chat name.
shared_history: Is shared history enabled.
"""

chat_type: ChatTypes
Expand All @@ -72,3 +75,4 @@ class ChatInfo:
created_at: dt
members: List[ChatInfoMember]
name: str
shared_history: bool
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pybotx"
version = "0.47.0"
version = "0.48.0"
description = "A python library for interacting with eXpress BotX API"
authors = [
"Sidnev Nikolay <[email protected]>",
Expand Down
2 changes: 2 additions & 0 deletions tests/client/chats_api/test_chat_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ async def test__chat_info__succeed(
},
],
"name": "Group Chat Example",
"shared_history": False,
},
},
),
Expand Down Expand Up @@ -137,6 +138,7 @@ async def test__chat_info__succeed(
),
],
name="Group Chat Example",
shared_history=False,
)

assert endpoint.called
5 changes: 5 additions & 0 deletions tests/client/chats_api/test_list_chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ async def test__list_chats__succeed(
],
"inserted_at": "2019-08-29T11:22:48.358586Z",
"updated_at": "2019-08-30T21:02:10.453786Z",
"shared_history": False,
},
],
},
Expand All @@ -76,6 +77,7 @@ async def test__list_chats__succeed(
],
created_at=datetime_formatter("2019-08-29T11:22:48.358586Z"),
updated_at=datetime_formatter("2019-08-30T21:02:10.453786Z"),
shared_history=False,
),
]
assert endpoint.called
Expand Down Expand Up @@ -110,6 +112,7 @@ async def test__list_chats__unsupported_chats_types(
],
"inserted_at": "2019-08-29T11:22:48.358586Z",
"updated_at": "2019-08-30T21:02:10.453786Z",
"shared_history": False,
},
{
"group_chat_id": "c7faf797-5470-4d18-9b1c-379bb8b24d48",
Expand All @@ -122,6 +125,7 @@ async def test__list_chats__unsupported_chats_types(
],
"inserted_at": "2019-08-29T11:22:48.358586Z",
"updated_at": "2019-08-30T21:02:10.453786Z",
"shared_history": False,
},
],
},
Expand All @@ -148,6 +152,7 @@ async def test__list_chats__unsupported_chats_types(
],
created_at=datetime_formatter("2019-08-29T11:22:48.358586Z"),
updated_at=datetime_formatter("2019-08-30T21:02:10.453786Z"),
shared_history=False,
),
]
assert endpoint.called

0 comments on commit 6d4c550

Please sign in to comment.