90 lines
4.8 KiB
PHP
90 lines
4.8 KiB
PHP
<?php
|
|
|
|
|
|
namespace Yeepay\Yop\Sdk\Service\Promtion;
|
|
|
|
|
|
use Yeepay\Yop\Sdk\Auth\AuthorityReqRegistryImpl;
|
|
use Yeepay\Yop\Sdk\Auth\AuthorizationReqRegistry;
|
|
use Yeepay\Yop\Sdk\Auth\AuthorizationReqSupport;
|
|
use Yeepay\Yop\Sdk\Client\ClientParams;
|
|
use Yeepay\Yop\Sdk\Client\Support\ClientParamsSupport;
|
|
use Yeepay\Yop\Sdk\Config\AppSdkConfig;
|
|
use Yeepay\Yop\Sdk\Config\AppSdkConfigProvider;
|
|
use Yeepay\Yop\Sdk\Config\DefaultAppSdkConfigProvider;
|
|
use Yeepay\Yop\Sdk\Exception\YopClientException;
|
|
|
|
class PromtionClientBuilder
|
|
{
|
|
/**
|
|
* @var AuthorizationReqRegistry
|
|
*/
|
|
private static $authorizationReqRegistry;
|
|
|
|
public static function __init()
|
|
{
|
|
self::$authorizationReqRegistry = new AuthorityReqRegistryImpl();
|
|
self::$authorizationReqRegistry->register('activityListQuery', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
self::$authorizationReqRegistry->register('addRights', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
self::$authorizationReqRegistry->register('add_rights', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
self::$authorizationReqRegistry->register('couponApply', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
self::$authorizationReqRegistry->register('couponListQuery', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
self::$authorizationReqRegistry->register('create_rights_qrcode_adapter', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
self::$authorizationReqRegistry->register('frozen_rights', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
self::$authorizationReqRegistry->register('pointCreate', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
self::$authorizationReqRegistry->register('pointOperate', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
self::$authorizationReqRegistry->register('pointQuery', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
self::$authorizationReqRegistry->register('query_consume_record_adapter', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
self::$authorizationReqRegistry->register('query_rights', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
self::$authorizationReqRegistry->register('rightsCreateQrcode', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
self::$authorizationReqRegistry->register('rightsFrozenRights', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
self::$authorizationReqRegistry->register('rightsQueryConsumeRecords', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
self::$authorizationReqRegistry->register('rightsQueryRights', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
self::$authorizationReqRegistry->register('rightsTransfer', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
self::$authorizationReqRegistry->register('rights_transfer', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
self::$authorizationReqRegistry->register('subsidyApply', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
self::$authorizationReqRegistry->register('subsidyBack', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
self::$authorizationReqRegistry->register('subsidyBackQuery', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
self::$authorizationReqRegistry->register('subsidyQuery', AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
|
}
|
|
|
|
/**
|
|
* @var ClientParams
|
|
*/
|
|
private $clientParams;
|
|
|
|
/**
|
|
* PromtionClientBuilder constructor.
|
|
* @param ClientParams $clientParams
|
|
*/
|
|
public function __construct(ClientParams $clientParams)
|
|
{
|
|
$this->clientParams = $clientParams;
|
|
}
|
|
|
|
public function build()
|
|
{
|
|
return new PromtionClient($this->clientParams);
|
|
}
|
|
|
|
/**
|
|
* @param $config AppSdkConfig|array|AppSdkConfigProvider
|
|
* @return PromtionClientBuilder
|
|
* @throws YopClientException
|
|
*/
|
|
public static function builder($config)
|
|
{
|
|
$appSdkConfigProvider = null;
|
|
if ($config instanceof AppSdkConfigProvider) {
|
|
$appSdkConfigProvider = $config;
|
|
} else {
|
|
$appSdkConfigProvider = new DefaultAppSdkConfigProvider($config);
|
|
}
|
|
$clientParams = ClientParamsSupport::generateClientParams($appSdkConfigProvider);
|
|
$clientParams->setAuthorizationReqRegistry(self::$authorizationReqRegistry);
|
|
return new PromtionClientBuilder($clientParams);
|
|
}
|
|
|
|
}
|
|
PromtionClientBuilder::__init();
|