-
Notifications
You must be signed in to change notification settings - Fork 91
Service Contracts
The search API endpoint is the main source of Adobe Stock assets and should be configurable and extensible. We encourage the re-usage of Magento framework interfaces is such cases.
interface GetImageListInterface
{
/**
* @param SearchCriteriaInterface $searchCriteria
* @return SearchResultsInterface
*/
public function execute(SearchCriteriaInterface $searchCriteria) : SearchResultsInterface;
}
The interface accepts search criteria object that implements generic framework interface: \Magento\Framework\Api\SearchCriteriaInterface
. The returned object will implement \Magento\Framework\Api\SearchResultsInterface
interface that also defined in Magento framework.
In order to persist images to the Magento gallery, we defined two interfaces that will provide the ability to save image preview and licensed the image to the filesystem.
Both interfaces are accepting Adobe Stock media id for asset identification and download to the media gallery.
interface SaveImagePreviewInterface
{
/**
* @param int $mediaId
* @return bool
*/
public function execute(int $mediaId): bool;
}
interface SaveLicensedImageInterface
{
/**
* @param int $mediaId
* @return bool
*/
public function execute(int $mediaId): bool;
}
It's required to save image metadata along with image file to implement functionality that's need such data for business logic.
Proposed interface is a typical repository in Magento to work with entities.
interface ImageMetadataRepositoryInterface
{
/**
* @param ImageMetadataInterface $entityData
* @return int
*/
public function save(ImageMetadataInterface $entityData) : int;
/**
* @param int $entityId
* @return ImageMetadataInterface
*/
public function get(int $entityId) : ImageMetadataInterface;
/**
* @param ImageMetadataInterface $entityData
* @return void
* @throws \Magento\Framework\Exception\NoSuchEntityException
* @throws \Magento\Framework\Exception\CouldNotDeleteException
*/
public function delete(ImageMetadataInterface $entityData);
/**
* @param int $entityId
* @return void
* @throws \Magento\Framework\Exception\NoSuchEntityException
* @throws \Magento\Framework\Exception\CouldNotDeleteException
*/
public function deleteById(int $entityId);
/**
* @param SearchCriteriaInterface $searchCriteria
* @return SearchResultsInterface
*/
public function getList(SearchCriteriaInterface $searchCriteria) : SearchResultsInterface;
}