mediaopt / image-similarity-as-a-service-sdk
This package's canonical repository appears to be gone and the package has been frozen as a result.
dev-master
2021-08-18 11:19 UTC
Requires
- ext-curl: *
- ext-json: *
- guzzlehttp/guzzle: ~6.3 || ~7.3
- monolog/monolog: 1.*
- psr/log: ^1.1
Requires (Dev)
- phpunit/phpunit: 6.*
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2024-09-18 17:48:32 UTC
README
You could use this SDK to build your own integration
Installation
With Composer, run
composer require mediaopt/image-similarity-as-a-service-sdk
Configuration
You have to create a new class that implements the Mediaopt\ImageSdk\AbstractConfigurator
// app/MyConfigurator.php
use Mediaopt\ImageSdk\AbstractConfigurator;
use Monolog\Handler\HandlerInterface;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger;
class MyConfigurator implements AbstractConfigurator
{
/**
* @return string
*/
protected function getUsername()
{
//Take it from somewhere
return 'username';
}
/**
* @return string
*/
protected function getPassword()
{
//Take it from somewhere
return 'password';
}
/**
* @return int
*/
protected function getEnvironment()
{
// Take it from somewhere
// Value should be on of
// self::ENVIRONMENT_PRODUCTION
// or
// self::ENVIRONMENT_STAGE
return self::ENVIRONMENT_STAGE;
}
/**
* @return HandlerInterface
*/
protected function buildLogHandler()
{
// You could return any handler
// that implements Monolog's HandlerInterface
return new RotatingFileHandler(
'/dir/to/logs/',
10, //Max files to keep
Logger::ERROR
);
}
}
Create SDK services
//app/my_application.php
use Mediaopt\ImageSdk\Main;
use Mediaopt\ImageSdk\Api\Product;
use Mediaopt\ImageSdk\Api\Image;
use Mediaopt\ImageSdk\Api\Category;
$configurator = new MyConfigurator();
$sdk = new Main($configurator);
/* @var $productService Product */
$productService = $sdk->buildProductService();
/* @var $imageService Image */
$imageService = $sdk->buildImageService();
/* @var $categoryService Category */
$categoryService = $sdk->buildCategoryService();
Use method of services
Image service has the following methods:
deleteImagesByImageId
deleteImagesByProductId
deleteImage
sendImage
getSimilarProducts
getSimilarProductsForCategory
Product service has the following methods:
getProductIds
sendProductData
Category service has the following method:
sendCategoryData