etrias / ewarehousing-connector
此包已被废弃,不再维护。未建议替代包。
此包的最新版本(v2.3.2)没有可用的许可证信息。
ewarehousing api 的 PHP 连接器
v2.3.2
2020-04-24 09:26 UTC
Requires
- php: >=5.5
- ext-json: *
- guzzlehttp/guzzle: ^6.2
- jms/serializer: ^1.8 || ^2.0 || ^3.0
- symfony/cache: ^3.4 || ^4.0 || ^5.0
- symfony/yaml: ^3.4 || ^4.0 || ^5.0
Requires (Dev)
- doctrine/cache: ^1.6
- friendsofphp/php-cs-fixer: ^2.4
- phpunit/phpunit: ^6.2
- ramsey/uuid: ^3.7
Suggests
- doctrine/cache: Speed up jms, because it can cache metadata
This package is auto-updated.
Last update: 2021-06-24 12:14:38 UTC
README
ewarehousing-connector
ewarehousing api 的 PHP 连接器
## 安装示例
/** * @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; } }