Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: providing some actions with issues, queues and users from API #8

Merged
merged 2 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: BytesPayload instead of pure bytes for post/patch/put requests
  • Loading branch information
danfimov committed Sep 18, 2023
commit 6ae1462982c43ab193cefbac5b582e5830b45fe0
13 changes: 11 additions & 2 deletions ya_tracker_client/domain/client/base.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from abc import ABC, abstractmethod
from http import HTTPStatus
from json import dumps
from logging import getLogger
from typing import Any

from aiohttp import BytesPayload

from ya_tracker_client.domain.client.errors import (
ClientAuthError,
ClientError,
Expand Down Expand Up @@ -55,11 +58,17 @@ async def request(
payload: dict[str, Any] | None = None,
) -> bytes:
uri = f"{self._base_url}/{self._api_version}{uri}"

bytes_payload = BytesPayload(
value=bytes(dumps(payload), encoding="utf-8"),
content_type="application/json",
)

status, body = await self._make_request(
method=method,
url=uri,
params=params,
data=payload,
data=bytes_payload,
)
self._check_status(status, body)
return body
Expand All @@ -70,7 +79,7 @@ async def _make_request(
method: str,
url: str,
params: dict[str, Any] | None = None,
data: bytes | None = None,
data: bytes | BytesPayload | None = None,
) -> tuple[int, bytes]:
"""
Get raw response from via http-client.
Expand Down
4 changes: 2 additions & 2 deletions ya_tracker_client/infrastructure/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from ssl import create_default_context
from typing import Any

from aiohttp import ClientSession, ClientTimeout, TCPConnector
from aiohttp import BytesPayload, ClientSession, ClientTimeout, TCPConnector
from certifi import where

from ya_tracker_client.domain.client import BaseClient
Expand Down Expand Up @@ -51,7 +51,7 @@ async def _make_request(
method: str,
url: str,
params: dict[str, Any] | None = None,
data: bytes | None = None,
data: bytes | BytesPayload | None = None,
) -> tuple[int, bytes]:
session = self._get_session()
async with session.request(method, url, params=params, data=data) as response:
Expand Down
Loading