Skip to content

Commit

Permalink
refactor: remove ref field
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Maximenyuk committed Jun 24, 2024
1 parent 2ab29a6 commit a5352fb
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 11 deletions.
7 changes: 1 addition & 6 deletions pybotx/models/sync_smartapp_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class BotAPISyncSmartAppSender(VerifiedPayloadBaseModel):


class BotAPISyncSmartAppPayload(VerifiedPayloadBaseModel):
ref: UUID
data: Dict[str, Any]
files: List[APIAsyncFile]

Expand Down Expand Up @@ -82,7 +81,7 @@ def to_domain(self, raw_smartapp_event: Dict[str, Any]) -> SmartAppEvent:
"type": "smartapp_rpc",
"params": self.payload.data,
},
ref=self.payload.ref,
ref=None,
smartapp_id=self.bot_id,
opts=None,
files=[convert_async_file_to_domain(file) for file in self.payload.files],
Expand All @@ -92,14 +91,12 @@ def to_domain(self, raw_smartapp_event: Dict[str, Any]) -> SmartAppEvent:


class BotAPISyncSmartAppEventResultResponse(UnverifiedPayloadBaseModel):
ref: UUID
data: Any
files: List[APIAsyncFile]

@classmethod
def from_domain(
cls,
ref: UUID,
data: Any,
files: Missing[List[File]] = Undefined,
) -> "BotAPISyncSmartAppEventResultResponse":
Expand All @@ -108,7 +105,6 @@ def from_domain(
api_async_files = [convert_async_file_from_domain(file) for file in files]

return cls(
ref=ref,
data=data,
files=api_async_files,
)
Expand All @@ -117,7 +113,6 @@ def jsonable_dict(self) -> Dict[str, Any]:
return {
"status": "ok",
"result": {
"ref": str(self.ref),
"data": self.data,
"files": [file.jsonable_dict() for file in self.files],
},
Expand Down
2 changes: 1 addition & 1 deletion pybotx/models/system_events/smartapp_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SmartAppEvent(BotCommandBase):
sender: Event sender.
"""

ref: UUID
ref: Optional[UUID]
smartapp_id: UUID
data: Dict[str, Any] # noqa: WPS110
opts: Optional[Dict[str, Any]]
Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ async def handle_sync_smartapp_event(
_: Bot,
) -> BotAPISyncSmartAppEventResultResponse:
return BotAPISyncSmartAppEventResultResponse.from_domain(
ref=event.ref,
data=event.data,
files=event.files,
)
Expand Down
3 changes: 0 additions & 3 deletions tests/test_end_to_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ async def handle_sync_smartapp_event(
_: Bot,
) -> BotAPISyncSmartAppEventResultResponse:
return BotAPISyncSmartAppEventResultResponse.from_domain(
ref=event.ref,
data=event.data["params"],
files=event.files,
)
Expand Down Expand Up @@ -429,7 +428,6 @@ def test__web_app__sync_smartapp_event__success(bot: Bot, bot_id: UUID) -> None:
},
"method": "list.get",
"payload": {
"ref": "6fafda2c-6505-57a5-a088-25ea5d1d0364",
"data": {"category_id": 1},
"files": [
{
Expand Down Expand Up @@ -459,7 +457,6 @@ def test__web_app__sync_smartapp_event__success(bot: Bot, bot_id: UUID) -> None:
assert response.json() == {
"status": "ok",
"result": {
"ref": "6fafda2c-6505-57a5-a088-25ea5d1d0364",
"data": {"category_id": 1},
"files": [
{
Expand Down

0 comments on commit a5352fb

Please sign in to comment.