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

Remove deprecated API interface #137

Merged
merged 4 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions src/commercetools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from .client import Client
from .exceptions import CommercetoolsError
from .version import __version__

__all__ = ["Client", "CommercetoolsError"]
__all__ = ["CommercetoolsError"]
9 changes: 1 addition & 8 deletions src/commercetools/base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from commercetools.constants import HEADER_CORRELATION_ID
from commercetools.exceptions import CommercetoolsError
from commercetools.helpers import _concurrent_retry
from commercetools.services import ServicesMixin
from commercetools.utils import BaseTokenSaver, DefaultTokenSaver, fix_token_url
from commercetools.version import __version__

Expand Down Expand Up @@ -53,7 +52,7 @@ def __init__(
) -> None:
# Use environment variables as fallback
config = {
"project_key": project_key,
"project_key": project_key or "example-project",
"client_id": client_id,
"client_secret": client_secret,
"url": url,
Expand Down Expand Up @@ -231,9 +230,3 @@ def _get_user_agent(self):
sys.platform,
arch,
)


class Client(BaseClient, ServicesMixin):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._base_url = f"{self._config['url']}/{self._config['project_key']}/"
5 changes: 2 additions & 3 deletions src/commercetools/checkout/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
# contribute to this project then please do not edit this file directly
# but send a pull request to the Lab Digital fork of rmf-codegen at
# https://github.com/labd/rmf-codegen

from commercetools.client import BaseClient
from commercetools.base_client import BaseClient


class Client(BaseClient):
def __init__(self, *args, **kwargs):
kwargs.setdefault("url", "https://checkout.{region}.commercetools.com")
super().__init__(self, **kwargs)
super().__init__(**kwargs)
140 changes: 0 additions & 140 deletions src/commercetools/client.py

This file was deleted.

17 changes: 3 additions & 14 deletions src/commercetools/contrib/pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import pytest
import requests

from commercetools import Client
from commercetools.platform.client import Client as PlatformClient
from commercetools.testing import backend_mocker
from commercetools.testing.server import Server
Expand All @@ -25,7 +24,9 @@ def commercetools_api():


