2017 © Pedro Peláez
 

library ewarehousing-connector

PHP connector for ewarehousing api

image

etrias/ewarehousing-connector

PHP connector for ewarehousing api

  • Monday, July 16, 2018
  • by etrias
  • Repository
  • 1 Watchers
  • 0 Stars
  • 192 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 24 Versions
  • 26 % Grown

The README.md

Build Status Scrutinizer Code Quality Code Coverage, (*1)

ewarehousing-connector

PHP connector for ewarehousing api, (*2)

Setup example

/**
 * @return array
 */
function getEwhConfig() {
    return [
        'base_uri' => EWH_ENDPOINT,
    ];

}
/**
 * @return callable
 */
function getEwhLogger()
{
    static $loggerMiddleware = null;

    if (!is_callable($loggerMiddleware)) {
        $logger = new Logger('ewarehousing');

        $streamHandler = new \Monolog\Handler\StreamHandler(LOG_DIR.'/ewarehousing.log', Logger::INFO);
        $streamHandler->setFormatter(new \Monolog\Formatter\JsonFormatter());
        $logger->pushHandler($streamHandler);

        $loggerMiddleware = \GuzzleHttp\Middleware::log($logger, new \GuzzleHttp\MessageFormatter());
    }

    return $loggerMiddleware;
}

function getEwhCacheAdapter()
{
    static $adapter = null;

    if (!$adapter instanceof AdapterInterface) {
        $adapter = new RedisAdapter(getRedisClient());
    }

    return $adapter;
}

function getEwhSerializer()
{
    static $serializer = null;

    if (!$serializer instanceof GuzzleClient)
    {
        $serializer = SerializerBuilder::create()
            ->setCacheDir(sys_get_temp_dir().'/jms-cache')
            ->setDebug(true)
            ->addMetadataDir(__DIR__.'/../../../vendor/etrias/ewarehousing-connector/src/Serializer/Metadata', 'Etrias\EwarehousingConnector')
            ->addDefaultDeserializationVisitors()
            ->addDefaultSerializationVisitors()
            ->addDefaultHandlers()
            ->configureHandlers(function (HandlerRegistry $registry) {
                $registry->registerSubscribingHandler(new DateHandler());
            })
            ->setSerializationVisitor('array', new ArraySerializationVisitor(new SerializedNameAnnotationStrategy(new CamelCaseNamingStrategy()), new DefaultAccessorStrategy()))
            ->setDeserializationVisitor('array', new ArrayDeserializationVisitor(new SerializedNameAnnotationStrategy(new CamelCaseNamingStrategy()), new DefaultAccessorStrategy()))
            ->build();
    }

    return $serializer;
}

function getEwhAuthenticationService()
{
    static $authenticationService = null;

    if (!$authenticationService instanceof AuthenticationServiceInterface)
    {
        $client = new EwarehousingClient(getEwhConfig());

        $authenticationService = new AuthenticationService(
            $client,
            getEwhSerializer(),
            EWH_USERNAME,
            EWH_CUSTOMERID,
            EWH_PASSWORD,
            getEwhCacheAdapter()
        );
    }

    return $authenticationService;
}

function getEwhClient()
{
    static $client = null;

    if (!$client instanceof EwarehousingClientInterface) {
        $client = ClientFactory::create()
            ->setAuthenticationService(getEwhAuthenticationService())
            ->setConfig(getEwhConfig())
            ->pushToHandlerStack(getEwhLogger())
            ->build();
    }

    return $client;
}

function getEwhInboundService()
{
    static $service = null;

    if (!$service instanceof InboundServiceInterface) {
        $service = new InboundService(getEwhClient(), getEwhSerializer());
    }

    return $service;
}

function getEwhOrderService()
{
    static $service = null;

    if (!$service instanceof OrderServiceInterface) {
        $service = new OrderService(getEwhClient(), getEwhSerializer());
    }

    return $service;
}

function getEwhStockService()
{
    static $service = null;

    if (!$service instanceof StockServiceInterface) {
        $service = new StockService(getEwhClient(), getEwhSerializer());
    }

    return $service;
}
}

The Versions

16/07 2018
16/07 2018
16/07 2018

dev-feature/IT-2048_orders_updated_after

dev-feature/IT-2048_orders_updated_after

PHP connector for ewarehousing api

  Sources   Download

The Requires

 

The Development Requires

by Christ-Jan

28/05 2018

dev-feature/IT-1841_new_stock_api

dev-feature/IT-1841_new_stock_api

PHP connector for ewarehousing api

  Sources   Download

The Requires

 

The Development Requires

by Christ-Jan

09/02 2018

dev-feature/add_language

dev-feature/add_language

PHP connector for ewarehousing api

  Sources   Download

The Requires

 

The Development Requires

by Christ-Jan

01/02 2018

dev-hotfix/quantity_to_print

dev-hotfix/quantity_to_print

PHP connector for ewarehousing api

  Sources   Download

The Requires

 

The Development Requires

by Christ-Jan

24/11 2017