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

Manage reference entities #1

Merged
merged 1 commit into from
Feb 14, 2023
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
33 changes: 29 additions & 4 deletions akeneo_api_client/client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
# -*- coding: utf-8 -*-

from akeneo_api_client.auth import *
from akeneo_api_client.resources import *
import requests

from akeneo_api_client.auth import Auth
from akeneo_api_client.resources import (
AssociationTypesPool,
AttributesPool,
AttributeGroupsPool,
CategoriesPool,
ChannelsPool,
CurrenciesPool,
FamiliesPool,
LocalesPool,
MeasureFamiliesPool,
MediaFilesPool,
ProductsPool,
ProductModelsPool,
PublishedProductsPool,
AssetFamilyPool,
ReferenceEntityPool,
)
from akeneo_api_client.utils import urljoin


class Client:
Expand Down Expand Up @@ -68,6 +85,10 @@ def _init(self, base_url, session, auth):
urljoin(self._base_url, self.BASIC_API_PATH, 'published-products/'), session),
'asset_families': AssetFamilyPool(
urljoin(self._base_url, self.BASIC_API_PATH, 'asset-families/'), session),
"reference_entities": ReferenceEntityPool(
urljoin(self._base_url, self.BASIC_API_PATH, "reference-entities/"),
session,
),
}

@property
Expand Down Expand Up @@ -130,3 +151,7 @@ def published_products(self):
@property
def asset_families(self):
return self._resources["asset_families"]

@property
def reference_entities(self):
return self._resources["reference_entities"]
24 changes: 24 additions & 0 deletions akeneo_api_client/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,3 +361,27 @@ def assets(self, code):
urljoin(self._endpoint, code, 'assets/'),
self._session
)


class ReferenceEntityRecordPool(
ResourcePool,
CodeBasedResource,
GettableResource,
ListableResource,
UpdatableResource,
UpdatableListResource,
):
pass


class ReferenceEntityPool(
ResourcePool,
CodeBasedResource,
GettableResource,
ListableResource,
UpdatableResource,
):
def records(self, entity_code):
return ReferenceEntityRecordPool(
urljoin(self._endpoint, entity_code, "records/"), self._session
)