@pytest.fixture
def ct_platform_client(commercetools_api) -> typing.Generator[Client, None, None]:
def ct_platform_client(
commercetools_api,
) -> typing.Generator[PlatformClient, None, None]:
yield PlatformClient(
client_id="client-id",
client_secret="client-secret",
Expand All @@ -35,18 +36,6 @@ def ct_platform_client(commercetools_api) -> typing.Generator[Client, None, None
)


@pytest.fixture
def commercetools_client(commercetools_api) -> typing.Generator[Client, None, None]:
yield Client(
project_key="unittest",
client_id="client-id",
client_secret="client-secret",
scope=[],
url="https://api.europe-west1.gcp.commercetools.com",
token_url="https://auth.europe-west1.gcp.commercetools.com/oauth/token",
)


@pytest.fixture()
def commercetools_http_server(commercetools_api):
is_running = threading.Event()
Expand Down
4 changes: 2 additions & 2 deletions src/commercetools/importapi/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# contribute to this project then please do not edit this file directly
# but send a pull request to the Lab Digital fork of rmf-codegen at
# https://github.com/labd/rmf-codegen
from commercetools.client import BaseClient
from commercetools.base_client import BaseClient

from .by_project_key_request_builder import ByProjectKeyRequestBuilder

Expand All @@ -13,7 +13,7 @@ class Client(BaseClient):

def __init__(self, *args, **kwargs):
kwargs.setdefault("url", "https://import.europe-west1.gcp.commercetools.com")
super().__init__(self, **kwargs)
super().__init__(**kwargs)

def with_project_key_value(self, project_key: str) -> ByProjectKeyRequestBuilder:
return ByProjectKeyRequestBuilder(
Expand Down
4 changes: 2 additions & 2 deletions src/commercetools/platform/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# contribute to this project then please do not edit this file directly
# but send a pull request to the Lab Digital fork of rmf-codegen at
# https://github.com/labd/rmf-codegen
from commercetools.client import BaseClient
from commercetools.base_client import BaseClient

from .by_project_key_request_builder import ByProjectKeyRequestBuilder

Expand All @@ -13,7 +13,7 @@ class Client(BaseClient):

def __init__(self, *args, **kwargs):
kwargs.setdefault("url", "https://api.{region}.commercetools.com")
super().__init__(self, **kwargs)
super().__init__(**kwargs)

def with_project_key(self, project_key: str) -> ByProjectKeyRequestBuilder:
"""The Project endpoint is used to retrieve certain information from a project."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def get(
obj = ErrorResponse.deserialize(response.json())
raise self._client._create_exception(obj, response)
elif response.status_code == 404:
return None
raise self._client._create_exception(None, response)
warnings.warn("Unhandled status code %d" % response.status_code)

def head(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get(
obj = ErrorResponse.deserialize(response.json())
raise self._client._create_exception(obj, response)
elif response.status_code == 404:
return None
raise self._client._create_exception(None, response)
warnings.warn("Unhandled status code %d" % response.status_code)

def head(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get(
obj = ErrorResponse.deserialize(response.json())
raise self._client._create_exception(obj, response)
elif response.status_code == 404:
return None
raise self._client._create_exception(None, response)
warnings.warn("Unhandled status code %d" % response.status_code)

def head(
Expand Down Expand Up @@ -94,5 +94,5 @@ def delete(
obj = ErrorResponse.deserialize(response.json())
raise self._client._create_exception(obj, response)
elif response.status_code == 404:
return None
raise self._client._create_exception(None, response)
warnings.warn("Unhandled status code %d" % response.status_code)
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def get(
obj = ErrorResponse.deserialize(response.json())
raise self._client._create_exception(obj, response)
elif response.status_code == 404:
return None
raise self._client._create_exception(None, response)
warnings.warn("Unhandled status code %d" % response.status_code)

def head(
Expand Down Expand Up @@ -123,5 +123,5 @@ def post(
obj = ErrorResponse.deserialize(response.json())
raise self._client._create_exception(obj, response)
elif response.status_code == 404:
return None
raise self._client._create_exception(None, response)
warnings.warn("Unhandled status code %d" % response.status_code)
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ def post(
obj = ErrorResponse.deserialize(response.json())
raise self._client._create_exception(obj, response)
elif response.status_code == 404:
return None
raise self._client._create_exception(None, response)
warnings.warn("Unhandled status code %d" % response.status_code)
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get(
obj = ErrorResponse.deserialize(response.json())
raise self._client._create_exception(obj, response)
elif response.status_code == 404:
return None
raise self._client._create_exception(None, response)
warnings.warn("Unhandled status code %d" % response.status_code)

def head(
Expand Down Expand Up @@ -98,7 +98,7 @@ def post(
obj = ErrorResponse.deserialize(response.json())
raise self._client._create_exception(obj, response)
elif response.status_code == 404:
return None
raise self._client._create_exception(None, response)
warnings.warn("Unhandled status code %d" % response.status_code)

def delete(
Expand All @@ -122,5 +122,5 @@ def delete(
obj = ErrorResponse.deserialize(response.json())
raise self._client._create_exception(obj, response)
elif response.status_code == 404:
return None
raise self._client._create_exception(None, response)
warnings.warn("Unhandled status code %d" % response.status_code)
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get(
obj = ErrorResponse.deserialize(response.json())
raise self._client._create_exception(obj, response)
elif response.status_code == 404:
return None
raise self._client._create_exception(None, response)
warnings.warn("Unhandled status code %d" % response.status_code)

def head(
Expand Down Expand Up @@ -98,7 +98,7 @@ def post(
obj = ErrorResponse.deserialize(response.json())
raise self._client._create_exception(obj, response)
elif response.status_code == 404:
return None
raise self._client._create_exception(None, response)
warnings.warn("Unhandled status code %d" % response.status_code)

def delete(
Expand All @@ -122,5 +122,5 @@ def delete(
obj = ErrorResponse.deserialize(response.json())
raise self._client._create_exception(obj, response)
elif response.status_code == 404:
return None
raise self._client._create_exception(None, response)
warnings.warn("Unhandled status code %d" % response.status_code)
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def get(
obj = ErrorResponse.deserialize(response.json())
raise self._client._create_exception(obj, response)
elif response.status_code == 404:
return None
raise self._client._create_exception(None, response)
warnings.warn("Unhandled status code %d" % response.status_code)

def head(
Expand Down Expand Up @@ -137,5 +137,5 @@ def post(
obj = ErrorResponse.deserialize(response.json())
raise self._client._create_exception(obj, response)
elif response.status_code == 404:
return None
raise self._client._create_exception(None, response)
warnings.warn("Unhandled status code %d" % response.status_code)
Loading
Loading