first commit
This commit is contained in:
24
.gitignore
vendored
Normal file
24
.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/vendor/
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
|
||||
# Laravel 4 specific
|
||||
bootstrap/compiled.php
|
||||
app/storage/
|
||||
|
||||
# Laravel 5 & Lumen specific
|
||||
public/storage
|
||||
public/hot
|
||||
|
||||
# Laravel 5 & Lumen specific with changed public path
|
||||
public_html/storage
|
||||
public_html/hot
|
||||
|
||||
storage/*.key
|
||||
.env
|
||||
Homestead.yaml
|
||||
Homestead.json
|
||||
/.vagrant
|
||||
.phpunit.result.cache
|
||||
.idea
|
||||
32
composer.json
Normal file
32
composer.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "xuanchen/yee-pay",
|
||||
"description": "域展科技-易宝支付",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Leady",
|
||||
"email": "149307205@qq.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.4",
|
||||
"laravel/framework": "^8.5",
|
||||
"guzzlehttp/guzzle": "^7.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Leady\\YeePay\\": "src/",
|
||||
"Yeepay\\Yop\\Sdk\\": "lib/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Leady\\YeePay\\ServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"LeadyYeePay": "Leady\\YeePay\\Facade"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
5299
composer.lock
generated
Normal file
5299
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
19
config/config.php
Normal file
19
config/config.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
return [
|
||||
'serverRoot' => 'https://openapi.yeepay.com/yop-center',
|
||||
'yosServerRoot' => 'https://openapi.yeepay.com/yop-center',
|
||||
'appKey' => '',
|
||||
'secretKey' => '',
|
||||
'encryptKey' => '',
|
||||
'merchantNo' => '',
|
||||
'storeType' => 'string',
|
||||
'certType' => 'RSA2048',
|
||||
'yopPublicKey' => '',
|
||||
'isvPrivateKey' => '',
|
||||
'httpClient' => [
|
||||
'connect_timeout' => 10000,
|
||||
'read_timeout' => 30000,
|
||||
'max_conn_total' => 2000,
|
||||
'max_conn_per_route' => 1000,
|
||||
],
|
||||
];
|
||||
3485
database/yee_pay_areas.sql
Normal file
3485
database/yee_pay_areas.sql
Normal file
File diff suppressed because it is too large
Load Diff
27
lib/Auth/AuthorityReqRegistryImpl.php
Normal file
27
lib/Auth/AuthorityReqRegistryImpl.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Auth;
|
||||
|
||||
class AuthorityReqRegistryImpl implements AuthorizationReqRegistry
|
||||
{
|
||||
|
||||
private $authorizationReqs = [];
|
||||
|
||||
/**
|
||||
* @param $operationId string
|
||||
* @param $securityReq AuthorizationReq
|
||||
* @return $this
|
||||
*/
|
||||
public function register($operationId, $securityReq)
|
||||
{
|
||||
$this->authorizationReqs[$operationId] = $securityReq;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAuthorizationReq($operationId)
|
||||
{
|
||||
return $this->authorizationReqs[$operationId];
|
||||
}
|
||||
|
||||
}
|
||||
145
lib/Auth/AuthorizationReq.php
Normal file
145
lib/Auth/AuthorizationReq.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Auth;
|
||||
|
||||
class AuthorizationReq
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $signerType;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $credentialType;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $signatureAlg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $digestAlg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $protocolPrefix;
|
||||
|
||||
/**
|
||||
* AuthorizationReq constructor.
|
||||
* @param string $signerType
|
||||
* @param string $credentialType
|
||||
* @param string $signatureAlg
|
||||
* @param string $digestAlg
|
||||
* @param string $protocolPrefix
|
||||
*/
|
||||
public function __construct($signerType, $credentialType, $signatureAlg, $digestAlg, $protocolPrefix)
|
||||
{
|
||||
$this->signerType = $signerType;
|
||||
$this->credentialType = $credentialType;
|
||||
$this->signatureAlg = $signatureAlg;
|
||||
$this->digestAlg = $digestAlg;
|
||||
$this->protocolPrefix = $protocolPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSignerType()
|
||||
{
|
||||
return $this->signerType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $signerType
|
||||
* @return AuthorizationReq
|
||||
*/
|
||||
public function setSignerType($signerType)
|
||||
{
|
||||
$this->signerType = $signerType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCredentialType()
|
||||
{
|
||||
return $this->credentialType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $credentialType
|
||||
* @return AuthorizationReq
|
||||
*/
|
||||
public function setCredentialType($credentialType)
|
||||
{
|
||||
$this->credentialType = $credentialType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSignatureAlg()
|
||||
{
|
||||
return $this->signatureAlg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $signatureAlg
|
||||
* @return AuthorizationReq
|
||||
*/
|
||||
public function setSignatureAlg($signatureAlg)
|
||||
{
|
||||
$this->signatureAlg = $signatureAlg;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDigestAlg()
|
||||
{
|
||||
return $this->digestAlg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $digestAlg
|
||||
* @return AuthorizationReq
|
||||
*/
|
||||
public function setDigestAlg($digestAlg)
|
||||
{
|
||||
$this->digestAlg = $digestAlg;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProtocolPrefix()
|
||||
{
|
||||
return $this->protocolPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $protocolPrefix
|
||||
* @return AuthorizationReq
|
||||
*/
|
||||
public function setProtocolPrefix($protocolPrefix)
|
||||
{
|
||||
$this->protocolPrefix = $protocolPrefix;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
14
lib/Auth/AuthorizationReqRegistry.php
Normal file
14
lib/Auth/AuthorizationReqRegistry.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Auth;
|
||||
|
||||
interface AuthorizationReqRegistry
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $operationId string
|
||||
* @return AuthorizationReq
|
||||
*/
|
||||
public function getAuthorizationReq($operationId);
|
||||
|
||||
}
|
||||
37
lib/Auth/AuthorizationReqSupport.php
Normal file
37
lib/Auth/AuthorizationReqSupport.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Auth;
|
||||
|
||||
use Yeepay\Yop\Sdk\Security\DigestAlg;
|
||||
|
||||
class AuthorizationReqSupport
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private static $supportedAuthorizationReqs;
|
||||
|
||||
static function init()
|
||||
{
|
||||
self::$supportedAuthorizationReqs =
|
||||
[
|
||||
"YOP-RSA2048-SHA256" => new AuthorizationReq("RSA", "RSA2048", "SHA256withRSA", DigestAlg::SHA256,
|
||||
"YOP-RSA2048-SHA256"),
|
||||
"YOP-RSA2048-SHA512" => new AuthorizationReq("RSA", "RSA2048", "SHA512withRSA", DigestAlg::SHA512,
|
||||
"YOP-RSA2048-SHA512"),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $securityReqName
|
||||
* @return AuthorizationReq
|
||||
*/
|
||||
static function getAuthorizationReq($securityReqName)
|
||||
{
|
||||
return self::$supportedAuthorizationReqs[$securityReqName];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
AuthorizationReqSupport::init();
|
||||
75
lib/Auth/Cipher/DefaultEncryptor.php
Normal file
75
lib/Auth/Cipher/DefaultEncryptor.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Auth\Cipher;
|
||||
|
||||
use Yeepay\Yop\Sdk\Auth\Encryptor;
|
||||
use Yeepay\Yop\Sdk\Http\ContentType;
|
||||
use Yeepay\Yop\Sdk\Http\Headers;
|
||||
use Yeepay\Yop\Sdk\Internal\Request;
|
||||
use Yeepay\Yop\Sdk\Security\Aes\AesEncryptor;
|
||||
|
||||
class DefaultEncryptor implements Encryptor
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $key;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $keyLength;
|
||||
|
||||
/**
|
||||
* DefaultEncryptor constructor.
|
||||
* @param $base64EncodedKey string
|
||||
*/
|
||||
public function __construct($base64EncodedKey)
|
||||
{
|
||||
$this->key = base64_decode($base64EncodedKey);
|
||||
$this->keyLength = strlen($this->key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function encrypt(Request $request)
|
||||
{
|
||||
if ($request->getContentType() == ContentType::APPLICATION_OCTET_STREAM) {
|
||||
return;
|
||||
}
|
||||
$request->addHeader(Headers::YOP_ENCRYPT_TYPE, "aes".$this->keyLength);
|
||||
if (!empty($request->getParameters()) > 0) {
|
||||
$encryptedParameters = [];
|
||||
foreach ($request->getParameters() as $paramName => $paramValues) {
|
||||
$encryptedParamValues = [];
|
||||
foreach ($paramValues as $paramValue) {
|
||||
$encryptedParamValues[] = AesEncryptor::encryptAndEncodeBase64($paramValue, $this->key);
|
||||
}
|
||||
$encryptedParameters[$paramName] = $encryptedParamValues;
|
||||
}
|
||||
$request->setParameters($encryptedParameters);
|
||||
}
|
||||
if (empty($request->getContent())) {
|
||||
if (is_string($request->getContent())) {
|
||||
$request->setContent(AesEncryptor::decodeBase64AndDecrypt($request->getContent(), $this->key));
|
||||
} else {
|
||||
if (is_resource($request->getContent())) {
|
||||
//todo 忽略对resource的签名
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $content string
|
||||
* @return string
|
||||
*/
|
||||
public function decrypt($content)
|
||||
{
|
||||
return AesEncryptor::decodeBase64AndDecrypt($content, $this->key);
|
||||
}
|
||||
|
||||
}
|
||||
94
lib/Auth/Credential/DefaultCredentialProvider.php
Normal file
94
lib/Auth/Credential/DefaultCredentialProvider.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Auth\Credential;
|
||||
|
||||
use Yeepay\Yop\Sdk\Auth\YopCredentialProvider;
|
||||
use Yeepay\Yop\Sdk\Auth\YopRsaCredentials;
|
||||
use Yeepay\Yop\Sdk\Config\AppSdkConfig;
|
||||
use Yeepay\Yop\Sdk\Config\AppSdkConfigProvider;
|
||||
use Yeepay\Yop\Sdk\Config\Support\ConfigUtils;
|
||||
use Yeepay\Yop\Sdk\Exception\YopClientException;
|
||||
|
||||
class DefaultCredentialProvider implements YopCredentialProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $credentials;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $defaultAppCredentials;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $publicKeys;
|
||||
|
||||
/**
|
||||
* DefaultCredentialProvider constructor.
|
||||
* @param AppSdkConfigProvider $appSdkConfigProvider
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function __construct(AppSdkConfigProvider $appSdkConfigProvider)
|
||||
{
|
||||
$this->credentials = [];
|
||||
foreach ($appSdkConfigProvider->getAllConfig() as $appKey => $appKeySdkConfig) {
|
||||
/* @var $appKeySdkConfig AppSdkConfig */
|
||||
$appKeyCredentials = [];
|
||||
if (!empty($appKeySdkConfig->getIsvPrivateKeys())) {
|
||||
foreach ($appKeySdkConfig->getIsvPrivateKeys() as $credentialType => $isvPrivateKey) {
|
||||
/* @var $isvPrivateKey string|resource */
|
||||
if (is_string($isvPrivateKey)) {
|
||||
$appKeyCredentials[$credentialType] = new YopRsaCredentials($appKey,
|
||||
ConfigUtils::getPrivateKey($isvPrivateKey),
|
||||
$appKeySdkConfig->getEncryptKey());
|
||||
} else {
|
||||
if (is_resource($isvPrivateKey)) {
|
||||
$appKeyCredentials[$credentialType] = new YopRsaCredentials($appKey, $isvPrivateKey,
|
||||
$appKeySdkConfig->getEncryptKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($appKeyCredentials)) {
|
||||
$this->credentials[$appKey] = $appKeyCredentials;
|
||||
}
|
||||
}
|
||||
$this->defaultAppCredentials = $this->credentials[$appSdkConfigProvider->getDefaultConfig()->getAppKey()];
|
||||
$this->publicKeys = $appSdkConfigProvider->getDefaultConfig()->getYopPublicKeys();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $appKey string
|
||||
* @param $credentialType string
|
||||
* @return YopRsaCredentials
|
||||
*/
|
||||
public function getCredential($appKey, $credentialType)
|
||||
{
|
||||
if (isset($this->credentials[$appKey])) {
|
||||
return $this->credentials[$appKey][$credentialType];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $credentialType string
|
||||
* @return YopRsaCredentials
|
||||
*/
|
||||
public function getDefaultAppCredential($credentialType)
|
||||
{
|
||||
return $this->defaultAppCredentials[$credentialType];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $credentialType string
|
||||
* @return resource
|
||||
*/
|
||||
public function getYopPublicKey($credentialType)
|
||||
{
|
||||
return $this->publicKeys[$credentialType];
|
||||
}
|
||||
|
||||
}
|
||||
22
lib/Auth/Encryptor.php
Normal file
22
lib/Auth/Encryptor.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Auth;
|
||||
|
||||
use Yeepay\Yop\Sdk\Internal\Request;
|
||||
|
||||
interface Encryptor
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function encrypt(Request $request);
|
||||
|
||||
/**
|
||||
* @param $content
|
||||
* @return mixed
|
||||
*/
|
||||
public function decrypt($content);
|
||||
|
||||
}
|
||||
97
lib/Auth/SignOptions.php
Normal file
97
lib/Auth/SignOptions.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Auth;
|
||||
|
||||
class SignOptions
|
||||
{
|
||||
|
||||
const DEFAULT_EXPIRATION_IN_SECONDS = 1800;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $digestAlg;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $protocolPrefix;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $expirationInSeconds = self::DEFAULT_EXPIRATION_IN_SECONDS;
|
||||
|
||||
/**
|
||||
* SignOptions constructor.
|
||||
* @param string $digestAlg
|
||||
* @param string $protocolPrefix
|
||||
* @param int $expirationInSeconds
|
||||
*/
|
||||
public function __construct($digestAlg, $protocolPrefix, $expirationInSeconds = null)
|
||||
{
|
||||
$this->digestAlg = $digestAlg;
|
||||
$this->protocolPrefix = $protocolPrefix;
|
||||
if (isset($expirationInSeconds)) {
|
||||
$this->expirationInSeconds = $expirationInSeconds;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDigestAlg()
|
||||
{
|
||||
return $this->digestAlg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $digestAlg
|
||||
* @return SignOptions
|
||||
*/
|
||||
public function setDigestAlg($digestAlg)
|
||||
{
|
||||
$this->digestAlg = $digestAlg;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProtocolPrefix()
|
||||
{
|
||||
return $this->protocolPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $protocolPrefix
|
||||
* @return SignOptions
|
||||
*/
|
||||
public function setProtocolPrefix($protocolPrefix)
|
||||
{
|
||||
$this->protocolPrefix = $protocolPrefix;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getExpirationInSeconds()
|
||||
{
|
||||
return $this->expirationInSeconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $expirationInSeconds
|
||||
* @return SignOptions
|
||||
*/
|
||||
public function setExpirationInSeconds($expirationInSeconds)
|
||||
{
|
||||
$this->expirationInSeconds = $expirationInSeconds;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
26
lib/Auth/Signer.php
Normal file
26
lib/Auth/Signer.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Auth;
|
||||
|
||||
use Yeepay\Yop\Sdk\Http\YopHttpResponse;
|
||||
use Yeepay\Yop\Sdk\Internal\Request;
|
||||
|
||||
interface Signer
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param YopRsaCredentials|null $credentials
|
||||
* @param SignOptions|null $options
|
||||
*/
|
||||
public function sign(Request $request, YopRsaCredentials $credentials = null, SignOptions $options = null);
|
||||
|
||||
/**
|
||||
* @param YopHttpResponse $httpResponse
|
||||
* @param string $signature
|
||||
* @param resource $publicKey
|
||||
* @param SignOptions $options
|
||||
*/
|
||||
public function checkSignature(YopHttpResponse $httpResponse, $signature, $publicKey, SignOptions $options);
|
||||
|
||||
}
|
||||
199
lib/Auth/Signer/RsaSigner.php
Normal file
199
lib/Auth/Signer/RsaSigner.php
Normal file
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Auth\Signer;
|
||||
|
||||
use DateTime;
|
||||
use Yeepay\Yop\Sdk\Auth\Signer;
|
||||
use Yeepay\Yop\Sdk\Auth\SignOptions;
|
||||
use Yeepay\Yop\Sdk\Auth\YopRsaCredentials;
|
||||
use Yeepay\Yop\Sdk\Exception\VerifySignFailedException;
|
||||
use Yeepay\Yop\Sdk\Exception\YopClientException;
|
||||
use Yeepay\Yop\Sdk\Http\Headers;
|
||||
use Yeepay\Yop\Sdk\Http\YopHttpResponse;
|
||||
use Yeepay\Yop\Sdk\Internal\Request;
|
||||
use Yeepay\Yop\Sdk\Security\Encodes;
|
||||
use Yeepay\Yop\Sdk\Utils\DateUtils;
|
||||
use Yeepay\Yop\Sdk\Utils\Http\HttpUtils;
|
||||
|
||||
class RsaSigner implements Signer
|
||||
{
|
||||
|
||||
private static $yopAuthVersion = 'yop-auth-v3';
|
||||
|
||||
private static $defaultHeadersToSign;
|
||||
|
||||
private static $headerJoiner = "\n";
|
||||
|
||||
private static $signedHeaderStringJoiner = ';';
|
||||
|
||||
private $logger;
|
||||
|
||||
public static function __init()
|
||||
{
|
||||
self::$defaultHeadersToSign = [
|
||||
strtolower(Headers::CONTENT_LENGTH),
|
||||
strtolower(Headers::CONTENT_TYPE),
|
||||
strtolower(Headers::CONTENT_DISPOSITION),
|
||||
strtolower(Headers::CONTENT_MD5),
|
||||
strtolower(Headers::YOP_REQUEST_ID),
|
||||
strtolower(Headers::YOP_DATE),
|
||||
strtolower(Headers::YOP_APPKEY),
|
||||
strtolower(Headers::YOP_CONTENT_SHA256),
|
||||
strtolower(Headers::YOP_HASH_CRC64ECMA),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function sign(Request $request, YopRsaCredentials $credentials = null, SignOptions $options = null)
|
||||
{
|
||||
if ($credentials == null) {
|
||||
return;
|
||||
}
|
||||
$accessKeyId = $credentials->getAppKey();
|
||||
$request->addHeader(Headers::HOST, HttpUtils:: generateHostHeader($request->getEndpoint()));
|
||||
$timestamp = new DateTime();
|
||||
$timestamp->setTimezone(DateUtils::$UTC_TIMEZONE);
|
||||
|
||||
$contentSha256 = $this->calculateContentHash($request);
|
||||
if (isset($contentSha256)) {
|
||||
$request->addHeader(Headers::YOP_CONTENT_SHA256, $contentSha256);
|
||||
}
|
||||
$canonicalQueryString = $this->getCanonicalQueryString($request);
|
||||
$headersToSign = $this->getHeadersToSign($request->getHeaders(), self::$defaultHeadersToSign);
|
||||
$canonicalHeader = $this->getCanonicalHeaders($headersToSign);
|
||||
$signedHeaders = strtolower(trim(implode(self::$signedHeaderStringJoiner, array_keys($headersToSign))));
|
||||
|
||||
$authString = self::$yopAuthVersion.'/'.$accessKeyId.'/'.DateUtils::formatAlternateIso8601Date($timestamp).'/'
|
||||
.$options->getExpirationInSeconds();
|
||||
|
||||
$canonicalURI = $this->getCanonicalURIPath($request->getResourcePath());
|
||||
$canonicalRequest = $authString.self::$headerJoiner.$request->getHttpMethod().self::$headerJoiner.$canonicalURI
|
||||
.self::$headerJoiner.$canonicalQueryString.self::$headerJoiner.$canonicalHeader;
|
||||
|
||||
$signature = $this->computeSignature($canonicalRequest, $credentials->getPrivateKey(),
|
||||
$options->getDigestAlg());
|
||||
$authorizationHeader = $options->getProtocolPrefix().' '.$authString.'/'.$signedHeaders.'/'.$signature;
|
||||
$request->addHeader(Headers::AUTHORIZATION, $authorizationHeader);
|
||||
}
|
||||
|
||||
private function calculateContentHash(Request $request)
|
||||
{
|
||||
$content = null;
|
||||
if (HttpUtils::usePayloadForQueryParameters($request)) {
|
||||
$content = HttpUtils::getCanonicalQueryString($request->getParameters(), true);
|
||||
} else {
|
||||
if (is_string($request->getContent())) {
|
||||
$content = $request->getContent();
|
||||
}
|
||||
}
|
||||
if (isset($content)) {
|
||||
return hash('sha256', $content);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private function getCanonicalQueryString(Request $request)
|
||||
{
|
||||
if (HttpUtils::usePayloadForQueryParameters($request)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return HttpUtils::getCanonicalQueryString($request->getParameters(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $path string
|
||||
* @return string
|
||||
*/
|
||||
private function getCanonicalURIPath($path)
|
||||
{
|
||||
if (empty($path)) {
|
||||
return '/';
|
||||
} else {
|
||||
if ($path[0] == '/') {
|
||||
return HttpUtils::urlEncodeExceptSlash($path);
|
||||
} else {
|
||||
return '/'.HttpUtils::urlEncodeExceptSlash($path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $headers array
|
||||
* @return string
|
||||
*/
|
||||
private function getCanonicalHeaders($headers)
|
||||
{
|
||||
if (count($headers) == 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$headerStrings = [];
|
||||
foreach ($headers as $k => $v) {
|
||||
if ($k === null) {
|
||||
continue;
|
||||
}
|
||||
if ($v === null) {
|
||||
$v = '';
|
||||
}
|
||||
$headerStrings[] = rawurlencode(
|
||||
strtolower(trim($k))
|
||||
).':'.rawurlencode(trim($v));
|
||||
}
|
||||
sort($headerStrings);
|
||||
|
||||
return implode(self::$headerJoiner, $headerStrings);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $headers array
|
||||
* @param $headersToSign array
|
||||
* @return array
|
||||
*/
|
||||
private function getHeadersToSign($headers, $headersToSign)
|
||||
{
|
||||
$ret = [];
|
||||
if ($headersToSign !== null) {
|
||||
$tmp = [];
|
||||
foreach ($headersToSign as $header) {
|
||||
$tmp[] = strtolower(trim($header));
|
||||
}
|
||||
$headersToSign = $tmp;
|
||||
}
|
||||
foreach ($headers as $k => $v) {
|
||||
if (trim((string) $v) !== '') {
|
||||
if ($headersToSign !== null) {
|
||||
$k = strtolower(trim($k));
|
||||
if (in_array($k, $headersToSign) && $k != trim(Headers::AUTHORIZATION)) {
|
||||
$ret[$k] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private function computeSignature($canonicalRequest, $privateKey, $digestAlg)
|
||||
{
|
||||
$signature = null;
|
||||
if (openssl_sign($canonicalRequest, $signature, $privateKey, $digestAlg)) {
|
||||
return Encodes::base64url_encode($signature).'$'.$digestAlg;
|
||||
}
|
||||
throw new YopClientException('compute signature failed.');
|
||||
}
|
||||
|
||||
public function checkSignature(YopHttpResponse $httpResponse, $signature, $publicKey, SignOptions $options)
|
||||
{
|
||||
$content = $httpResponse->readContent();
|
||||
$content = str_replace([" ", "\n", "\t"], "", $content);
|
||||
if (openssl_verify($content, base64_decode($signature), $publicKey, $options->getDigestAlg()) == 1) {
|
||||
return;
|
||||
}
|
||||
throw new VerifySignFailedException("response sign verify failure");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RsaSigner::__init();
|
||||
29
lib/Auth/SignerFactory.php
Normal file
29
lib/Auth/SignerFactory.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Auth;
|
||||
|
||||
use Yeepay\Yop\Sdk\Auth\Signer\RsaSigner;
|
||||
|
||||
class SignerFactory
|
||||
{
|
||||
|
||||
private static $signers = [];
|
||||
|
||||
public static function init()
|
||||
{
|
||||
self::$signers['RSA'] = new RsaSigner();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $signerType string
|
||||
* @return Signer
|
||||
*/
|
||||
public static function getSigner($signerType)
|
||||
{
|
||||
return self::$signers[$signerType];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SignerFactory::init();
|
||||
|
||||
27
lib/Auth/YopCredentialProvider.php
Normal file
27
lib/Auth/YopCredentialProvider.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Auth;
|
||||
|
||||
interface YopCredentialProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $appKey string
|
||||
* @param $credentialType string
|
||||
* @return YopRsaCredentials
|
||||
*/
|
||||
public function getCredential($appKey, $credentialType);
|
||||
|
||||
/**
|
||||
* @param $credentialType string
|
||||
* @return YopRsaCredentials
|
||||
*/
|
||||
public function getDefaultAppCredential($credentialType);
|
||||
|
||||
/**
|
||||
* @param $credentialType string
|
||||
* @return resource
|
||||
*/
|
||||
public function getYopPublicKey($credentialType);
|
||||
|
||||
}
|
||||
93
lib/Auth/YopRsaCredentials.php
Normal file
93
lib/Auth/YopRsaCredentials.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Auth;
|
||||
|
||||
class YopRsaCredentials
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $appKey;
|
||||
|
||||
/**
|
||||
* @var resource
|
||||
*/
|
||||
private $privateKey;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $encryptKey;
|
||||
|
||||
/**
|
||||
* YopRsaCredentials constructor.
|
||||
* @param string $appKey
|
||||
* @param resource $privateKey
|
||||
* @param string $encryptKey
|
||||
*/
|
||||
public function __construct($appKey, $privateKey, $encryptKey)
|
||||
{
|
||||
$this->appKey = $appKey;
|
||||
$this->privateKey = $privateKey;
|
||||
$this->encryptKey = $encryptKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAppKey()
|
||||
{
|
||||
return $this->appKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $appKey
|
||||
* @return YopRsaCredentials
|
||||
*/
|
||||
public function setAppKey($appKey)
|
||||
{
|
||||
$this->appKey = $appKey;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return resource
|
||||
*/
|
||||
public function getPrivateKey()
|
||||
{
|
||||
return $this->privateKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resource $privateKey
|
||||
* @return YopRsaCredentials
|
||||
*/
|
||||
public function setPrivateKey($privateKey)
|
||||
{
|
||||
$this->privateKey = $privateKey;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEncryptKey()
|
||||
{
|
||||
return $this->encryptKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $encryptKey
|
||||
* @return YopRsaCredentials
|
||||
*/
|
||||
public function setEncryptKey($encryptKey)
|
||||
{
|
||||
$this->encryptKey = $encryptKey;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
100
lib/Client/ClientExecutionParams.php
Normal file
100
lib/Client/ClientExecutionParams.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Client;
|
||||
|
||||
use Yeepay\Yop\Sdk\Model\BaseRequest;
|
||||
use Yeepay\Yop\Sdk\Model\Transform\RequestMarshaller;
|
||||
use Yeepay\Yop\Sdk\Model\Transform\ResponseUnMarshaller;
|
||||
|
||||
class ClientExecutionParams
|
||||
{
|
||||
|
||||
/**
|
||||
* @var BaseRequest
|
||||
*/
|
||||
private $request;
|
||||
|
||||
/**
|
||||
* @var RequestMarshaller
|
||||
*/
|
||||
private $requestMarshaller;
|
||||
|
||||
/**
|
||||
* @var ResponseUnMarshaller
|
||||
*/
|
||||
private $responseUnMarshaller;
|
||||
|
||||
/**
|
||||
* ClientExecutionParams constructor.
|
||||
* @param $request BaseRequest
|
||||
* @param RequestMarshaller $requestMarshaller
|
||||
* @param ResponseUnMarshaller $responseUnMarshaller
|
||||
*/
|
||||
public function __construct(
|
||||
$request,
|
||||
RequestMarshaller $requestMarshaller,
|
||||
ResponseUnMarshaller $responseUnMarshaller
|
||||
) {
|
||||
$this->request = $request;
|
||||
$this->requestMarshaller = $requestMarshaller;
|
||||
$this->responseUnMarshaller = $responseUnMarshaller;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BaseRequest
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BaseRequest $request
|
||||
* @return ClientExecutionParams
|
||||
*/
|
||||
public function setRequest(BaseRequest $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return RequestMarshaller
|
||||
*/
|
||||
public function getRequestMarshaller()
|
||||
{
|
||||
return $this->requestMarshaller;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RequestMarshaller $requestMarshaller
|
||||
* @return ClientExecutionParams
|
||||
*/
|
||||
public function setRequestMarshaller(RequestMarshaller $requestMarshaller)
|
||||
{
|
||||
$this->requestMarshaller = $requestMarshaller;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ResponseUnMarshaller
|
||||
*/
|
||||
public function getResponseUnMarshaller()
|
||||
{
|
||||
return $this->responseUnMarshaller;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ResponseUnMarshaller $responseUnMarshaller
|
||||
* @return ClientExecutionParams
|
||||
*/
|
||||
public function setResponseUnMarshaller(ResponseUnMarshaller $responseUnMarshaller)
|
||||
{
|
||||
$this->responseUnMarshaller = $responseUnMarshaller;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
133
lib/Client/ClientHandler.php
Normal file
133
lib/Client/ClientHandler.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Client;
|
||||
|
||||
use Yeepay\Yop\Sdk\Auth\AuthorizationReqRegistry;
|
||||
use Yeepay\Yop\Sdk\Auth\Cipher\DefaultEncryptor;
|
||||
use Yeepay\Yop\Sdk\Auth\SignerFactory;
|
||||
use Yeepay\Yop\Sdk\Auth\SignOptions;
|
||||
use Yeepay\Yop\Sdk\Auth\YopCredentialProvider;
|
||||
use Yeepay\Yop\Sdk\Exception\YopClientException;
|
||||
use Yeepay\Yop\Sdk\Http\ExecutionContext;
|
||||
use Yeepay\Yop\Sdk\Http\YopHttpClient;
|
||||
use Yeepay\Yop\Sdk\Model\Transform\ResponseUnMarshalParams;
|
||||
|
||||
class ClientHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* @var YopCredentialProvider
|
||||
*/
|
||||
private $credentialsProvider;
|
||||
|
||||
/**
|
||||
* @var AuthorizationReqRegistry
|
||||
*/
|
||||
private $authorizationReqRegistry;
|
||||
|
||||
/**
|
||||
* @var YopHttpClient
|
||||
*/
|
||||
private $yopHttpClient;
|
||||
|
||||
/**
|
||||
* @var GateWayRouter
|
||||
*/
|
||||
private $gatewayRouter;
|
||||
|
||||
/**
|
||||
* ClientHandler constructor.
|
||||
* @param ClientParams $clientParams
|
||||
*/
|
||||
public function __construct(ClientParams $clientParams)
|
||||
{
|
||||
$this->credentialsProvider = $clientParams->getCredentialsProvider();
|
||||
$this->authorizationReqRegistry = $clientParams->getAuthorizationReqRegistry();
|
||||
$this->yopHttpClient = new YopHttpClient($clientParams->getClientConfiguration());
|
||||
$this->gatewayRouter = new GateWayRouter(new ServerRootSpace($clientParams->getEndPoint(),
|
||||
$clientParams->getYosEndPoint(),
|
||||
$clientParams->getSandboxEndPoint()),
|
||||
$clientParams->getModes());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ClientExecutionParams $executionParams
|
||||
* @return mixed
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function execute(ClientExecutionParams $executionParams)
|
||||
{
|
||||
|
||||
$executionContext = $this->getExecutionContext($executionParams);
|
||||
$request = $executionParams->getRequestMarshaller()->marshal($executionParams->getRequest());
|
||||
|
||||
/** @var ExecutionContext $httpExecutionContext */
|
||||
$httpExecutionContext = $executionContext[0];
|
||||
$request->setEndpoint($this->gatewayRouter->route($httpExecutionContext->getCredentials()->getAppKey(),
|
||||
$request));
|
||||
$yopHttpResponse = $this->yopHttpClient->execute($request, $httpExecutionContext);
|
||||
/** @var ResponseUnMarshalParams $ResponseUnMarshalParams */
|
||||
$ResponseUnMarshalParams = $executionContext[1];
|
||||
|
||||
return $executionParams->getResponseUnMarshaller()->unmarshal($yopHttpResponse, $ResponseUnMarshalParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ClientExecutionParams $executionParams
|
||||
* @return array
|
||||
* @throws YopClientException
|
||||
*/
|
||||
private function getExecutionContext(ClientExecutionParams $executionParams)
|
||||
{
|
||||
$httpExecutionContext = new ExecutionContext();
|
||||
$ResponseUnMarshalParams = new ResponseUnMarshalParams();
|
||||
|
||||
$request = $executionParams->getRequest();
|
||||
$authorizationReq = $this->authorizationReqRegistry->getAuthorizationReq($request::getOperationId());
|
||||
if (isset($authorizationReq)) {
|
||||
$signer = SignerFactory::getSigner($authorizationReq->getSignerType());
|
||||
$signOptions = new SignOptions($authorizationReq->getDigestAlg(), $authorizationReq->getProtocolPrefix());
|
||||
$httpExecutionContext->setSigner($signer)->setSignOptions($signOptions);
|
||||
$ResponseUnMarshalParams->setSigner($signer)->setSignOptions($signOptions)
|
||||
->setPublicKey($this->credentialsProvider->getYopPublicKey($authorizationReq->getCredentialType()));
|
||||
|
||||
$credentials = null;
|
||||
$requestConfig = $request->getRequestConfig();
|
||||
$needEncrypt = false;
|
||||
if (isset($requestConfig)) {
|
||||
if (!empty($requestConfig->getCredentials())) {
|
||||
$credentials = $requestConfig->getCredentials();
|
||||
} else {
|
||||
$customAppKey = $requestConfig->getAppKey();
|
||||
if (!empty($customAppKey)) {
|
||||
$credentials = $this->credentialsProvider->getCredential($customAppKey,
|
||||
$authorizationReq->getCredentialType());
|
||||
if (!isset($credentials)) {
|
||||
throw new YopClientException('no credentials specified, appKey:'.$customAppKey
|
||||
.', credentialType:'.$authorizationReq->getCredentialType());
|
||||
}
|
||||
}
|
||||
}
|
||||
$needEncrypt = $requestConfig->isNeedEncrypt();
|
||||
}
|
||||
if (!isset($credentials)) {
|
||||
$credentials = $this->credentialsProvider->getDefaultAppCredential($authorizationReq->getCredentialType());
|
||||
}
|
||||
if (!isset($credentials)) {
|
||||
throw new YopClientException('no credentials specified for defaultAppKey, credentialType:'
|
||||
.$authorizationReq->getCredentialType());
|
||||
}
|
||||
$httpExecutionContext->setCredentials($credentials);
|
||||
if ($needEncrypt) {
|
||||
$encryptor = new DefaultEncryptor($credentials->getEncryptKey());
|
||||
$httpExecutionContext->setNeedEncrypt(true)->setEncryptor($encryptor);
|
||||
$ResponseUnMarshalParams->setNeedDecrypt(true)->setEncryptor($encryptor);
|
||||
}
|
||||
|
||||
return [$httpExecutionContext, $ResponseUnMarshalParams];
|
||||
} else {
|
||||
throw new YopClientException("no securityReq assigned, api:".$request::getOperationId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
181
lib/Client/ClientParams.php
Normal file
181
lib/Client/ClientParams.php
Normal file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Client;
|
||||
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Yeepay\Yop\Sdk\Auth\AuthorizationReqRegistry;
|
||||
use Yeepay\Yop\Sdk\Auth\YopCredentialProvider;
|
||||
use Yeepay\Yop\Sdk\Http\ClientConfiguration;
|
||||
|
||||
class ClientParams
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Uri
|
||||
*/
|
||||
private $endPoint;
|
||||
|
||||
/**
|
||||
* @var Uri
|
||||
*/
|
||||
private $yosEndPoint;
|
||||
|
||||
/**
|
||||
* @var Uri
|
||||
*/
|
||||
private $sandboxEndPoint;
|
||||
|
||||
/**
|
||||
* @var ClientConfiguration
|
||||
*/
|
||||
private $clientConfiguration;
|
||||
|
||||
/**
|
||||
* @var AuthorizationReqRegistry
|
||||
*/
|
||||
private $authorizationReqRegistry;
|
||||
|
||||
/**
|
||||
* @var YopCredentialProvider
|
||||
*/
|
||||
private $credentialsProvider;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $modes;
|
||||
|
||||
/**
|
||||
* @return Uri
|
||||
*/
|
||||
public function getEndPoint()
|
||||
{
|
||||
return $this->endPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Uri $endPoint
|
||||
* @return ClientParams
|
||||
*/
|
||||
public function setEndPoint($endPoint)
|
||||
{
|
||||
$this->endPoint = $endPoint;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Uri
|
||||
*/
|
||||
public function getYosEndPoint()
|
||||
{
|
||||
return $this->yosEndPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Uri $yosEndPoint
|
||||
* @return ClientParams
|
||||
*/
|
||||
public function setYosEndPoint($yosEndPoint)
|
||||
{
|
||||
$this->yosEndPoint = $yosEndPoint;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Uri
|
||||
*/
|
||||
public function getSandboxEndPoint()
|
||||
{
|
||||
return $this->sandboxEndPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Uri $sandboxEndPoint
|
||||
* @return ClientParams
|
||||
*/
|
||||
public function setSandboxEndPoint($sandboxEndPoint)
|
||||
{
|
||||
$this->sandboxEndPoint = $sandboxEndPoint;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ClientConfiguration
|
||||
*/
|
||||
public function getClientConfiguration()
|
||||
{
|
||||
return $this->clientConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ClientConfiguration $clientConfiguration
|
||||
* @return ClientParams
|
||||
*/
|
||||
public function setClientConfiguration($clientConfiguration)
|
||||
{
|
||||
$this->clientConfiguration = $clientConfiguration;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AuthorizationReqRegistry
|
||||
*/
|
||||
public function getAuthorizationReqRegistry()
|
||||
{
|
||||
return $this->authorizationReqRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AuthorizationReqRegistry $authorizationReqRegistry
|
||||
* @return ClientParams
|
||||
*/
|
||||
public function setAuthorizationReqRegistry($authorizationReqRegistry)
|
||||
{
|
||||
$this->authorizationReqRegistry = $authorizationReqRegistry;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return YopCredentialProvider
|
||||
*/
|
||||
public function getCredentialsProvider()
|
||||
{
|
||||
return $this->credentialsProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param YopCredentialProvider $credentialsProvider
|
||||
* @return ClientParams
|
||||
*/
|
||||
public function setCredentialsProvider($credentialsProvider)
|
||||
{
|
||||
$this->credentialsProvider = $credentialsProvider;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getModes()
|
||||
{
|
||||
return $this->modes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $modes
|
||||
* @return ClientParams
|
||||
*/
|
||||
public function setModes($modes)
|
||||
{
|
||||
$this->modes = $modes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
104
lib/Client/GateWayRouter.php
Normal file
104
lib/Client/GateWayRouter.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Client;
|
||||
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Yeepay\Yop\Sdk\Config\Mode;
|
||||
use Yeepay\Yop\Sdk\Internal\Request;
|
||||
|
||||
class GateWayRouter
|
||||
{
|
||||
|
||||
/**
|
||||
* @var ServerRootSpace
|
||||
*/
|
||||
private $serverRootSpace;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $independentApiGroups;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $defaultMode;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $modes;
|
||||
|
||||
/**
|
||||
* GateWayRouter constructor.
|
||||
* @param ServerRootSpace $serverRootSpace
|
||||
* @param $modes
|
||||
*/
|
||||
public function __construct(ServerRootSpace $serverRootSpace, $modes = [])
|
||||
{
|
||||
$this->serverRootSpace = $serverRootSpace;
|
||||
$this->independentApiGroups = ["bank-encryption"];
|
||||
$this->defaultMode = getenv("yop.sdk.mode");
|
||||
$this->modes = $modes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $appKey string
|
||||
* @param $request Request
|
||||
* @return Uri
|
||||
*/
|
||||
public function route($appKey, $request)
|
||||
{
|
||||
if ($this->isAppInSandboxMode($appKey)) {
|
||||
return $this->serverRootSpace->getSandboxServerRoot();
|
||||
} else {
|
||||
$serverRoot = $request->getYosFlag() ? $this->serverRootSpace->getYosServerRoot() :
|
||||
$this->serverRootSpace->getServerRoot();
|
||||
$apiGroup = str_replace('_', '-', strtolower($request->getServiceName()));
|
||||
if (in_array($apiGroup, $this->independentApiGroups)) {
|
||||
$result = new Uri();
|
||||
$result->withScheme($serverRoot->getScheme());
|
||||
$result->withHost($serverRoot->getHost());
|
||||
$result->withPort($serverRoot->getPort());
|
||||
$result->withPath($serverRoot->getPath());
|
||||
$result->withUserInfo($serverRoot->getUserInfo());
|
||||
$result->withQuery($serverRoot->getQuery());
|
||||
$result->withFragment($serverRoot->getFragment());
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
return $serverRoot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $appKey
|
||||
* @return bool
|
||||
*/
|
||||
private function isAppInSandboxMode($appKey)
|
||||
{
|
||||
if (empty($this->defaultMode)) {
|
||||
return isset($this->modes[$appKey]) && $this->modes[$appKey] = Mode::SANDBOX;
|
||||
}
|
||||
|
||||
return $this->defaultMode == Mode::SANDBOX;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $apiGroup
|
||||
* @param string $originHost
|
||||
* @param bool $isYosRequest
|
||||
* @return string
|
||||
*/
|
||||
private function getIndependentApiGroupHost($apiGroup, $originHost, $isYosRequest)
|
||||
{
|
||||
if ($isYosRequest) {
|
||||
return $originHost;
|
||||
}
|
||||
$index = strpos($originHost, '.');
|
||||
|
||||
return substr($originHost, 0, $index).'_'.$apiGroup.substr($originHost, $index, -1);
|
||||
}
|
||||
|
||||
}
|
||||
77
lib/Client/ServerRootSpace.php
Normal file
77
lib/Client/ServerRootSpace.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Client;
|
||||
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
|
||||
class ServerRootSpace
|
||||
{
|
||||
|
||||
private static $defaultServerRoot;
|
||||
|
||||
private static $defaultYosServerRoot;
|
||||
|
||||
private static $defaultSandboxServerRoot;
|
||||
|
||||
public static function __init()
|
||||
{
|
||||
self::$defaultServerRoot = new Uri('https://openapi.yeepay.com/yop-center');
|
||||
self::$defaultYosServerRoot = new Uri('https://yos.yeepay.com/yop-center');
|
||||
self::$defaultSandboxServerRoot = new Uri('https://sandbox.yeepay.com/yop-center');
|
||||
}
|
||||
|
||||
/**
|
||||
* @var Uri
|
||||
*/
|
||||
private $serverRoot;
|
||||
|
||||
/**
|
||||
* @var Uri
|
||||
*/
|
||||
private $yosServerRoot;
|
||||
|
||||
/**
|
||||
* @var Uri
|
||||
*/
|
||||
private $sandboxServerRoot;
|
||||
|
||||
/**
|
||||
* ServerRootSpace constructor.
|
||||
* @param Uri|null $serverRoot
|
||||
* @param Uri|null $yosServerRoot
|
||||
* @param Uri|null $sandboxServerRoot
|
||||
*/
|
||||
public function __construct(Uri $serverRoot = null, Uri $yosServerRoot = null, Uri $sandboxServerRoot = null)
|
||||
{
|
||||
$this->serverRoot = isset($serverRoot) ? $serverRoot : self::$defaultServerRoot;
|
||||
$this->yosServerRoot = isset($yosServerRoot) ? $yosServerRoot : self::$defaultYosServerRoot;
|
||||
$this->sandboxServerRoot = isset($sandboxServerRoot) ? $sandboxServerRoot : self::$defaultSandboxServerRoot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Uri
|
||||
*/
|
||||
public function getServerRoot()
|
||||
{
|
||||
return $this->serverRoot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Uri
|
||||
*/
|
||||
public function getYosServerRoot()
|
||||
{
|
||||
return $this->yosServerRoot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Uri
|
||||
*/
|
||||
public function getSandboxServerRoot()
|
||||
{
|
||||
return $this->sandboxServerRoot;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ServerRootSpace::__init();
|
||||
67
lib/Client/Support/ClientParamsSupport.php
Normal file
67
lib/Client/Support/ClientParamsSupport.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Client\Support;
|
||||
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Yeepay\Yop\Sdk\Auth\Credential\DefaultCredentialProvider;
|
||||
use Yeepay\Yop\Sdk\Client\ClientParams;
|
||||
use Yeepay\Yop\Sdk\Config\AppSdkConfig;
|
||||
use Yeepay\Yop\Sdk\Config\AppSdkConfigProvider;
|
||||
use Yeepay\Yop\Sdk\Exception\YopClientException;
|
||||
use Yeepay\Yop\Sdk\Http\ClientConfiguration;
|
||||
|
||||
class ClientParamsSupport
|
||||
{
|
||||
|
||||
/**
|
||||
* @param AppSdkConfigProvider $appSdkConfigProvider
|
||||
* @return ClientParams
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public static function generateClientParams(AppSdkConfigProvider $appSdkConfigProvider)
|
||||
{
|
||||
$clientParams = new ClientParams();
|
||||
$clientParams->setCredentialsProvider(new DefaultCredentialProvider($appSdkConfigProvider));
|
||||
$defaultAppSdkConfig = $appSdkConfigProvider->getDefaultConfig();
|
||||
if (!empty($defaultAppSdkConfig->getServerRoot())) {
|
||||
$clientParams->setEndPoint(new Uri($defaultAppSdkConfig->getServerRoot()));
|
||||
}
|
||||
if (!empty($defaultAppSdkConfig->getYosServerRoot())) {
|
||||
$clientParams->setYosEndPoint(new Uri($defaultAppSdkConfig->getYosServerRoot()));
|
||||
}
|
||||
if (!empty($defaultAppSdkConfig->getSandboxServerRoot())) {
|
||||
$clientParams->setSandboxEndPoint(new Uri($defaultAppSdkConfig->getSandboxServerRoot()));
|
||||
}
|
||||
$clientConfigurations = new ClientConfiguration();
|
||||
if (!empty($defaultAppSdkConfig->getHttpClientConfig())) {
|
||||
$httpClientConfig = $defaultAppSdkConfig->getHttpClientConfig();
|
||||
$clientConfigurations->setSocketTimeoutInMillis($httpClientConfig['read_timeout']);
|
||||
$clientConfigurations->setConnectionTimeoutInMillis($httpClientConfig['connect_timeout']);
|
||||
}
|
||||
if (!empty($defaultAppSdkConfig->getProxy())) {
|
||||
$proxyConfig = $defaultAppSdkConfig->getProxy();
|
||||
$parts = [
|
||||
'scheme' => $proxyConfig->getScheme(), 'host' => $proxyConfig->getHost(),
|
||||
'port' => $proxyConfig->getPort(),
|
||||
];
|
||||
if (!empty($proxyConfig->getUsername()) && !empty($proxyConfig->getPort())) {
|
||||
$parts['user'] = $proxyConfig->getUsername();
|
||||
$parts['pass'] = $proxyConfig->getPassword();
|
||||
}
|
||||
$proxyURI = new Uri($parts);
|
||||
$clientConfigurations->setProxyUrl($proxyURI->__toString());
|
||||
}
|
||||
$clientParams->setClientConfiguration($clientConfigurations);
|
||||
$modes = [];
|
||||
foreach ($appSdkConfigProvider->getAllConfig() as $appKey => $appKeySdkConfig) {
|
||||
/* @var $appKeySdkConfig AppSdkConfig */
|
||||
if (!empty($appKeySdkConfig->getMode())) {
|
||||
$modes[$appKey] = $appKeySdkConfig->getMode();
|
||||
}
|
||||
}
|
||||
$clientParams->setModes($modes);
|
||||
|
||||
return $clientParams;
|
||||
}
|
||||
|
||||
}
|
||||
467
lib/Config/AppSdkConfig.php
Normal file
467
lib/Config/AppSdkConfig.php
Normal file
@@ -0,0 +1,467 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Config;
|
||||
|
||||
use Yeepay\Yop\Sdk\Config\Support\ConfigUtils;
|
||||
use Yeepay\Yop\Sdk\Exception\YopClientException;
|
||||
|
||||
class AppSdkConfig
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $appKey;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $serverRoot;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $yosServerRoot;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sandboxServerRoot;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $aesSecretKey;
|
||||
|
||||
/**
|
||||
* @var string | resource
|
||||
*/
|
||||
private $defaultPublicKey;
|
||||
|
||||
/**
|
||||
* @var string | resource
|
||||
*/
|
||||
private $defaultIsvPrivateKey;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $httpClientConfig;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $encryptKey;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $yopPublicKeys;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $isvPrivateKeys;
|
||||
|
||||
/**
|
||||
* @var ProxyConfig
|
||||
*/
|
||||
private $proxy;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $region;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $mode;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $trustAllCerts;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $default;
|
||||
|
||||
/**
|
||||
* AppSdkConfig constructor.
|
||||
* @param array $data
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function __construct(array $data = [])
|
||||
{
|
||||
if (isset($data['app_key'])) {
|
||||
$this->appKey = $data['app_key'];
|
||||
}
|
||||
if (isset($data['server_root'])) {
|
||||
$this->serverRoot = $data['server_root'];
|
||||
}
|
||||
if (isset($data['yos_server_root'])) {
|
||||
$this->yosServerRoot = $data['yos_server_root'];
|
||||
}
|
||||
if (isset($data['sandbox_server_root'])) {
|
||||
$this->sandboxServerRoot = $data['sandbox_server_root'];
|
||||
}
|
||||
if (isset($data['aesSecretKey'])) {
|
||||
$this->aesSecretKey = $data['aesSecretKey'];
|
||||
}
|
||||
if (isset($data['yop_public_key'])) {
|
||||
$publicKeys = [];
|
||||
for ($i = 0; $i < count($data['yop_public_key']); $i++) {
|
||||
$publicKeyConfig = $data['yop_public_key'][$i];
|
||||
$certs = ConfigUtils::loadPublicKey($publicKeyConfig);
|
||||
$publicKeys[$certs[0]] = $certs[1];
|
||||
if ($i == 0) {
|
||||
$this->defaultPublicKey = $certs[1];
|
||||
}
|
||||
}
|
||||
$this->yopPublicKeys = $publicKeys;
|
||||
}
|
||||
if (isset($data['isv_private_key'])) {
|
||||
$privateKeys = [];
|
||||
for ($i = 0; $i < count($data['isv_private_key']); $i++) {
|
||||
$privateKeyConfig = $data['isv_private_key'][$i];
|
||||
$certs = ConfigUtils::loadPrivateKey($privateKeyConfig);
|
||||
$privateKeys[$certs[0]] = $certs[1];
|
||||
if ($i == 0) {
|
||||
$this->defaultIsvPrivateKey = $certs[1];
|
||||
}
|
||||
}
|
||||
$this->isvPrivateKeys = $privateKeys;
|
||||
}
|
||||
if (isset($data['encrypt_key'])) {
|
||||
$this->encryptKey = $data['encrypt_key'];
|
||||
}
|
||||
if (isset($data['http_client'])) {
|
||||
$this->httpClientConfig = $data['http_client'];
|
||||
}
|
||||
if (isset($data['trust_all_certs'])) {
|
||||
$this->trustAllCerts = $data['trust_all_certs'];
|
||||
}
|
||||
if (isset($data['proxy'])) {
|
||||
$proxyConfig = $data['proxy'];
|
||||
$this->proxy = new ProxyConfig($proxyConfig['host'], $proxyConfig['port'], $proxyConfig['scheme'],
|
||||
$proxyConfig['username'],
|
||||
$proxyConfig['password'], $proxyConfig['domain'], $proxyConfig['workstation']);
|
||||
}
|
||||
if (isset($data['region'])) {
|
||||
$this->region = $data['region'];
|
||||
}
|
||||
if (isset($data['default'])) {
|
||||
$this->default = $data['default'];
|
||||
}
|
||||
if (isset($data['mode'])) {
|
||||
$this->mode = $data['mode'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAppKey()
|
||||
{
|
||||
return $this->appKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $appKey
|
||||
* @return AppSdkConfig
|
||||
*/
|
||||
public function setAppKey($appKey)
|
||||
{
|
||||
$this->appKey = $appKey;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getServerRoot()
|
||||
{
|
||||
return $this->serverRoot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $serverRoot
|
||||
* @return AppSdkConfig
|
||||
*/
|
||||
public function setServerRoot($serverRoot)
|
||||
{
|
||||
$this->serverRoot = $serverRoot;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getYosServerRoot()
|
||||
{
|
||||
return $this->yosServerRoot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $yosServerRoot
|
||||
* @return AppSdkConfig
|
||||
*/
|
||||
public function setYosServerRoot($yosServerRoot)
|
||||
{
|
||||
$this->yosServerRoot = $yosServerRoot;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSandboxServerRoot()
|
||||
{
|
||||
return $this->sandboxServerRoot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sandboxServerRoot
|
||||
* @return AppSdkConfig
|
||||
*/
|
||||
public function setSandboxServerRoot($sandboxServerRoot)
|
||||
{
|
||||
$this->sandboxServerRoot = $sandboxServerRoot;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAesSecretKey()
|
||||
{
|
||||
return $this->aesSecretKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $aesSecretKey
|
||||
* @return AppSdkConfig
|
||||
*/
|
||||
public function setAesSecretKey($aesSecretKey)
|
||||
{
|
||||
$this->aesSecretKey = $aesSecretKey;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return resource|string
|
||||
*/
|
||||
public function getDefaultPublicKey()
|
||||
{
|
||||
return $this->defaultPublicKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resource|string $defaultPublicKey
|
||||
* @return AppSdkConfig
|
||||
*/
|
||||
public function setDefaultPublicKey($defaultPublicKey)
|
||||
{
|
||||
$this->defaultPublicKey = $defaultPublicKey;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return resource|string
|
||||
*/
|
||||
public function getDefaultIsvPrivateKey()
|
||||
{
|
||||
return $this->defaultIsvPrivateKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resource|string $defaultIsvPrivateKey
|
||||
* @return AppSdkConfig
|
||||
*/
|
||||
public function setDefaultIsvPrivateKey($defaultIsvPrivateKey)
|
||||
{
|
||||
$this->defaultIsvPrivateKey = $defaultIsvPrivateKey;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getHttpClientConfig()
|
||||
{
|
||||
return $this->httpClientConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $httpClientConfig
|
||||
* @return AppSdkConfig
|
||||
*/
|
||||
public function setHttpClientConfig($httpClientConfig)
|
||||
{
|
||||
$this->httpClientConfig = $httpClientConfig;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEncryptKey()
|
||||
{
|
||||
return $this->encryptKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $encryptKey
|
||||
* @return AppSdkConfig
|
||||
*/
|
||||
public function setEncryptKey($encryptKey)
|
||||
{
|
||||
$this->encryptKey = $encryptKey;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getYopPublicKeys()
|
||||
{
|
||||
return $this->yopPublicKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $yopPublicKeys
|
||||
* @return AppSdkConfig
|
||||
*/
|
||||
public function setYopPublicKeys($yopPublicKeys)
|
||||
{
|
||||
$this->yopPublicKeys = $yopPublicKeys;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getIsvPrivateKeys()
|
||||
{
|
||||
return $this->isvPrivateKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $isvPrivateKeys
|
||||
* @return AppSdkConfig
|
||||
*/
|
||||
public function setIsvPrivateKeys($isvPrivateKeys)
|
||||
{
|
||||
$this->isvPrivateKeys = $isvPrivateKeys;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ProxyConfig
|
||||
*/
|
||||
public function getProxy()
|
||||
{
|
||||
return $this->proxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ProxyConfig $proxy
|
||||
* @return AppSdkConfig
|
||||
*/
|
||||
public function setProxy($proxy)
|
||||
{
|
||||
$this->proxy = $proxy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRegion()
|
||||
{
|
||||
return $this->region;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $region
|
||||
* @return AppSdkConfig
|
||||
*/
|
||||
public function setRegion($region)
|
||||
{
|
||||
$this->region = $region;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMode()
|
||||
{
|
||||
return $this->mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $mode
|
||||
* @return AppSdkConfig
|
||||
*/
|
||||
public function setMode($mode)
|
||||
{
|
||||
$this->mode = $mode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isTrustAllCerts()
|
||||
{
|
||||
return $this->trustAllCerts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $trustAllCerts
|
||||
* @return AppSdkConfig
|
||||
*/
|
||||
public function setTrustAllCerts($trustAllCerts)
|
||||
{
|
||||
$this->trustAllCerts = $trustAllCerts;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDefault()
|
||||
{
|
||||
return $this->default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $default
|
||||
* @return AppSdkConfig
|
||||
*/
|
||||
public function setDefault($default)
|
||||
{
|
||||
$this->default = $default;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
24
lib/Config/AppSdkConfigProvider.php
Normal file
24
lib/Config/AppSdkConfigProvider.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Config;
|
||||
|
||||
interface AppSdkConfigProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $appKey string
|
||||
* @return AppSdkConfig
|
||||
*/
|
||||
public function getConfig($appKey);
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getAllConfig();
|
||||
|
||||
/**
|
||||
* @return AppSdkConfig
|
||||
*/
|
||||
public function getDefaultConfig();
|
||||
|
||||
}
|
||||
70
lib/Config/DefaultAppSdkConfigProvider.php
Normal file
70
lib/Config/DefaultAppSdkConfigProvider.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Config;
|
||||
|
||||
use Yeepay\Yop\Sdk\Exception\YopClientException;
|
||||
|
||||
class DefaultAppSdkConfigProvider implements AppSdkConfigProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $configContainer;
|
||||
|
||||
/**
|
||||
* @var AppSdkConfig
|
||||
*/
|
||||
private $default;
|
||||
|
||||
/**
|
||||
* DefaultAppSdkConfigProvider constructor.
|
||||
* @param $config AppSdkConfig | AppSdkConfig[]
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function __construct($config)
|
||||
{
|
||||
if ($config instanceof AppSdkConfig) {
|
||||
$this->default = $config;
|
||||
$this->configContainer = [$config->getAppKey() => $config];
|
||||
} else {
|
||||
if (empty($config)) {
|
||||
throw new YopClientException("config is empty.");
|
||||
}
|
||||
$this->configContainer = [];
|
||||
$this->default = $config[0];
|
||||
foreach ($config as $item) {
|
||||
$this->configContainer[$item->getAppKey()] = $item;
|
||||
if ($item->isDefault()) {
|
||||
$this->default = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $appKey string
|
||||
* @return AppSdkConfig
|
||||
*/
|
||||
public function getConfig($appKey)
|
||||
{
|
||||
return $this->configContainer[$appKey];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AppSdkConfig
|
||||
*/
|
||||
public function getDefaultConfig()
|
||||
{
|
||||
return $this->default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getAllConfig()
|
||||
{
|
||||
return $this->configContainer;
|
||||
}
|
||||
|
||||
}
|
||||
12
lib/Config/Mode.php
Normal file
12
lib/Config/Mode.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Config;
|
||||
|
||||
class Mode
|
||||
{
|
||||
|
||||
const PROD = 'prod';
|
||||
|
||||
const SANDBOX = 'sandbox';
|
||||
|
||||
}
|
||||
204
lib/Config/ProxyConfig.php
Normal file
204
lib/Config/ProxyConfig.php
Normal file
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Config;
|
||||
|
||||
class ProxyConfig
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $host;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $port;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $scheme;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $username;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $password;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $domain;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $workstation;
|
||||
|
||||
/**
|
||||
* ProxyConfig constructor.
|
||||
* @param $host
|
||||
* @param $port
|
||||
* @param $scheme
|
||||
* @param null $username
|
||||
* @param null $password
|
||||
* @param null $domain
|
||||
* @param null $workstation
|
||||
*/
|
||||
public function __construct(
|
||||
$host,
|
||||
$port,
|
||||
$scheme,
|
||||
$username = null,
|
||||
$password = null,
|
||||
$domain = null,
|
||||
$workstation = null
|
||||
) {
|
||||
$this->host = $host;
|
||||
$this->port = $port;
|
||||
$this->scheme = $scheme;
|
||||
$this->username = $username;
|
||||
$this->password = $password;
|
||||
$this->domain = $domain;
|
||||
$this->workstation = $workstation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getHost()
|
||||
{
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $host
|
||||
* @return ProxyConfig
|
||||
*/
|
||||
public function setHost($host)
|
||||
{
|
||||
$this->host = $host;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPort()
|
||||
{
|
||||
return $this->port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $port
|
||||
* @return ProxyConfig
|
||||
*/
|
||||
public function setPort($port)
|
||||
{
|
||||
$this->port = $port;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getScheme()
|
||||
{
|
||||
return $this->scheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $scheme
|
||||
* @return ProxyConfig
|
||||
*/
|
||||
public function setScheme($scheme)
|
||||
{
|
||||
$this->scheme = $scheme;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUsername()
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $username
|
||||
* @return ProxyConfig
|
||||
*/
|
||||
public function setUsername($username)
|
||||
{
|
||||
$this->username = $username;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPassword()
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $password
|
||||
* @return ProxyConfig
|
||||
*/
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->password = $password;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDomain()
|
||||
{
|
||||
return $this->domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $domain
|
||||
* @return ProxyConfig
|
||||
*/
|
||||
public function setDomain($domain)
|
||||
{
|
||||
$this->domain = $domain;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getWorkstation()
|
||||
{
|
||||
return $this->workstation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $workstation
|
||||
* @return ProxyConfig
|
||||
*/
|
||||
public function setWorkstation($workstation)
|
||||
{
|
||||
$this->workstation = $workstation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
86
lib/Config/Support/ConfigUtils.php
Normal file
86
lib/Config/Support/ConfigUtils.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Config\Support;
|
||||
|
||||
use Yeepay\Yop\Sdk\Exception\YopClientException;
|
||||
|
||||
class ConfigUtils
|
||||
{
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
* @return array
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public static function loadPublicKey(array $config)
|
||||
{
|
||||
$certType = $config['cert_type'];
|
||||
if ($config['store_type'] == 'string') {
|
||||
return [$certType, self::getPublicKey($config['value'])];
|
||||
} else {
|
||||
throw new YopClientException('unsupported publicKey storeType:'.$config['store_type']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
* @return array
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public static function loadPrivateKey(array $config)
|
||||
{
|
||||
$certType = $config['cert_type'];
|
||||
if ($config['store_type'] == 'string') {
|
||||
return [$certType, self::getPrivateKey($config['value'])];
|
||||
} else {
|
||||
if ($config['store_type'] == 'file_12') {
|
||||
$certs = [];
|
||||
$pkcs12 = file_get_contents($config['value']);
|
||||
openssl_pkcs12_read($pkcs12, $certs, $config['password']);
|
||||
|
||||
return [$certType, $certs['pkey']];
|
||||
} else {
|
||||
throw new YopClientException('unsupported publicKey storeType:'.$config['store_type']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $publicKey
|
||||
* @return resource
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public static function getPublicKey($publicKey)
|
||||
{
|
||||
$publicKey = "-----BEGIN PUBLIC KEY-----\n".
|
||||
wordwrap($publicKey, 64, "\n", true).
|
||||
"\n-----END PUBLIC KEY-----";
|
||||
$result = openssl_pkey_get_public($publicKey);
|
||||
if (empty($result)) {
|
||||
throw new YopClientException("illegal publicKey");
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $privateKey
|
||||
* @return resource
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public static function getPrivateKey($privateKey)
|
||||
{
|
||||
$privateKey = "-----BEGIN RSA PRIVATE KEY-----\n".
|
||||
wordwrap($privateKey, 64, "\n", true).
|
||||
"\n-----END RSA PRIVATE KEY-----";
|
||||
$result = openssl_pkey_get_private($privateKey);
|
||||
if (empty($result)) {
|
||||
throw new YopClientException("illegal privateKey");
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
8
lib/Exception/VerifySignFailedException.php
Normal file
8
lib/Exception/VerifySignFailedException.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Exception;
|
||||
|
||||
class VerifySignFailedException extends YopClientBizException
|
||||
{
|
||||
|
||||
}
|
||||
8
lib/Exception/YopClientBizException.php
Normal file
8
lib/Exception/YopClientBizException.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Exception;
|
||||
|
||||
class YopClientBizException extends YopClientException
|
||||
{
|
||||
|
||||
}
|
||||
8
lib/Exception/YopClientException.php
Normal file
8
lib/Exception/YopClientException.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Exception;
|
||||
|
||||
class YopClientException extends \Exception
|
||||
{
|
||||
|
||||
}
|
||||
194
lib/Exception/YopServiceException.php
Normal file
194
lib/Exception/YopServiceException.php
Normal file
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Exception;
|
||||
|
||||
class YopServiceException extends YopClientException
|
||||
{
|
||||
|
||||
const ERROR_TYPE_CLIENT = 'Client';
|
||||
|
||||
const ERROR_TYPE_SERVICE = 'Service';
|
||||
|
||||
const ERROR_TYPE_UNKNOWN = 'Unknown';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $requestId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $errorCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $subErrorCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $errorType = self::ERROR_TYPE_UNKNOWN;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $errorMessage;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $subErrorMessage;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $statusCode;
|
||||
|
||||
/**
|
||||
* YopServiceException constructor.
|
||||
* @param $errorMessage
|
||||
* @param string $errorCode
|
||||
*/
|
||||
public function __construct($errorMessage, $errorCode = '')
|
||||
{
|
||||
parent::__construct($errorMessage);
|
||||
$this->errorCode = $errorCode;
|
||||
$this->errorMessage = $errorMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRequestId()
|
||||
{
|
||||
return $this->requestId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $requestId
|
||||
* @return YopServiceException
|
||||
*/
|
||||
public function setRequestId($requestId)
|
||||
{
|
||||
$this->requestId = $requestId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorCode()
|
||||
{
|
||||
return $this->errorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $errorCode
|
||||
* @return YopServiceException
|
||||
*/
|
||||
public function setErrorCode($errorCode)
|
||||
{
|
||||
$this->errorCode = $errorCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSubErrorCode()
|
||||
{
|
||||
return $this->subErrorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $subErrorCode
|
||||
* @return YopServiceException
|
||||
*/
|
||||
public function setSubErrorCode($subErrorCode)
|
||||
{
|
||||
$this->subErrorCode = $subErrorCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorType()
|
||||
{
|
||||
return $this->errorType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $errorType
|
||||
* @return YopServiceException
|
||||
*/
|
||||
public function setErrorType($errorType)
|
||||
{
|
||||
$this->errorType = $errorType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorMessage()
|
||||
{
|
||||
return $this->errorMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $errorMessage
|
||||
* @return YopServiceException
|
||||
*/
|
||||
public function setErrorMessage($errorMessage)
|
||||
{
|
||||
$this->errorMessage = $errorMessage;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSubErrorMessage()
|
||||
{
|
||||
return $this->subErrorMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $subErrorMessage
|
||||
* @return YopServiceException
|
||||
*/
|
||||
public function setSubErrorMessage($subErrorMessage)
|
||||
{
|
||||
$this->subErrorMessage = $subErrorMessage;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatusCode()
|
||||
{
|
||||
return $this->statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $statusCode
|
||||
* @return YopServiceException
|
||||
*/
|
||||
public function setStatusCode($statusCode)
|
||||
{
|
||||
$this->statusCode = $statusCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
201
lib/Http/ClientConfiguration.php
Normal file
201
lib/Http/ClientConfiguration.php
Normal file
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Http;
|
||||
|
||||
use Yeepay\Yop\Sdk\Utils\Http\Region;
|
||||
use Yeepay\Yop\Sdk\Utils\YopConstants;
|
||||
|
||||
class ClientConfiguration
|
||||
{
|
||||
|
||||
const DEFAULT_CONNECTION_TIMEOUT_IN_MILLIS = 50000;
|
||||
|
||||
const DEFAULT_SOCKET_TIMEOUT_IN_MILLIS = 50000;
|
||||
|
||||
private static $defaultUserAgent;
|
||||
|
||||
private static $defaultRegion = Region::CN_N1;
|
||||
|
||||
/**
|
||||
* ClientConfiguration constructor.
|
||||
* @param int $connectionTimeoutInMillis
|
||||
* @param int $socketTimeoutInMillis
|
||||
* @param null $userAgent
|
||||
* @param null $proxyUrl
|
||||
*/
|
||||
public function __construct(
|
||||
$connectionTimeoutInMillis = self::DEFAULT_CONNECTION_TIMEOUT_IN_MILLIS,
|
||||
$socketTimeoutInMillis = self::DEFAULT_SOCKET_TIMEOUT_IN_MILLIS,
|
||||
$userAgent = null,
|
||||
$region = null,
|
||||
$proxyUrl = null
|
||||
) {
|
||||
$this->connectionTimeoutInMillis = $connectionTimeoutInMillis;
|
||||
$this->socketTimeoutInMillis = $socketTimeoutInMillis;
|
||||
|
||||
$this->userAgent = isset($userAgent) ? $userAgent : self::$defaultUserAgent;
|
||||
$this->region = isset($region) ? $region : self::$defaultRegion;
|
||||
|
||||
$this->proxyUrl = $proxyUrl;
|
||||
}
|
||||
|
||||
public static function __init()
|
||||
{
|
||||
self::$defaultUserAgent = YopConstants::LANG.'/'.YopConstants::VERSION.'/'.php_uname('s').'/'.php_uname('r').'/m/m/'.phpversion();
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $userAgent;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $proxyUrl;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $connectionTimeoutInMillis;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $socketTimeoutInMillis;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $region;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getDefaultUserAgent()
|
||||
{
|
||||
return self::$defaultUserAgent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $defaultUserAgent
|
||||
*/
|
||||
public static function setDefaultUserAgent($defaultUserAgent)
|
||||
{
|
||||
self::$defaultUserAgent = $defaultUserAgent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getDefaultRegion()
|
||||
{
|
||||
return self::$defaultRegion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $defaultRegion
|
||||
*/
|
||||
public static function setDefaultRegion($defaultRegion)
|
||||
{
|
||||
self::$defaultRegion = $defaultRegion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getUserAgent()
|
||||
{
|
||||
return $this->userAgent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $userAgent
|
||||
* @return ClientConfiguration
|
||||
*/
|
||||
public function setUserAgent($userAgent)
|
||||
{
|
||||
$this->userAgent = $userAgent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProxyUrl()
|
||||
{
|
||||
return $this->proxyUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $proxyUrl
|
||||
* @return ClientConfiguration
|
||||
*/
|
||||
public function setProxyUrl($proxyUrl)
|
||||
{
|
||||
$this->proxyUrl = $proxyUrl;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getConnectionTimeoutInMillis()
|
||||
{
|
||||
return $this->connectionTimeoutInMillis;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $connectionTimeoutInMillis
|
||||
* @return ClientConfiguration
|
||||
*/
|
||||
public function setConnectionTimeoutInMillis($connectionTimeoutInMillis)
|
||||
{
|
||||
$this->connectionTimeoutInMillis = $connectionTimeoutInMillis;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getSocketTimeoutInMillis()
|
||||
{
|
||||
return $this->socketTimeoutInMillis;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $socketTimeoutInMillis
|
||||
* @return ClientConfiguration
|
||||
*/
|
||||
public function setSocketTimeoutInMillis($socketTimeoutInMillis)
|
||||
{
|
||||
$this->socketTimeoutInMillis = $socketTimeoutInMillis;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRegion()
|
||||
{
|
||||
return $this->region;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $region
|
||||
* @return ClientConfiguration
|
||||
*/
|
||||
public function setRegion($region)
|
||||
{
|
||||
$this->region = $region;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ClientConfiguration::__init();
|
||||
16
lib/Http/ContentType.php
Normal file
16
lib/Http/ContentType.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Http;
|
||||
|
||||
class ContentType
|
||||
{
|
||||
|
||||
const APPLICATION_FORM_URLENCODED = "application/x-www-form-urlencoded";
|
||||
|
||||
const APPLICATION_JSON = "application/json";
|
||||
|
||||
const APPLICATION_OCTET_STREAM = "application/octet-stream";
|
||||
|
||||
const MULTIPART_FORM_DATA = "multipart/form-data";
|
||||
|
||||
}
|
||||
133
lib/Http/ExecutionContext.php
Normal file
133
lib/Http/ExecutionContext.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Http;
|
||||
|
||||
use Yeepay\Yop\Sdk\Auth\Encryptor;
|
||||
use Yeepay\Yop\Sdk\Auth\Signer;
|
||||
use Yeepay\Yop\Sdk\Auth\SignOptions;
|
||||
use Yeepay\Yop\Sdk\Auth\YopRsaCredentials;
|
||||
|
||||
class ExecutionContext
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Signer
|
||||
*/
|
||||
private $signer;
|
||||
|
||||
/**
|
||||
* @var SignOptions
|
||||
*/
|
||||
private $signOptions;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $needEncrypt;
|
||||
|
||||
/**
|
||||
* @var Encryptor
|
||||
*/
|
||||
private $encryptor;
|
||||
|
||||
/**
|
||||
* @var YopRsaCredentials
|
||||
*/
|
||||
private $credentials;
|
||||
|
||||
/**
|
||||
* @return Signer
|
||||
*/
|
||||
public function getSigner()
|
||||
{
|
||||
return $this->signer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Signer $signer
|
||||
* @return ExecutionContext
|
||||
*/
|
||||
public function setSigner($signer)
|
||||
{
|
||||
$this->signer = $signer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SignOptions
|
||||
*/
|
||||
public function getSignOptions()
|
||||
{
|
||||
return $this->signOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SignOptions $signOptions
|
||||
* @return ExecutionContext
|
||||
*/
|
||||
public function setSignOptions($signOptions)
|
||||
{
|
||||
$this->signOptions = $signOptions;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $needEncrypt
|
||||
* @return ExecutionContext
|
||||
*/
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
$this->needEncrypt = $needEncrypt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Encryptor
|
||||
*/
|
||||
public function getEncryptor()
|
||||
{
|
||||
return $this->encryptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Encryptor $encryptor
|
||||
* @return ExecutionContext
|
||||
*/
|
||||
public function setEncryptor($encryptor)
|
||||
{
|
||||
$this->encryptor = $encryptor;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return YopRsaCredentials
|
||||
*/
|
||||
public function getCredentials()
|
||||
{
|
||||
return $this->credentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param YopRsaCredentials $credentials
|
||||
* @return ExecutionContext
|
||||
*/
|
||||
public function setCredentials($credentials)
|
||||
{
|
||||
$this->credentials = $credentials;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
100
lib/Http/Headers.php
Normal file
100
lib/Http/Headers.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Http;
|
||||
|
||||
class Headers
|
||||
{
|
||||
|
||||
/*
|
||||
* Standard HTTP Headers
|
||||
*/
|
||||
const AUTHORIZATION = "Authorization";
|
||||
|
||||
const CACHE_CONTROL = "Cache-Control";
|
||||
|
||||
const CONTENT_DISPOSITION = "Content-Disposition";
|
||||
|
||||
const CONTENT_ENCODING = "Content-Encoding";
|
||||
|
||||
const CONTENT_LENGTH = "Content-Length";
|
||||
|
||||
const CONTENT_MD5 = "Content-MD5";
|
||||
|
||||
const CONTENT_RANGE = "Content-Range";
|
||||
|
||||
const CONTENT_TYPE = "Content-Type";
|
||||
|
||||
const DATE = "Date";
|
||||
|
||||
const ETAG = "ETag";
|
||||
|
||||
const EXPIRES = "Expires";
|
||||
|
||||
const HOST = "Host";
|
||||
|
||||
const LAST_MODIFIED = "Last-Modified";
|
||||
|
||||
const LOCATION = "Location";
|
||||
|
||||
const RANGE = "Range";
|
||||
|
||||
const SERVER = "Server";
|
||||
|
||||
const TRANSFER_ENCODING = "Transfer-Encoding";
|
||||
|
||||
const USER_AGENT = "User-Agent";
|
||||
|
||||
/*
|
||||
* YOP Common HTTP Headers
|
||||
*/
|
||||
|
||||
const YOP_ACL = "x-yop-acl";
|
||||
|
||||
const YOP_CONTENT_SHA256 = "x-yop-content-sha256";
|
||||
|
||||
/**
|
||||
* 签名
|
||||
*/
|
||||
const YOP_SIGN = "x-yop-sign";
|
||||
|
||||
const YOP_HASH_CRC64ECMA = "x-yop-hash-crc64ecma";
|
||||
|
||||
const YOP_COPY_METADATA_DIRECTIVE = "x-yop-metadata-directive";
|
||||
|
||||
const YOP_COPY_SOURCE_IF_MATCH = "x-yop-copy-source-if-match";
|
||||
|
||||
const YOP_DATE = "x-yop-date";
|
||||
|
||||
const YOP_APPKEY = "x-yop-appkey";
|
||||
|
||||
const YOP_PREFIX = "x-yop-";
|
||||
|
||||
const YOP_REQUEST_ID = "x-yop-request-id";
|
||||
|
||||
const YOP_SECURITY_TOKEN = "x-yop-security-token";
|
||||
|
||||
const YOP_USER_METADATA_PREFIX = "x-yop-meta-";
|
||||
|
||||
const YOP_VIA = "x-yop-via";
|
||||
|
||||
const YOP_ENCRYPT_TYPE = "x-yop-encrypt-type";
|
||||
|
||||
/*
|
||||
* YOS HTTP Headers
|
||||
*/
|
||||
|
||||
const YOP_COPY_SOURCE = "x-yop-copy-source";
|
||||
|
||||
const YOP_COPY_SOURCE_IF_MODIFIED_SINCE = "x-yop-copy-source-if-modified-since";
|
||||
|
||||
const YOP_COPY_SOURCE_IF_NONE_MATCH = "x-yop-copy-source-if-none-match";
|
||||
|
||||
const YOP_COPY_SOURCE_IF_UNMODIFIED_SINCE = "x-yop-copy-source-if-unmodified-since";
|
||||
|
||||
const YOP_DEBUG_ID = "x-yop-debug-id";
|
||||
|
||||
const YOP_NEXT_APPEND_OFFSET = "x-yop-next-append-offset";
|
||||
|
||||
const YOP_OBJECT_TYPE = "x-yop-object-type";
|
||||
|
||||
}
|
||||
29
lib/Http/HttpMethod.php
Normal file
29
lib/Http/HttpMethod.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2014 Baidu, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* Http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Http;
|
||||
|
||||
class HttpMethod
|
||||
{
|
||||
|
||||
const GET = 'GET';
|
||||
const PUT = 'PUT';
|
||||
const POST = 'POST';
|
||||
const DELETE = 'DELETE';
|
||||
const HEAD = 'HEAD';
|
||||
|
||||
}
|
||||
16
lib/Http/HttpStatus.php
Normal file
16
lib/Http/HttpStatus.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Http;
|
||||
|
||||
class HttpStatus
|
||||
{
|
||||
|
||||
const SC_OK = 200;
|
||||
|
||||
const SC_NO_CONTENT = 204;
|
||||
|
||||
const SC_INTERNAL_SERVER_ERROR = 500;
|
||||
|
||||
const SC_BAD_GATEWAY = 502;
|
||||
|
||||
}
|
||||
144
lib/Http/YopHttpClient.php
Normal file
144
lib/Http/YopHttpClient.php
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Http;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use GuzzleHttp\Exception\ServerException;
|
||||
use GuzzleHttp\RequestOptions;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Yeepay\Yop\Sdk\Exception\YopClientException;
|
||||
use Yeepay\Yop\Sdk\Internal\MultiPartFile;
|
||||
use Yeepay\Yop\Sdk\Internal\Request;
|
||||
use Yeepay\Yop\Sdk\Log\LogFactory;
|
||||
use Yeepay\Yop\Sdk\Utils\Http\HttpUtils;
|
||||
|
||||
class YopHttpClient
|
||||
{
|
||||
|
||||
/**
|
||||
* @var ClientConfiguration
|
||||
*/
|
||||
private $clientConfiguration;
|
||||
|
||||
/**
|
||||
* @var Client
|
||||
*/
|
||||
private $guzzleClient;
|
||||
|
||||
/**
|
||||
* @var LoggerInterface
|
||||
*/
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* YopHttpClient constructor.
|
||||
* @param ClientConfiguration $clientConfiguration
|
||||
*/
|
||||
public function __construct(ClientConfiguration $clientConfiguration)
|
||||
{
|
||||
|
||||
$this->logger = LogFactory::getLogger(get_class($this));
|
||||
$this->clientConfiguration = $clientConfiguration;
|
||||
$guzzleClientConfig = [
|
||||
RequestOptions::CONNECT_TIMEOUT => $clientConfiguration->getConnectionTimeoutInMillis() / 1000,
|
||||
RequestOptions::TIMEOUT, $clientConfiguration->getSocketTimeoutInMillis() / 1000,
|
||||
];
|
||||
if (!empty($clientConfiguration->getProxyUrl())) {
|
||||
$guzzleClientConfig[RequestOptions::PROXY] = $clientConfiguration->getProxyUrl();
|
||||
}
|
||||
$this->guzzleClient = new Client($guzzleClientConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ExecutionContext $executionContext
|
||||
* @return YopHttpResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function execute(Request $request, ExecutionContext $executionContext)
|
||||
{
|
||||
$credentials = $executionContext->getCredentials();
|
||||
$request->addHeader(Headers::YOP_APPKEY, $credentials->getAppKey());
|
||||
$request->addHeader(Headers::USER_AGENT, $this->clientConfiguration->getUserAgent());
|
||||
if ($executionContext->isNeedEncrypt()) {
|
||||
$executionContext->getEncryptor()->encrypt($request);
|
||||
}
|
||||
$executionContext->getSigner()
|
||||
->sign($request, $executionContext->getCredentials(), $executionContext->getSignOptions());
|
||||
try {
|
||||
$guzzleResponse = $this->sendRequest($request);
|
||||
} catch (ServerException $e) {
|
||||
$guzzleResponse = $e->getResponse();
|
||||
} catch (\Throwable $e) {
|
||||
throw new YopClientException("execute request failed:".$e->getMessage());
|
||||
}
|
||||
|
||||
return new YopHttpResponse($guzzleResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return mixed|ResponseInterface
|
||||
* @throws GuzzleException
|
||||
* @throws YopClientException
|
||||
*/
|
||||
private function sendRequest(Request $request)
|
||||
{
|
||||
$uri = $request->getEndpoint().HttpUtils::urlEncodeExceptSlash($request->getResourcePath());
|
||||
if (!empty($request->getMultipartFiles())) {
|
||||
if ($request->getHttpMethod() == HttpMethod::POST) {
|
||||
$body = [];
|
||||
if (!empty($request->getParameters())) {
|
||||
foreach ($request->getParameters() as $k => $v) {
|
||||
if (!empty($v)) {
|
||||
foreach ($v as $value) {
|
||||
$body[] = ['name' => $k, 'contents' => $value];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($request->getMultipartFiles() as $k => $v) {
|
||||
$part = ['name' => $k];
|
||||
if (!empty($v)) {
|
||||
foreach ($v as $value) {
|
||||
/** @var MultiPartFile $value */
|
||||
$part['contents'] = $value->getContent();
|
||||
$part['filename'] = $value->getFileName();
|
||||
$body[] = $part;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->guzzleClient->request($request->getHttpMethod(), $uri,
|
||||
[
|
||||
RequestOptions::MULTIPART => $body,
|
||||
RequestOptions::HEADERS => $request->getHeaders(),
|
||||
]);
|
||||
} else {
|
||||
throw new YopClientException("contentType:multipart/form-data only support post request.");
|
||||
}
|
||||
}
|
||||
$requestIsPostOrPut = $request->getHttpMethod() == HttpMethod::POST || $request->getHttpMethod() == HttpMethod::PUT;
|
||||
$requestHasPayload = !empty($request->getContent());
|
||||
$putParamsInUri = !$requestIsPostOrPut || $requestHasPayload;
|
||||
if ($putParamsInUri) {
|
||||
$encodedParameters = \GuzzleHttp\Psr7\Query::build(HttpUtils::encodedParameters($request->getParameters()));
|
||||
if (!empty($encodedParameters)) {
|
||||
$uri = $uri.'?'.$encodedParameters;
|
||||
}
|
||||
}
|
||||
$requestOptions = [RequestOptions::HEADERS => $request->getHeaders()];
|
||||
if ($requestHasPayload) {
|
||||
$requestOptions[RequestOptions::BODY] = $request->getContent();
|
||||
} else {
|
||||
if ($requestIsPostOrPut) {
|
||||
$requestOptions[RequestOptions::BODY] = \GuzzleHttp\Psr7\Query::build(HttpUtils::encodedParameters($request->getParameters()));
|
||||
}
|
||||
}
|
||||
|
||||
return $this->guzzleClient->request($request->getHttpMethod(), $uri, $requestOptions);
|
||||
}
|
||||
|
||||
}
|
||||
140
lib/Http/YopHttpResponse.php
Normal file
140
lib/Http/YopHttpResponse.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Http;
|
||||
|
||||
use DateTime;
|
||||
use Exception;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Yeepay\Yop\Sdk\Log\LogFactory;
|
||||
use Yeepay\Yop\Sdk\Utils\DateUtils;
|
||||
|
||||
class YopHttpResponse
|
||||
{
|
||||
|
||||
/**
|
||||
* @var LoggerInterface
|
||||
*/
|
||||
private static $logger;
|
||||
|
||||
/**
|
||||
* @var Response
|
||||
*/
|
||||
private $httpResponse;
|
||||
|
||||
/**
|
||||
* @var StreamInterface
|
||||
*/
|
||||
private $stream;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $content;
|
||||
|
||||
public static function __init()
|
||||
{
|
||||
self::$logger = LogFactory::getLogger(self::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* YopHttpResponse constructor.
|
||||
* @param Response $response
|
||||
*/
|
||||
public function __construct(Response $response)
|
||||
{
|
||||
$this->httpResponse = $response;
|
||||
$this->stream = $response->getBody();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return null | string
|
||||
*/
|
||||
public function getHeader($name)
|
||||
{
|
||||
$values = $this->httpResponse->getHeader($name);
|
||||
if (empty($values)) {
|
||||
return null;
|
||||
} else {
|
||||
return $values[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return float
|
||||
*/
|
||||
public function getHeaderAsLong($name)
|
||||
{
|
||||
$values = $this->httpResponse->getHeader($name);
|
||||
if (empty($values)) {
|
||||
return -1;
|
||||
} else {
|
||||
return floatval($values[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @return DateTime|null
|
||||
*/
|
||||
public function getHeaderAsRFC822Date($name)
|
||||
{
|
||||
$values = $this->httpResponse->getHeader($name);
|
||||
if (empty($values)) {
|
||||
return null;
|
||||
} else {
|
||||
try {
|
||||
return DateUtils::parseRfc822Date($values[0]);
|
||||
} catch (Exception $e) {
|
||||
self::$logger->warning('Invalid '.$name.':'.$values[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return StreamInterface
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function readContent()
|
||||
{
|
||||
if (isset($this->content)) {
|
||||
return $this->content;
|
||||
}
|
||||
$this->content = $this->stream->__toString();
|
||||
$this->stream->close();
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatusCode()
|
||||
{
|
||||
return $this->httpResponse->getStatusCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStatusText()
|
||||
{
|
||||
return implode(' ', [
|
||||
$this->httpResponse->getProtocolVersion(), $this->httpResponse->getStatusCode(),
|
||||
$this->httpResponse->getReasonPhrase(),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
YopHttpResponse::__init();
|
||||
248
lib/Internal/DefaultRequest.php
Normal file
248
lib/Internal/DefaultRequest.php
Normal file
@@ -0,0 +1,248 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Internal;
|
||||
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
use Yeepay\Yop\Sdk\Http\Headers;
|
||||
|
||||
class DefaultRequest implements Request
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $resourcePath;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $parameters = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $multipartFiles = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $headers = [];
|
||||
|
||||
/**
|
||||
* @var Uri
|
||||
*/
|
||||
private $endpoint;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $serviceName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $httpMethod;
|
||||
|
||||
/**
|
||||
* @var StreamInterface
|
||||
*/
|
||||
private $content;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $yosAssigned;
|
||||
|
||||
/**
|
||||
* DefaultRequest constructor.
|
||||
* @param string $serviceName
|
||||
*/
|
||||
public function __construct($serviceName)
|
||||
{
|
||||
$this->serviceName = $serviceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getHeaders()
|
||||
{
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $headers
|
||||
*/
|
||||
public function setHeaders(array $headers)
|
||||
{
|
||||
$this->headers = $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*/
|
||||
public function addHeader($name, $value)
|
||||
{
|
||||
$this->headers[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getResourcePath()
|
||||
{
|
||||
return $this->resourcePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*/
|
||||
public function setResourcePath($path)
|
||||
{
|
||||
$this->resourcePath = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getParameters()
|
||||
{
|
||||
return $this->parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function setParameters($parameters)
|
||||
{
|
||||
$this->parameters = $parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param array $values
|
||||
*/
|
||||
public function addParameters($name, array $values)
|
||||
{
|
||||
$this->parameters[$name] = $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*/
|
||||
public function addParameter($name, $value)
|
||||
{
|
||||
if (isset($this->parameters[$name])) {
|
||||
$values = $this->parameters[$name];
|
||||
$values[] = $value;
|
||||
} else {
|
||||
$this->parameters[$name] = [$value];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|MultiPartFile
|
||||
*/
|
||||
public function getMultipartFiles()
|
||||
{
|
||||
return $this->multipartFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string|resource $file
|
||||
*/
|
||||
public function addMultiPartFile($name, $file)
|
||||
{
|
||||
if (isset($this->multipartFiles[$name])) {
|
||||
$values = $this->multipartFiles[$name];
|
||||
$values[] = new MultiPartFile($file);
|
||||
} else {
|
||||
$this->multipartFiles[$name] = [new MultiPartFile($file)];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Uri
|
||||
*/
|
||||
public function getEndpoint()
|
||||
{
|
||||
return $this->endpoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Uri $endpoint
|
||||
*/
|
||||
public function setEndpoint(Uri $endpoint)
|
||||
{
|
||||
$this->endpoint = $endpoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getHttpMethod()
|
||||
{
|
||||
return $this->httpMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $httpMethod
|
||||
*/
|
||||
public function setHttpMethod($httpMethod)
|
||||
{
|
||||
$this->httpMethod = $httpMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContentType()
|
||||
{
|
||||
return $this->headers[Headers::CONTENT_TYPE];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return StreamInterface
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $content StreamInterface
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getServiceName()
|
||||
{
|
||||
return $this->serviceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getYosFlag()
|
||||
{
|
||||
return $this->yosAssigned;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $flag bool
|
||||
*/
|
||||
public function setYosFlag($flag)
|
||||
{
|
||||
$this->yosAssigned = $flag;
|
||||
}
|
||||
|
||||
}
|
||||
75
lib/Internal/MultiPartFile.php
Normal file
75
lib/Internal/MultiPartFile.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Internal;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
use Yeepay\Yop\Sdk\Utils\ObjectSerializer;
|
||||
|
||||
class MultiPartFile
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $fileName;
|
||||
|
||||
/**
|
||||
* @var StreamInterface
|
||||
*/
|
||||
private $content;
|
||||
|
||||
/**
|
||||
* MultiPartFile constructor.
|
||||
* @param string|resource $file
|
||||
*/
|
||||
public function __construct($file)
|
||||
{
|
||||
if (is_string($file)) {
|
||||
$this->fileName = ObjectSerializer::sanitizeFilename($file);
|
||||
$this->content = \GuzzleHttp\Psr7\Utils::streamFor($file);
|
||||
} else {
|
||||
$meta_data = stream_get_meta_data($file);
|
||||
$this->fileName = ObjectSerializer::sanitizeFilename($meta_data['uri']);
|
||||
$this->content = \GuzzleHttp\Psr7\Utils::streamFor($file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFileName()
|
||||
{
|
||||
return $this->fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fileName
|
||||
* @return MultiPartFile
|
||||
*/
|
||||
public function setFileName($fileName)
|
||||
{
|
||||
$this->fileName = $fileName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return StreamInterface
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param StreamInterface $content
|
||||
* @return MultiPartFile
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
120
lib/Internal/Request.php
Normal file
120
lib/Internal/Request.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Internal;
|
||||
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
interface Request
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getHeaders();
|
||||
|
||||
/**
|
||||
* @param array $headers
|
||||
*/
|
||||
public function setHeaders(array $headers);
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*/
|
||||
public function addHeader($name, $value);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getResourcePath();
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*/
|
||||
public function setResourcePath($path);
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getParameters();
|
||||
|
||||
/**
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function setParameters($parameters);
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param array $values
|
||||
*/
|
||||
public function addParameters($name, array $values);
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*/
|
||||
public function addParameter($name, $value);
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getMultipartFiles();
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string|resource $file
|
||||
*/
|
||||
public function addMultiPartFile($name, $file);
|
||||
|
||||
/**
|
||||
* @return Uri
|
||||
*/
|
||||
public function getEndpoint();
|
||||
|
||||
/**
|
||||
* @param Uri $endpoint
|
||||
*/
|
||||
public function setEndpoint(Uri $endpoint);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getHttpMethod();
|
||||
|
||||
/**
|
||||
* @param string $httpMethod
|
||||
*/
|
||||
public function setHttpMethod($httpMethod);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContentType();
|
||||
|
||||
/**
|
||||
* @return StreamInterface
|
||||
*/
|
||||
public function getContent();
|
||||
|
||||
/**
|
||||
* @param StreamInterface $content
|
||||
*/
|
||||
public function setContent($content);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getServiceName();
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getYosFlag();
|
||||
|
||||
/**
|
||||
* @param bool $flag
|
||||
*/
|
||||
public function setYosFlag($flag);
|
||||
|
||||
}
|
||||
88
lib/Log/LogFactory.php
Normal file
88
lib/Log/LogFactory.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Log;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* The global LogFactory for the SDK.
|
||||
*/
|
||||
class LogFactory
|
||||
{
|
||||
|
||||
/**
|
||||
* @var LogFactoryInterface the LogFactory instance
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
private static $logLevel;
|
||||
|
||||
private static $logLevelMapping;
|
||||
|
||||
public static function __init()
|
||||
{
|
||||
LogFactory::$instance = new NullLogFactory();
|
||||
LogFactory::$logLevelMapping = [
|
||||
'emergency' => 0,
|
||||
'alert' => 1,
|
||||
'critical' => 2,
|
||||
'error' => 3,
|
||||
'warning' => 4,
|
||||
'notice' => 5,
|
||||
'info' => 6,
|
||||
'debug' => 7,
|
||||
];
|
||||
LogFactory::$logLevel = 6;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LogFactoryInterface $logFactory the logFactory interface.
|
||||
* @throws \InvalidArgumentException if $logFactory is null.
|
||||
*/
|
||||
public static function setInstance(LogFactoryInterface $logFactory)
|
||||
{
|
||||
if ($logFactory === null) {
|
||||
throw new \InvalidArgumentException(
|
||||
'$logFactory should not be null.'
|
||||
);
|
||||
}
|
||||
LogFactory::$instance = $logFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $logLevel the log level. The value can be 'emergency',
|
||||
* 'alert', 'critical', 'error', 'warning', 'notice', 'info', or
|
||||
* 'debug'.
|
||||
* @throws \InvalidArgumentException if no such a log level is defined.
|
||||
*/
|
||||
public static function setLogLevel($logLevel)
|
||||
{
|
||||
if (isset(LogFactory::$logLevelMapping[$logLevel])) {
|
||||
LogFactory::$logLevel = LogFactory::$logLevelMapping[$logLevel];
|
||||
} else {
|
||||
throw new \InvalidArgumentException(
|
||||
"Unrecognized log level $logLevel"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean true if the debug log level is enabled.
|
||||
*/
|
||||
public static function isDebugEnabled()
|
||||
{
|
||||
return LogFactory::$logLevel >= 7;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name string the name of logger
|
||||
* @return LoggerInterface the Logger instance
|
||||
*/
|
||||
public static function getLogger($name)
|
||||
{
|
||||
return LogFactory::$instance->getLogger($name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LogFactory::__init();
|
||||
31
lib/Log/LogFactoryInterface.php
Normal file
31
lib/Log/LogFactoryInterface.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2014 Baidu, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* Http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Log;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
interface LogFactoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $name string
|
||||
* @return LoggerInterface
|
||||
*/
|
||||
public function getLogger($name);
|
||||
|
||||
}
|
||||
59
lib/Log/MonoLogFactory.php
Normal file
59
lib/Log/MonoLogFactory.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2014 Baidu, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* Http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Log;
|
||||
|
||||
use Monolog\Logger;
|
||||
|
||||
/**
|
||||
* A LogFactory for Monolog.
|
||||
*/
|
||||
class MonoLogFactory implements LogFactoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $handlers;
|
||||
|
||||
/**
|
||||
* Constructs a new MonoLogFactory instance.
|
||||
* @param array $handlers log handlers
|
||||
*/
|
||||
public function __construct(array $handlers = null)
|
||||
{
|
||||
$this->handlers = $handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns \Monolog\Logger.
|
||||
* @param string $name the name of logger
|
||||
* @return \Monolog\Logger a monolog logger instance
|
||||
*/
|
||||
public function getLogger($name)
|
||||
{
|
||||
$logger = new Logger($name);
|
||||
if ($this->handlers !== null) {
|
||||
foreach ($this->handlers as $handler) {
|
||||
$logger->pushHandler($handler);
|
||||
}
|
||||
}
|
||||
|
||||
return $logger;
|
||||
}
|
||||
|
||||
}
|
||||
38
lib/Log/NullLogFactory.php
Normal file
38
lib/Log/NullLogFactory.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2014 Baidu, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* Http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Log;
|
||||
|
||||
use Psr\Log\NullLogger;
|
||||
|
||||
/**
|
||||
* A LogFactory that returns a NullLogger.
|
||||
*/
|
||||
class NullLogFactory implements LogFactoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Always returns a NullLogger.
|
||||
* @param string $name the name of logger
|
||||
* @return Psr\Log\NullLogger a NullLogger
|
||||
*/
|
||||
public function getLogger($name)
|
||||
{
|
||||
return new NullLogger();
|
||||
}
|
||||
|
||||
}
|
||||
40
lib/Model/BaseRequest.php
Normal file
40
lib/Model/BaseRequest.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Model;
|
||||
|
||||
abstract class BaseRequest
|
||||
{
|
||||
|
||||
/**
|
||||
* @var RequestConfig
|
||||
*/
|
||||
private $requestConfig;
|
||||
|
||||
/**
|
||||
* @return RequestConfig
|
||||
*/
|
||||
public function getRequestConfig()
|
||||
{
|
||||
return $this->requestConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RequestConfig $requestConfig
|
||||
* @return BaseRequest
|
||||
*/
|
||||
public function setRequestConfig($requestConfig)
|
||||
{
|
||||
$this->requestConfig = $requestConfig;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getOperationId()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
44
lib/Model/BaseResponse.php
Normal file
44
lib/Model/BaseResponse.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Model;
|
||||
|
||||
abstract class BaseResponse
|
||||
{
|
||||
|
||||
/**
|
||||
* @var YopResponseMetadata
|
||||
*/
|
||||
private $metadata;
|
||||
|
||||
/**
|
||||
* BaseResponse constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->metadata = $this->getMetaDataInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return YopResponseMetadata
|
||||
*/
|
||||
public function getMetadata()
|
||||
{
|
||||
return $this->metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return YopResponseMetadata
|
||||
*/
|
||||
protected function getMetaDataInstance()
|
||||
{
|
||||
return new YopResponseMetadata();
|
||||
}
|
||||
|
||||
abstract function getResultClass();
|
||||
|
||||
/**
|
||||
* @param mixed $result
|
||||
*/
|
||||
abstract function setResult($result);
|
||||
|
||||
}
|
||||
57
lib/Model/ModelInterface.php
Normal file
57
lib/Model/ModelInterface.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Model;
|
||||
|
||||
interface ModelInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName();
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
* @return array
|
||||
*/
|
||||
public static function swaggerTypes();
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @return array
|
||||
*/
|
||||
public static function swaggerFormats();
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap();
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
* @return array
|
||||
*/
|
||||
public static function setters();
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
* @return array
|
||||
*/
|
||||
public static function getters();
|
||||
|
||||
/**
|
||||
* Show all the invalid properties with reasons.
|
||||
* @return array
|
||||
*/
|
||||
public function listInvalidProperties();
|
||||
|
||||
/**
|
||||
* Validate all the properties in the model
|
||||
* return true if all passed
|
||||
* @return bool
|
||||
*/
|
||||
public function valid();
|
||||
|
||||
}
|
||||
125
lib/Model/RequestConfig.php
Normal file
125
lib/Model/RequestConfig.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Auth\YopRsaCredentials;
|
||||
|
||||
class RequestConfig
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $appKey;
|
||||
|
||||
/**
|
||||
* @var YopRsaCredentials
|
||||
*/
|
||||
private $credentials;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $customRequestHeaders;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $needEncrypt;
|
||||
|
||||
/**
|
||||
* RequestConfig constructor.
|
||||
* @param null $appKey
|
||||
* @param YopRsaCredentials|null $credentials
|
||||
* @param array|null $customRequestHeaders
|
||||
* @param bool $needEncrypt
|
||||
*/
|
||||
public function __construct(
|
||||
$appKey = null,
|
||||
YopRsaCredentials $credentials = null,
|
||||
array $customRequestHeaders = null,
|
||||
$needEncrypt = false
|
||||
) {
|
||||
$this->appKey = $appKey;
|
||||
$this->credentials = $credentials;
|
||||
$this->customRequestHeaders = $customRequestHeaders;
|
||||
$this->needEncrypt = $needEncrypt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAppKey()
|
||||
{
|
||||
return $this->appKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $appKey
|
||||
* @return RequestConfig
|
||||
*/
|
||||
public function setAppKey($appKey)
|
||||
{
|
||||
$this->appKey = $appKey;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return YopRsaCredentials
|
||||
*/
|
||||
public function getCredentials()
|
||||
{
|
||||
return $this->credentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param YopRsaCredentials $credentials
|
||||
* @return RequestConfig
|
||||
*/
|
||||
public function setCredentials($credentials)
|
||||
{
|
||||
$this->credentials = $credentials;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCustomRequestHeaders()
|
||||
{
|
||||
return $this->customRequestHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $customRequestHeaders
|
||||
* @return RequestConfig
|
||||
*/
|
||||
public function setCustomRequestHeaders($customRequestHeaders)
|
||||
{
|
||||
$this->customRequestHeaders = $customRequestHeaders;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isNeedEncrypt()
|
||||
{
|
||||
return $this->needEncrypt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $needEncrypt
|
||||
* @return RequestConfig
|
||||
*/
|
||||
public function setNeedEncrypt($needEncrypt)
|
||||
{
|
||||
$this->needEncrypt = $needEncrypt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
150
lib/Model/Transform/BaseResponseUnMarshaller.php
Normal file
150
lib/Model/Transform/BaseResponseUnMarshaller.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Model\Transform;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Yeepay\Yop\Sdk\Exception\YopClientException;
|
||||
use Yeepay\Yop\Sdk\Exception\YopServiceException;
|
||||
use Yeepay\Yop\Sdk\Http\ContentType;
|
||||
use Yeepay\Yop\Sdk\Http\Headers;
|
||||
use Yeepay\Yop\Sdk\Http\HttpStatus;
|
||||
use Yeepay\Yop\Sdk\Http\YopHttpResponse;
|
||||
use Yeepay\Yop\Sdk\Log\LogFactory;
|
||||
use Yeepay\Yop\Sdk\Model\BaseResponse;
|
||||
use Yeepay\Yop\Sdk\Model\YopResponseMetadata;
|
||||
use Yeepay\Yop\Sdk\Utils\ObjectSerializer;
|
||||
use Yeepay\Yop\Sdk\Utils\YopConstants;
|
||||
|
||||
abstract class BaseResponseUnMarshaller implements ResponseUnMarshaller
|
||||
{
|
||||
|
||||
/**
|
||||
* @var LoggerInterface
|
||||
*/
|
||||
private static $logger;
|
||||
|
||||
public static function __init()
|
||||
{
|
||||
self::$logger = LogFactory::getLogger(self::class);
|
||||
}
|
||||
|
||||
public function unmarshal(YopHttpResponse $yopHttpResponse, ResponseUnMarshalParams $params)
|
||||
{
|
||||
$response = $this->getResponseInstance();
|
||||
$this->handleResponseMetaData($yopHttpResponse, $response->getMetadata());
|
||||
$this->checkSignature($yopHttpResponse, $response->getMetadata()->getYopSign(), $params);
|
||||
$this->handleContent($yopHttpResponse, $response->getMetadata()->getContentType(), $response, $params);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BaseResponse
|
||||
*/
|
||||
protected abstract function getResponseInstance();
|
||||
|
||||
/**
|
||||
* @param YopHttpResponse $yopHttpResponse
|
||||
* @param YopResponseMetadata $responseMetadata
|
||||
*/
|
||||
public function handleResponseMetaData($yopHttpResponse, YopResponseMetadata $responseMetadata)
|
||||
{
|
||||
$responseMetadata->setYopRequestId($yopHttpResponse->getHeader(Headers::YOP_REQUEST_ID));
|
||||
$responseMetadata->setYopContentSha256($yopHttpResponse->getHeader(Headers::YOP_CONTENT_SHA256));
|
||||
$responseMetadata->setYopSign($yopHttpResponse->getHeader(Headers::YOP_SIGN));
|
||||
$responseMetadata->setYopVia($yopHttpResponse->getHeader(Headers::YOP_VIA));
|
||||
$responseMetadata->setContentDisposition($yopHttpResponse->getHeader(Headers::CONTENT_DISPOSITION));
|
||||
$responseMetadata->setContentEncoding($yopHttpResponse->getHeader(Headers::CONTENT_ENCODING));
|
||||
$responseMetadata->setContentLength($yopHttpResponse->getHeaderAsLong(Headers::CONTENT_LENGTH));
|
||||
$responseMetadata->setContentType($yopHttpResponse->getHeader(Headers::CONTENT_TYPE));
|
||||
$responseMetadata->setDate($yopHttpResponse->getHeaderAsRFC822Date(Headers::DATE));
|
||||
$responseMetadata->setTransferEncoding($yopHttpResponse->getHeader(Headers::TRANSFER_ENCODING));
|
||||
|
||||
$etag = $yopHttpResponse->getHeader(Headers::ETAG);
|
||||
if (isset($etag)) {
|
||||
//TODO 此处对比java版有所简略
|
||||
$responseMetadata->setEtag($etag);
|
||||
}
|
||||
$responseMetadata->setExpires($yopHttpResponse->getHeaderAsRFC822Date(Headers::EXPIRES));
|
||||
$responseMetadata->setLastModified($yopHttpResponse->getHeaderAsRFC822Date(Headers::LAST_MODIFIED));
|
||||
$responseMetadata->setServer($yopHttpResponse->getHeader(Headers::SERVER));
|
||||
if ($responseMetadata->getYopVia() == YopConstants::DEFAULT_SANDBOX_VIA) {
|
||||
self::$logger->info('response from sandbox-gateway');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function checkSignature(YopHttpResponse $yopHttpResponse, $signature, ResponseUnMarshalParams $params)
|
||||
{
|
||||
if (isset($signature)) {
|
||||
$params->getSigner()
|
||||
->checkSignature($yopHttpResponse, $signature, $params->getPublicKey(), $params->getSignOptions());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param YopHttpResponse $yopHttpResponse
|
||||
* @param $contentType
|
||||
* @param BaseResponse $response
|
||||
* @param ResponseUnMarshalParams $params
|
||||
* @throws YopClientException
|
||||
*/
|
||||
protected function handleContent(
|
||||
YopHttpResponse $yopHttpResponse,
|
||||
$contentType,
|
||||
BaseResponse $response,
|
||||
ResponseUnMarshalParams $params
|
||||
) {
|
||||
$content = $yopHttpResponse->readContent();
|
||||
if ($params->isNeedDecrypt() && $contentType == ContentType::APPLICATION_JSON) {
|
||||
$content = $params->getEncryptor()->decrypt($content);
|
||||
}
|
||||
$statusCode = $yopHttpResponse->getStatusCode();
|
||||
if ($statusCode / 100 == HttpStatus::SC_OK / 100) {
|
||||
if ($statusCode != HttpStatus::SC_NO_CONTENT) {
|
||||
$data = json_decode($content);
|
||||
$response->setResult(ObjectSerializer::deserialize($data->{'result'}, $response->getResultClass()));
|
||||
}
|
||||
} elseif ($statusCode >= HttpStatus::SC_INTERNAL_SERVER_ERROR && $statusCode != HttpStatus::SC_BAD_GATEWAY) {
|
||||
$this->handleErrorResponse($content, $response->getMetadata(), $yopHttpResponse);
|
||||
} else {
|
||||
throw new YopClientException("Unexpected http statusCode:".$statusCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $content
|
||||
* @param YopResponseMetadata $responseMetadata
|
||||
* @param YopHttpResponse $yopHttpResponse
|
||||
* @throws YopServiceException
|
||||
*/
|
||||
protected function handleErrorResponse(
|
||||
$content,
|
||||
YopResponseMetadata $responseMetadata,
|
||||
YopHttpResponse $yopHttpResponse
|
||||
) {
|
||||
$yopServiceException = null;
|
||||
if (!empty($content)) {
|
||||
try {
|
||||
$data = json_decode($content, true);
|
||||
dd($data);
|
||||
$yopServiceException = new YopServiceException($data['message'], $data['code']);
|
||||
$yopServiceException->setRequestId($data['requestId']);
|
||||
$yopServiceException->setSubErrorCode($data['subCode']);
|
||||
$yopServiceException->setSubErrorMessage($data['subMessage']);
|
||||
} catch (\Exception $e) {
|
||||
self::$logger->error("unable to parse error response, content".$content);
|
||||
}
|
||||
}
|
||||
if (!isset($yopServiceException)) {
|
||||
$yopServiceException = new YopServiceException($yopHttpResponse->getStatusText());
|
||||
$yopServiceException->setRequestId($responseMetadata->getYopRequestId());
|
||||
}
|
||||
$yopServiceException->setStatusCode($yopHttpResponse->getStatusCode());
|
||||
$yopServiceException->setErrorType(YopServiceException::ERROR_TYPE_SERVICE);
|
||||
throw $yopServiceException;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BaseResponseUnMarshaller::__init();
|
||||
17
lib/Model/Transform/RequestMarshaller.php
Normal file
17
lib/Model/Transform/RequestMarshaller.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Model\Transform;
|
||||
|
||||
use Yeepay\Yop\Sdk\Internal\Request;
|
||||
use Yeepay\Yop\Sdk\Model\BaseRequest;
|
||||
|
||||
interface RequestMarshaller
|
||||
{
|
||||
|
||||
/**
|
||||
* @param BaseRequest $request
|
||||
* @return Request
|
||||
*/
|
||||
public function marshal($request);
|
||||
|
||||
}
|
||||
132
lib/Model/Transform/ResponseUnMarshalParams.php
Normal file
132
lib/Model/Transform/ResponseUnMarshalParams.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Model\Transform;
|
||||
|
||||
use Yeepay\Yop\Sdk\Auth\Encryptor;
|
||||
use Yeepay\Yop\Sdk\Auth\Signer;
|
||||
use Yeepay\Yop\Sdk\Auth\SignOptions;
|
||||
|
||||
class ResponseUnMarshalParams
|
||||
{
|
||||
|
||||
/**
|
||||
* @var resource
|
||||
*/
|
||||
private $publicKey;
|
||||
|
||||
/**
|
||||
* @var Signer
|
||||
*/
|
||||
private $signer;
|
||||
|
||||
/**
|
||||
* @var SignOptions
|
||||
*/
|
||||
private $signOptions;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $needDecrypt;
|
||||
|
||||
/**
|
||||
* @var Encryptor
|
||||
*/
|
||||
private $encryptor;
|
||||
|
||||
/**
|
||||
* @return resource
|
||||
*/
|
||||
public function getPublicKey()
|
||||
{
|
||||
return $this->publicKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resource $publicKey
|
||||
* @return ResponseUnMarshalParams
|
||||
*/
|
||||
public function setPublicKey($publicKey)
|
||||
{
|
||||
$this->publicKey = $publicKey;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Signer
|
||||
*/
|
||||
public function getSigner()
|
||||
{
|
||||
return $this->signer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Signer $signer
|
||||
* @return ResponseUnMarshalParams
|
||||
*/
|
||||
public function setSigner($signer)
|
||||
{
|
||||
$this->signer = $signer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SignOptions
|
||||
*/
|
||||
public function getSignOptions()
|
||||
{
|
||||
return $this->signOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SignOptions $signOptions
|
||||
* @return ResponseUnMarshalParams
|
||||
*/
|
||||
public function setSignOptions($signOptions)
|
||||
{
|
||||
$this->signOptions = $signOptions;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isNeedDecrypt()
|
||||
{
|
||||
return $this->needDecrypt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $needDecrypt
|
||||
* @return ResponseUnMarshalParams
|
||||
*/
|
||||
public function setNeedDecrypt($needDecrypt)
|
||||
{
|
||||
$this->needDecrypt = $needDecrypt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Encryptor
|
||||
*/
|
||||
public function getEncryptor()
|
||||
{
|
||||
return $this->encryptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Encryptor $encryptor
|
||||
* @return ResponseUnMarshalParams
|
||||
*/
|
||||
public function setEncryptor($encryptor)
|
||||
{
|
||||
$this->encryptor = $encryptor;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
17
lib/Model/Transform/ResponseUnMarshaller.php
Normal file
17
lib/Model/Transform/ResponseUnMarshaller.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Model\Transform;
|
||||
|
||||
use Yeepay\Yop\Sdk\Http\YopHttpResponse;
|
||||
|
||||
interface ResponseUnMarshaller
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $yopHttpResponse YopHttpResponse
|
||||
* @param ResponseUnMarshalParams $params
|
||||
* @return mixed
|
||||
*/
|
||||
public function unmarshal(YopHttpResponse $yopHttpResponse, ResponseUnMarshalParams $params);
|
||||
|
||||
}
|
||||
43
lib/Model/Transform/YosDownloadResponseUnMarshaller.php
Normal file
43
lib/Model/Transform/YosDownloadResponseUnMarshaller.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Model\Transform;
|
||||
|
||||
use Yeepay\Yop\Sdk\Exception\YopClientException;
|
||||
use Yeepay\Yop\Sdk\Http\ContentType;
|
||||
use Yeepay\Yop\Sdk\Http\HttpStatus;
|
||||
use Yeepay\Yop\Sdk\Http\YopHttpResponse;
|
||||
use Yeepay\Yop\Sdk\Model\BaseResponse;
|
||||
use Yeepay\Yop\Sdk\Model\YosDownloadResponse;
|
||||
|
||||
class YosDownloadResponseUnMarshaller extends BaseResponseUnMarshaller
|
||||
{
|
||||
|
||||
/**
|
||||
* @return YosDownloadResponse
|
||||
*/
|
||||
protected function getResponseInstance()
|
||||
{
|
||||
return new YosDownloadResponse();
|
||||
}
|
||||
|
||||
protected function handleContent(
|
||||
YopHttpResponse $yopHttpResponse,
|
||||
$contentType,
|
||||
BaseResponse $response,
|
||||
ResponseUnMarshalParams $params
|
||||
) {
|
||||
$statusCode = $yopHttpResponse->getStatusCode();
|
||||
if ($statusCode / 100 == HttpStatus::SC_OK / 100 && $statusCode != HttpStatus::SC_NO_CONTENT) {
|
||||
$response->setResult($yopHttpResponse->getContent());
|
||||
} elseif ($statusCode >= HttpStatus::SC_INTERNAL_SERVER_ERROR && $statusCode != HttpStatus::SC_BAD_GATEWAY) {
|
||||
$content = $yopHttpResponse->readContent();
|
||||
if ($params->isNeedDecrypt() && $contentType == ContentType::APPLICATION_JSON) {
|
||||
$content = $params->getEncryptor()->decrypt($content);
|
||||
}
|
||||
$this->handleErrorResponse($content, $response->getMetadata(), $yopHttpResponse);
|
||||
} else {
|
||||
throw new YopClientException("Unexpected http statusCode:".$statusCode);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
128
lib/Model/YopErrorResponse.php
Normal file
128
lib/Model/YopErrorResponse.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Model;
|
||||
|
||||
class YopErrorResponse
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $requestId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $message;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $subCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $subMessage;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRequestId()
|
||||
{
|
||||
return $this->requestId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $requestId
|
||||
* @return YopErrorResponse
|
||||
*/
|
||||
public function setRequestId($requestId)
|
||||
{
|
||||
$this->requestId = $requestId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
* @return YopErrorResponse
|
||||
*/
|
||||
public function setCode($code)
|
||||
{
|
||||
$this->code = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMessage()
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @return YopErrorResponse
|
||||
*/
|
||||
public function setMessage($message)
|
||||
{
|
||||
$this->message = $message;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSubCode()
|
||||
{
|
||||
return $this->subCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $subCode
|
||||
* @return YopErrorResponse
|
||||
*/
|
||||
public function setSubCode($subCode)
|
||||
{
|
||||
$this->subCode = $subCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSubMessage()
|
||||
{
|
||||
return $this->subMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $subMessage
|
||||
* @return YopErrorResponse
|
||||
*/
|
||||
public function setSubMessage($subMessage)
|
||||
{
|
||||
$this->subMessage = $subMessage;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
418
lib/Model/YopResponseMetadata.php
Normal file
418
lib/Model/YopResponseMetadata.php
Normal file
@@ -0,0 +1,418 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Model;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class YopResponseMetadata
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $yopRequestId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $yopSign;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $yopContentSha256;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $yopVia;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $contentDisposition;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $transferEncoding;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $contentEncoding;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $contentLength = -1;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $contentMd5;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $contentRange;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $contentType;
|
||||
|
||||
/**
|
||||
* @var DateTime
|
||||
*/
|
||||
private $date;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $etag;
|
||||
|
||||
/**
|
||||
* @var DateTime
|
||||
*/
|
||||
private $expires;
|
||||
|
||||
/**
|
||||
* @var DateTime
|
||||
*/
|
||||
private $lastModified;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $server;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $location;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getYopRequestId()
|
||||
{
|
||||
return $this->yopRequestId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $yopRequestId
|
||||
* @return YopResponseMetadata
|
||||
*/
|
||||
public function setYopRequestId($yopRequestId)
|
||||
{
|
||||
$this->yopRequestId = $yopRequestId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getYopSign()
|
||||
{
|
||||
return $this->yopSign;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $yopSign
|
||||
* @return YopResponseMetadata
|
||||
*/
|
||||
public function setYopSign($yopSign)
|
||||
{
|
||||
$this->yopSign = $yopSign;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getYopContentSha256()
|
||||
{
|
||||
return $this->yopContentSha256;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $yopContentSha256
|
||||
* @return YopResponseMetadata
|
||||
*/
|
||||
public function setYopContentSha256($yopContentSha256)
|
||||
{
|
||||
$this->yopContentSha256 = $yopContentSha256;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getYopVia()
|
||||
{
|
||||
return $this->yopVia;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $yopVia
|
||||
* @return YopResponseMetadata
|
||||
*/
|
||||
public function setYopVia($yopVia)
|
||||
{
|
||||
$this->yopVia = $yopVia;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContentDisposition()
|
||||
{
|
||||
return $this->contentDisposition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $contentDisposition
|
||||
* @return YopResponseMetadata
|
||||
*/
|
||||
public function setContentDisposition($contentDisposition)
|
||||
{
|
||||
$this->contentDisposition = $contentDisposition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTransferEncoding()
|
||||
{
|
||||
return $this->transferEncoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $transferEncoding
|
||||
* @return YopResponseMetadata
|
||||
*/
|
||||
public function setTransferEncoding($transferEncoding)
|
||||
{
|
||||
$this->transferEncoding = $transferEncoding;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContentEncoding()
|
||||
{
|
||||
return $this->contentEncoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $contentEncoding
|
||||
* @return YopResponseMetadata
|
||||
*/
|
||||
public function setContentEncoding($contentEncoding)
|
||||
{
|
||||
$this->contentEncoding = $contentEncoding;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getContentLength()
|
||||
{
|
||||
return $this->contentLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $contentLength
|
||||
* @return YopResponseMetadata
|
||||
*/
|
||||
public function setContentLength($contentLength)
|
||||
{
|
||||
$this->contentLength = $contentLength;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContentMd5()
|
||||
{
|
||||
return $this->contentMd5;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $contentMd5
|
||||
* @return YopResponseMetadata
|
||||
*/
|
||||
public function setContentMd5($contentMd5)
|
||||
{
|
||||
$this->contentMd5 = $contentMd5;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContentRange()
|
||||
{
|
||||
return $this->contentRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $contentRange
|
||||
* @return YopResponseMetadata
|
||||
*/
|
||||
public function setContentRange($contentRange)
|
||||
{
|
||||
$this->contentRange = $contentRange;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContentType()
|
||||
{
|
||||
return $this->contentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $contentType
|
||||
* @return YopResponseMetadata
|
||||
*/
|
||||
public function setContentType($contentType)
|
||||
{
|
||||
$this->contentType = $contentType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getDate()
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTime $date
|
||||
* @return YopResponseMetadata
|
||||
*/
|
||||
public function setDate($date)
|
||||
{
|
||||
$this->date = $date;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEtag()
|
||||
{
|
||||
return $this->etag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $etag
|
||||
* @return YopResponseMetadata
|
||||
*/
|
||||
public function setEtag($etag)
|
||||
{
|
||||
$this->etag = $etag;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getExpires()
|
||||
{
|
||||
return $this->expires;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTime $expires
|
||||
* @return YopResponseMetadata
|
||||
*/
|
||||
public function setExpires($expires)
|
||||
{
|
||||
$this->expires = $expires;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getLastModified()
|
||||
{
|
||||
return $this->lastModified;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTime $lastModified
|
||||
* @return YopResponseMetadata
|
||||
*/
|
||||
public function setLastModified($lastModified)
|
||||
{
|
||||
$this->lastModified = $lastModified;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getServer()
|
||||
{
|
||||
return $this->server;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $server
|
||||
* @return YopResponseMetadata
|
||||
*/
|
||||
public function setServer($server)
|
||||
{
|
||||
$this->server = $server;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLocation()
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $location
|
||||
* @return YopResponseMetadata
|
||||
*/
|
||||
public function setLocation($location)
|
||||
{
|
||||
$this->location = $location;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
60
lib/Model/YosDownloadResponse.php
Normal file
60
lib/Model/YosDownloadResponse.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Model;
|
||||
|
||||
use GuzzleHttp\Psr7\LazyOpenStream;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
class YosDownloadResponse extends BaseResponse
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StreamInterface
|
||||
*/
|
||||
private $result;
|
||||
|
||||
/**
|
||||
* @return YopResponseMetadata
|
||||
*/
|
||||
public function getMetadata()
|
||||
{
|
||||
return parent::getMetadata();
|
||||
}
|
||||
|
||||
protected function getMetaDataInstance()
|
||||
{
|
||||
return new YosDownloadResponseMetadata();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $file string|resource
|
||||
*/
|
||||
public function save($file)
|
||||
{
|
||||
$sink = is_string($file)
|
||||
? new LazyOpenStream($file, 'w+')
|
||||
: \GuzzleHttp\Psr7\stream_for($file);
|
||||
$contentLength = $this->getMetadata()->getContentLength();
|
||||
\GuzzleHttp\Psr7\copy_to_stream(
|
||||
$this->result,
|
||||
$sink,
|
||||
(strlen($contentLength) > 0 && (int) $contentLength > 0) ? (int) $contentLength : -1
|
||||
);
|
||||
$sink->seek(0);
|
||||
$this->result->close();
|
||||
}
|
||||
|
||||
function getResultClass()
|
||||
{
|
||||
return StreamInterface::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param StreamInterface $result
|
||||
*/
|
||||
function setResult($result)
|
||||
{
|
||||
$this->result = $result;
|
||||
}
|
||||
|
||||
}
|
||||
80
lib/Model/YosDownloadResponseMetadata.php
Normal file
80
lib/Model/YosDownloadResponseMetadata.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Model;
|
||||
|
||||
class YosDownloadResponseMetadata extends YopResponseMetadata
|
||||
{
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $instanceLength = -1;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $cacheControl;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $appendOffset;
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getInstanceLength()
|
||||
{
|
||||
return $this->instanceLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $instanceLength
|
||||
* @return YosDownloadResponseMetadata
|
||||
*/
|
||||
public function setInstanceLength($instanceLength)
|
||||
{
|
||||
$this->instanceLength = $instanceLength;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCacheControl()
|
||||
{
|
||||
return $this->cacheControl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $cacheControl
|
||||
* @return YosDownloadResponseMetadata
|
||||
*/
|
||||
public function setCacheControl($cacheControl)
|
||||
{
|
||||
$this->cacheControl = $cacheControl;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getAppendOffset()
|
||||
{
|
||||
return $this->appendOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $appendOffset
|
||||
* @return YosDownloadResponseMetadata
|
||||
*/
|
||||
public function setAppendOffset($appendOffset)
|
||||
{
|
||||
$this->appendOffset = $appendOffset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
34
lib/Security/Aes/AesEncryptor.php
Normal file
34
lib/Security/Aes/AesEncryptor.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Security\Aes;
|
||||
|
||||
class AesEncryptor
|
||||
{
|
||||
|
||||
private static $AES_METHOD = 'aes-256-cbc';
|
||||
|
||||
private static $AES_IV;
|
||||
|
||||
public static function init()
|
||||
{
|
||||
$str = '';
|
||||
for ($i = 0; $i < 16; $i++) {
|
||||
$str .= chr(0);
|
||||
}
|
||||
self::$AES_IV = $str;
|
||||
}
|
||||
|
||||
public static function encryptAndEncodeBase64($data, $key)
|
||||
{
|
||||
return base64_encode(openssl_encrypt($data, self::$AES_METHOD, $key, OPENSSL_RAW_DATA, self::$AES_IV));
|
||||
}
|
||||
|
||||
public static function decodeBase64AndDecrypt($base64EncodedData, $key)
|
||||
{
|
||||
return openssl_decrypt(base64_decode($base64EncodedData), self::$AES_METHOD, $key, OPENSSL_RAW_DATA,
|
||||
self::$AES_IV);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
AesEncryptor::init();
|
||||
12
lib/Security/DigestAlg.php
Normal file
12
lib/Security/DigestAlg.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Security;
|
||||
|
||||
abstract class DigestAlg
|
||||
{
|
||||
|
||||
const SHA256 = 'SHA256';
|
||||
|
||||
const SHA512 = 'SHA512';
|
||||
|
||||
}
|
||||
18
lib/Security/Encodes.php
Normal file
18
lib/Security/Encodes.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Security;
|
||||
|
||||
class Encodes
|
||||
{
|
||||
|
||||
public static function base64url_encode($data)
|
||||
{
|
||||
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
|
||||
}
|
||||
|
||||
public static function base64url_decode($data)
|
||||
{
|
||||
return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT));
|
||||
}
|
||||
|
||||
}
|
||||
579
lib/Service/Account/AccountClient.php
Normal file
579
lib/Service/Account/AccountClient.php
Normal file
@@ -0,0 +1,579 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account;
|
||||
|
||||
use Yeepay\Yop\Sdk\Client\ClientExecutionParams;
|
||||
use Yeepay\Yop\Sdk\Client\ClientHandler;
|
||||
use Yeepay\Yop\Sdk\Client\ClientParams;
|
||||
use Yeepay\Yop\Sdk\Exception\YopClientException;
|
||||
use Yeepay\Yop\Sdk\Service\Account\Model as Model;
|
||||
|
||||
class AccountClient
|
||||
{
|
||||
|
||||
/**
|
||||
* @var ClientHandler
|
||||
*/
|
||||
private $clientHandler;
|
||||
|
||||
/**
|
||||
* AccountClient constructor.
|
||||
* @param ClientParams $clientParams
|
||||
*/
|
||||
function __construct(ClientParams $clientParams)
|
||||
{
|
||||
$this->clientHandler = new ClientHandler($clientParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\AccountinfosQueryRequest $request
|
||||
* @return Model\AccountinfosQueryResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function accountinfosQuery(Model\AccountinfosQueryRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
if ($request->getMerchantNo() == null) {
|
||||
throw new YopClientException("request.merchantNo is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\AccountinfosQueryRequestMarshaller::getInstance(),
|
||||
Model\AccountinfosQueryResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\AutoWithdrawRuleCancelRequest $request
|
||||
* @return Model\AutoWithdrawRuleCancelResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function autoWithdrawRuleCancel(Model\AutoWithdrawRuleCancelRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\AutoWithdrawRuleCancelRequestMarshaller::getInstance(),
|
||||
Model\AutoWithdrawRuleCancelResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\AutoWithdrawRuleQueryRequest $request
|
||||
* @return Model\AutoWithdrawRuleQueryResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function autoWithdrawRuleQuery(Model\AutoWithdrawRuleQueryRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
if ($request->getParentMerchantNo() == null) {
|
||||
throw new YopClientException("request.parentMerchantNo is required.");
|
||||
}
|
||||
if ($request->getMerchantNo() == null) {
|
||||
throw new YopClientException("request.merchantNo is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\AutoWithdrawRuleQueryRequestMarshaller::getInstance(),
|
||||
Model\AutoWithdrawRuleQueryResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\AutoWithdrawRuleSetRequest $request
|
||||
* @return Model\AutoWithdrawRuleSetResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function autoWithdrawRuleSet(Model\AutoWithdrawRuleSetRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\AutoWithdrawRuleSetRequestMarshaller::getInstance(),
|
||||
Model\AutoWithdrawRuleSetResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\BalanceBankAccountListRequest $request
|
||||
* @return Model\BalanceBankAccountListResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function balanceBankAccountList(Model\BalanceBankAccountListRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
if ($request->getParentMerchantNo() == null) {
|
||||
throw new YopClientException("request.parentMerchantNo is required.");
|
||||
}
|
||||
if ($request->getMerchantNo() == null) {
|
||||
throw new YopClientException("request.merchantNo is required.");
|
||||
}
|
||||
if ($request->getBankCode() == null) {
|
||||
throw new YopClientException("request.bankCode is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\BalanceBankAccountListRequestMarshaller::getInstance(),
|
||||
Model\BalanceBankAccountListResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\BalanceQueryRequest $request
|
||||
* @return Model\BalanceQueryResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function balanceQuery(Model\BalanceQueryRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
if ($request->getMerchantNo() == null) {
|
||||
throw new YopClientException("request.merchantNo is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request, Model\BalanceQueryRequestMarshaller::getInstance(),
|
||||
Model\BalanceQueryResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\EnterpriseAccountPayOrderRequest $request
|
||||
* @return Model\EnterpriseAccountPayOrderResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function enterpriseAccountPayOrder(Model\EnterpriseAccountPayOrderRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
if ($request->getBody() == null) {
|
||||
throw new YopClientException("request.body is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\EnterpriseAccountPayOrderRequestMarshaller::getInstance(),
|
||||
Model\EnterpriseAccountPayOrderResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\EnterpriseAutoPaymentOrderRequest $request
|
||||
* @return Model\EnterpriseAutoPaymentOrderResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function enterpriseAutoPaymentOrder(Model\EnterpriseAutoPaymentOrderRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\EnterpriseAutoPaymentOrderRequestMarshaller::getInstance(),
|
||||
Model\EnterpriseAutoPaymentOrderResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\EnterpriseAutoPaymentQueryRequest $request
|
||||
* @return Model\EnterpriseAutoPaymentQueryResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function enterpriseAutoPaymentQuery(Model\EnterpriseAutoPaymentQueryRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
if ($request->getMerchantNo() == null) {
|
||||
throw new YopClientException("request.merchantNo is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\EnterpriseAutoPaymentQueryRequestMarshaller::getInstance(),
|
||||
Model\EnterpriseAutoPaymentQueryResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\EnterpriseWithholdingOrderRequest $request
|
||||
* @return Model\EnterpriseWithholdingOrderResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function enterpriseWithholdingOrder(Model\EnterpriseWithholdingOrderRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\EnterpriseWithholdingOrderRequestMarshaller::getInstance(),
|
||||
Model\EnterpriseWithholdingOrderResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\PayCancelRequest $request
|
||||
* @return Model\PayCancelResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function payCancel(Model\PayCancelRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request, Model\PayCancelRequestMarshaller::getInstance(),
|
||||
Model\PayCancelResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\PayOrderRequest $request
|
||||
* @return Model\PayOrderResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function payOrder(Model\PayOrderRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request, Model\PayOrderRequestMarshaller::getInstance(),
|
||||
Model\PayOrderResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\PayQueryRequest $request
|
||||
* @return Model\PayQueryResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function payQuery(Model\PayQueryRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
if ($request->getParentMerchantNo() == null) {
|
||||
throw new YopClientException("request.parentMerchantNo is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request, Model\PayQueryRequestMarshaller::getInstance(),
|
||||
Model\PayQueryResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\ReceiptGetRequest $request
|
||||
* @return Model\ReceiptGetResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function receiptGet(Model\ReceiptGetRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
if ($request->getParentMerchantNo() == null) {
|
||||
throw new YopClientException("request.parentMerchantNo is required.");
|
||||
}
|
||||
if ($request->getOrderNo() == null) {
|
||||
throw new YopClientException("request.orderNo is required.");
|
||||
}
|
||||
if ($request->getTradeType() == null) {
|
||||
throw new YopClientException("request.tradeType is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request, Model\ReceiptGetRequestMarshaller::getInstance(),
|
||||
Model\ReceiptGetResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\RechargeBankOrderRequest $request
|
||||
* @return Model\RechargeBankOrderResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function rechargeBankOrder(Model\RechargeBankOrderRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\RechargeBankOrderRequestMarshaller::getInstance(),
|
||||
Model\RechargeBankOrderResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\RechargeOnlinebankOrderRequest $request
|
||||
* @return Model\RechargeOnlinebankOrderResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function rechargeOnlinebankOrder(Model\RechargeOnlinebankOrderRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\RechargeOnlinebankOrderRequestMarshaller::getInstance(),
|
||||
Model\RechargeOnlinebankOrderResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\RechargeOrderRequest $request
|
||||
* @return Model\RechargeOrderResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function rechargeOrder(Model\RechargeOrderRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\RechargeOrderRequestMarshaller::getInstance(),
|
||||
Model\RechargeOrderResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\RechargeQueryRequest $request
|
||||
* @return Model\RechargeQueryResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function rechargeQuery(Model\RechargeQueryRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
if ($request->getParentMerchantNo() == null) {
|
||||
throw new YopClientException("request.parentMerchantNo is required.");
|
||||
}
|
||||
if ($request->getMerchantNo() == null) {
|
||||
throw new YopClientException("request.merchantNo is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\RechargeQueryRequestMarshaller::getInstance(),
|
||||
Model\RechargeQueryResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\SupplierApplyRequest $request
|
||||
* @return Model\SupplierApplyResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function supplierApply(Model\SupplierApplyRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
if ($request->getBody() == null) {
|
||||
throw new YopClientException("request.body is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\SupplierApplyRequestMarshaller::getInstance(),
|
||||
Model\SupplierApplyResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\SupplierPayOrderRequest $request
|
||||
* @return Model\SupplierPayOrderResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function supplierPayOrder(Model\SupplierPayOrderRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\SupplierPayOrderRequestMarshaller::getInstance(),
|
||||
Model\SupplierPayOrderResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\SupplierQueryRequest $request
|
||||
* @return Model\SupplierQueryResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function supplierQuery(Model\SupplierQueryRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
if ($request->getMerchantNo() == null) {
|
||||
throw new YopClientException("request.merchantNo is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\SupplierQueryRequestMarshaller::getInstance(),
|
||||
Model\SupplierQueryResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\SupplierQueryProgressRequest $request
|
||||
* @return Model\SupplierQueryProgressResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function supplierQueryProgress(Model\SupplierQueryProgressRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
if ($request->getRequestNo() == null) {
|
||||
throw new YopClientException("request.requestNo is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\SupplierQueryProgressRequestMarshaller::getInstance(),
|
||||
Model\SupplierQueryProgressResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\TransferB2bOrderRequest $request
|
||||
* @return Model\TransferB2bOrderResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function transferB2bOrder(Model\TransferB2bOrderRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\TransferB2bOrderRequestMarshaller::getInstance(),
|
||||
Model\TransferB2bOrderResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\TransferB2bQueryRequest $request
|
||||
* @return Model\TransferB2bQueryResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function transferB2bQuery(Model\TransferB2bQueryRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
if ($request->getParentMerchantNo() == null) {
|
||||
throw new YopClientException("request.parentMerchantNo is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\TransferB2bQueryRequestMarshaller::getInstance(),
|
||||
Model\TransferB2bQueryResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\WithdrawCardBindRequest $request
|
||||
* @return Model\WithdrawCardBindResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function withdrawCardBind(Model\WithdrawCardBindRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\WithdrawCardBindRequestMarshaller::getInstance(),
|
||||
Model\WithdrawCardBindResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\WithdrawCardModifyRequest $request
|
||||
* @return Model\WithdrawCardModifyResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function withdrawCardModify(Model\WithdrawCardModifyRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\WithdrawCardModifyRequestMarshaller::getInstance(),
|
||||
Model\WithdrawCardModifyResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\WithdrawCardQueryRequest $request
|
||||
* @return Model\WithdrawCardQueryResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function withdrawCardQuery(Model\WithdrawCardQueryRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
if ($request->getMerchantNo() == null) {
|
||||
throw new YopClientException("request.merchantNo is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\WithdrawCardQueryRequestMarshaller::getInstance(),
|
||||
Model\WithdrawCardQueryResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\WithdrawOrderRequest $request
|
||||
* @return Model\WithdrawOrderResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function withdrawOrder(Model\WithdrawOrderRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\WithdrawOrderRequestMarshaller::getInstance(),
|
||||
Model\WithdrawOrderResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model\WithdrawQueryRequest $request
|
||||
* @return Model\WithdrawQueryResponse
|
||||
* @throws YopClientException
|
||||
*/
|
||||
public function withdrawQuery(Model\WithdrawQueryRequest $request)
|
||||
{
|
||||
if ($request == null) {
|
||||
throw new YopClientException("request is required.");
|
||||
}
|
||||
if ($request->getParentMerchantNo() == null) {
|
||||
throw new YopClientException("request.parentMerchantNo is required.");
|
||||
}
|
||||
$clientExecutionParams = new ClientExecutionParams($request,
|
||||
Model\WithdrawQueryRequestMarshaller::getInstance(),
|
||||
Model\WithdrawQueryResponseUnMarshaller::getInstance());
|
||||
|
||||
return $this->clientHandler->execute($clientExecutionParams);
|
||||
}
|
||||
|
||||
}
|
||||
126
lib/Service/Account/AccountClientBuilder.php
Normal file
126
lib/Service/Account/AccountClientBuilder.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account;
|
||||
|
||||
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 AccountClientBuilder
|
||||
{
|
||||
|
||||
/**
|
||||
* @var AuthorizationReqRegistry
|
||||
*/
|
||||
private static $authorizationReqRegistry;
|
||||
|
||||
public static function __init()
|
||||
{
|
||||
self::$authorizationReqRegistry = new AuthorityReqRegistryImpl();
|
||||
self::$authorizationReqRegistry->register('accountinfosQuery',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('autoWithdrawRuleCancel',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('autoWithdrawRuleQuery',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('autoWithdrawRuleSet',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('balanceBankAccountList',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('balanceQuery',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('enterpriseAccountPayOrder',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('enterpriseAutoPaymentOrder',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('enterpriseAutoPaymentQuery',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('enterpriseWithholdingOrder',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('payCancel',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('payOrder',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('payQuery',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('receiptGet',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('rechargeBankOrder',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('rechargeOnlinebankOrder',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('rechargeOrder',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('rechargeQuery',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('supplierApply',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('supplierPayOrder',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('supplierQuery',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('supplierQueryProgress',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('transferB2bOrder',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('transferB2bQuery',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('withdrawCardBind',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('withdrawCardModify',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('withdrawCardQuery',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('withdrawOrder',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
self::$authorizationReqRegistry->register('withdrawQuery',
|
||||
AuthorizationReqSupport::getAuthorizationReq('YOP-RSA2048-SHA256'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @var ClientParams
|
||||
*/
|
||||
private $clientParams;
|
||||
|
||||
/**
|
||||
* AccountClientBuilder constructor.
|
||||
* @param ClientParams $clientParams
|
||||
*/
|
||||
public function __construct(ClientParams $clientParams)
|
||||
{
|
||||
$this->clientParams = $clientParams;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
return new AccountClient($this->clientParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $config AppSdkConfig|array|AppSdkConfigProvider
|
||||
* @return AccountClientBuilder
|
||||
* @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 AccountClientBuilder($clientParams);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
AccountClientBuilder::__init();
|
||||
348
lib/Service/Account/Model/AccountinfosQueryAccountDTOResult.php
Normal file
348
lib/Service/Account/Model/AccountinfosQueryAccountDTOResult.php
Normal file
@@ -0,0 +1,348 @@
|
||||
<?php
|
||||
/**
|
||||
* AccountinfosQueryAccountDTOResult
|
||||
* PHP version 5
|
||||
* @author Swagger Codegen team
|
||||
* @package Yeepay\Yop\Sdk\
|
||||
* @category Class
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
|
||||
/**
|
||||
* 账户
|
||||
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
* Swagger Codegen version: 3.0.13
|
||||
*/
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use ArrayAccess;
|
||||
use Yeepay\Yop\Sdk\Model\ModelInterface;
|
||||
use Yeepay\Yop\Sdk\Utils\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* AccountinfosQueryAccountDTOResult Class Doc Comment
|
||||
* @author Swagger Codegen team
|
||||
* @package Yeepay\Yop\Sdk\
|
||||
* @category Class
|
||||
* @description
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
class AccountinfosQueryAccountDTOResult implements ModelInterface, ArrayAccess
|
||||
{
|
||||
|
||||
const DISCRIMINATOR = null;
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
* @var string
|
||||
*/
|
||||
protected static $swaggerModelName = 'AccountinfosQueryAccountDTOResult';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerTypes = [
|
||||
'accountType' => 'string',
|
||||
'createTime' => 'string',
|
||||
'balance' => 'float',
|
||||
'accountStatus' => 'string',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'accountType' => null,
|
||||
'createTime' => 'date-time',
|
||||
'balance' => null,
|
||||
'accountStatus' => null,
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
* @return array
|
||||
*/
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @return array
|
||||
*/
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'accountType' => 'accountType',
|
||||
'createTime' => 'createTime',
|
||||
'balance' => 'balance',
|
||||
'accountStatus' => 'accountStatus',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'accountType' => 'setAccountType',
|
||||
'createTime' => 'setCreateTime',
|
||||
'balance' => 'setBalance',
|
||||
'accountStatus' => 'setAccountStatus',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'accountType' => 'getAccountType',
|
||||
'createTime' => 'getCreateTime',
|
||||
'balance' => 'getBalance',
|
||||
'accountStatus' => 'getAccountStatus',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$swaggerModelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->container['accountType'] = isset($data['accountType']) ? $data['accountType'] : null;
|
||||
$this->container['createTime'] = isset($data['createTime']) ? $data['createTime'] : null;
|
||||
$this->container['balance'] = isset($data['balance']) ? $data['balance'] : null;
|
||||
$this->container['accountStatus'] = isset($data['accountStatus']) ? $data['accountStatus'] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show all the invalid properties with reasons.
|
||||
* @return array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
return $invalidProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate all the properties in the model
|
||||
* return true if all passed
|
||||
* @return bool True if all properties are valid
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets accountType
|
||||
* @return string
|
||||
*/
|
||||
public function getAccountType()
|
||||
{
|
||||
return $this->container['accountType'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets accountType
|
||||
* @param string $accountType 账户类型
|
||||
* @return $this
|
||||
*/
|
||||
public function setAccountType($accountType)
|
||||
{
|
||||
$this->container['accountType'] = $accountType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets createTime
|
||||
* @return string
|
||||
*/
|
||||
public function getCreateTime()
|
||||
{
|
||||
return $this->container['createTime'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets createTime
|
||||
* @param string $createTime 开户时间
|
||||
* @return $this
|
||||
*/
|
||||
public function setCreateTime($createTime)
|
||||
{
|
||||
$this->container['createTime'] = $createTime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets balance
|
||||
* @return float
|
||||
*/
|
||||
public function getBalance()
|
||||
{
|
||||
return $this->container['balance'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets balance
|
||||
* @param float $balance 余额
|
||||
* @return $this
|
||||
*/
|
||||
public function setBalance($balance)
|
||||
{
|
||||
$this->container['balance'] = $balance;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets accountStatus
|
||||
* @return string
|
||||
*/
|
||||
public function getAccountStatus()
|
||||
{
|
||||
return $this->container['accountStatus'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets accountStatus
|
||||
* @param string $accountStatus 账户状态
|
||||
* @return $this
|
||||
*/
|
||||
public function setAccountStatus($accountStatus)
|
||||
{
|
||||
$this->container['accountStatus'] = $accountStatus;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
* @param integer $offset Offset
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
* @param integer $offset Offset
|
||||
* @return mixed
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return isset($this->container[$offset]) ? $this->container[$offset] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets value based on offset.
|
||||
* @param integer $offset Offset
|
||||
* @param mixed $value Value to be set
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if (is_null($offset)) {
|
||||
$this->container[] = $value;
|
||||
} else {
|
||||
$this->container[$offset] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets offset.
|
||||
* @param integer $offset Offset
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,401 @@
|
||||
<?php
|
||||
/**
|
||||
* AccountinfosQueryQueryAccountInfoListRespDTOResult
|
||||
* PHP version 5
|
||||
* @author Swagger Codegen team
|
||||
* @package Yeepay\Yop\Sdk\
|
||||
* @category Class
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
|
||||
/**
|
||||
* 账户
|
||||
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
* Swagger Codegen version: 3.0.13
|
||||
*/
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use ArrayAccess;
|
||||
use Yeepay\Yop\Sdk\Model\ModelInterface;
|
||||
use Yeepay\Yop\Sdk\Utils\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* AccountinfosQueryQueryAccountInfoListRespDTOResult Class Doc Comment
|
||||
* @author Swagger Codegen team
|
||||
* @package Yeepay\Yop\Sdk\
|
||||
* @category Class
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
class AccountinfosQueryQueryAccountInfoListRespDTOResult implements ModelInterface, ArrayAccess
|
||||
{
|
||||
|
||||
const DISCRIMINATOR = null;
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
* @var string
|
||||
*/
|
||||
protected static $swaggerModelName = 'AccountinfosQueryQueryAccountInfoListRespDTOResult';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerTypes = [
|
||||
'returnCode' => 'string',
|
||||
'returnMsg' => 'string',
|
||||
'initiateMerchantNo' => 'string',
|
||||
'merchantNo' => 'string',
|
||||
'totalAccountBalance' => 'float',
|
||||
'accountInfoList' => '\Yeepay\Yop\Sdk\Service\Account\Model\AccountinfosQueryAccountDTOResult[]',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'returnCode' => null,
|
||||
'returnMsg' => null,
|
||||
'initiateMerchantNo' => null,
|
||||
'merchantNo' => null,
|
||||
'totalAccountBalance' => null,
|
||||
'accountInfoList' => null,
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
* @return array
|
||||
*/
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @return array
|
||||
*/
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'returnCode' => 'returnCode',
|
||||
'returnMsg' => 'returnMsg',
|
||||
'initiateMerchantNo' => 'initiateMerchantNo',
|
||||
'merchantNo' => 'merchantNo',
|
||||
'totalAccountBalance' => 'totalAccountBalance',
|
||||
'accountInfoList' => 'accountInfoList',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'returnCode' => 'setReturnCode',
|
||||
'returnMsg' => 'setReturnMsg',
|
||||
'initiateMerchantNo' => 'setInitiateMerchantNo',
|
||||
'merchantNo' => 'setMerchantNo',
|
||||
'totalAccountBalance' => 'setTotalAccountBalance',
|
||||
'accountInfoList' => 'setAccountInfoList',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'returnCode' => 'getReturnCode',
|
||||
'returnMsg' => 'getReturnMsg',
|
||||
'initiateMerchantNo' => 'getInitiateMerchantNo',
|
||||
'merchantNo' => 'getMerchantNo',
|
||||
'totalAccountBalance' => 'getTotalAccountBalance',
|
||||
'accountInfoList' => 'getAccountInfoList',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$swaggerModelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->container['returnCode'] = isset($data['returnCode']) ? $data['returnCode'] : null;
|
||||
$this->container['returnMsg'] = isset($data['returnMsg']) ? $data['returnMsg'] : null;
|
||||
$this->container['initiateMerchantNo'] = isset($data['initiateMerchantNo']) ? $data['initiateMerchantNo'] : null;
|
||||
$this->container['merchantNo'] = isset($data['merchantNo']) ? $data['merchantNo'] : null;
|
||||
$this->container['totalAccountBalance'] = isset($data['totalAccountBalance']) ? $data['totalAccountBalance'] : null;
|
||||
$this->container['accountInfoList'] = isset($data['accountInfoList']) ? $data['accountInfoList'] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show all the invalid properties with reasons.
|
||||
* @return array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
return $invalidProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate all the properties in the model
|
||||
* return true if all passed
|
||||
* @return bool True if all properties are valid
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets returnCode
|
||||
* @return string
|
||||
*/
|
||||
public function getReturnCode()
|
||||
{
|
||||
return $this->container['returnCode'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets returnCode
|
||||
* @param string $returnCode 返回码
|
||||
* @return $this
|
||||
*/
|
||||
public function setReturnCode($returnCode)
|
||||
{
|
||||
$this->container['returnCode'] = $returnCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets returnMsg
|
||||
* @return string
|
||||
*/
|
||||
public function getReturnMsg()
|
||||
{
|
||||
return $this->container['returnMsg'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets returnMsg
|
||||
* @param string $returnMsg 返回信息
|
||||
* @return $this
|
||||
*/
|
||||
public function setReturnMsg($returnMsg)
|
||||
{
|
||||
$this->container['returnMsg'] = $returnMsg;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets initiateMerchantNo
|
||||
* @return string
|
||||
*/
|
||||
public function getInitiateMerchantNo()
|
||||
{
|
||||
return $this->container['initiateMerchantNo'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets initiateMerchantNo
|
||||
* @param string $initiateMerchantNo 发起方商户编号
|
||||
* @return $this
|
||||
*/
|
||||
public function setInitiateMerchantNo($initiateMerchantNo)
|
||||
{
|
||||
$this->container['initiateMerchantNo'] = $initiateMerchantNo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets merchantNo
|
||||
* @return string
|
||||
*/
|
||||
public function getMerchantNo()
|
||||
{
|
||||
return $this->container['merchantNo'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets merchantNo
|
||||
* @param string $merchantNo 商户编号
|
||||
* @return $this
|
||||
*/
|
||||
public function setMerchantNo($merchantNo)
|
||||
{
|
||||
$this->container['merchantNo'] = $merchantNo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets totalAccountBalance
|
||||
* @return float
|
||||
*/
|
||||
public function getTotalAccountBalance()
|
||||
{
|
||||
return $this->container['totalAccountBalance'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets totalAccountBalance
|
||||
* @param float $totalAccountBalance 账户总余额
|
||||
* @return $this
|
||||
*/
|
||||
public function setTotalAccountBalance($totalAccountBalance)
|
||||
{
|
||||
$this->container['totalAccountBalance'] = $totalAccountBalance;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets accountInfoList
|
||||
* @return \Yeepay\Yop\Sdk\Service\Account\Model\AccountinfosQueryAccountDTOResult[]
|
||||
*/
|
||||
public function getAccountInfoList()
|
||||
{
|
||||
return $this->container['accountInfoList'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets accountInfoList
|
||||
* @param \Yeepay\Yop\Sdk\Service\Account\Model\AccountinfosQueryAccountDTOResult[] $accountInfoList 账户信息列表
|
||||
* @return $this
|
||||
*/
|
||||
public function setAccountInfoList($accountInfoList)
|
||||
{
|
||||
$this->container['accountInfoList'] = $accountInfoList;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
* @param integer $offset Offset
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
* @param integer $offset Offset
|
||||
* @return mixed
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return isset($this->container[$offset]) ? $this->container[$offset] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets value based on offset.
|
||||
* @param integer $offset Offset
|
||||
* @param mixed $value Value to be set
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if (is_null($offset)) {
|
||||
$this->container[] = $value;
|
||||
} else {
|
||||
$this->container[$offset] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets offset.
|
||||
* @param integer $offset Offset
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
41
lib/Service/Account/Model/AccountinfosQueryRequest.php
Normal file
41
lib/Service/Account/Model/AccountinfosQueryRequest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Model\BaseRequest;
|
||||
|
||||
class AccountinfosQueryRequest extends BaseRequest
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $merchantNo;
|
||||
|
||||
/**
|
||||
* Gets merchantNo
|
||||
* @return string
|
||||
*/
|
||||
public function getMerchantNo()
|
||||
{
|
||||
return $this->merchantNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets merchantNo
|
||||
* @param string $merchantNo
|
||||
* @return AccountinfosQueryRequest
|
||||
*/
|
||||
public function setMerchantNo($merchantNo)
|
||||
{
|
||||
$this->merchantNo = $merchantNo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function getOperationId()
|
||||
{
|
||||
return 'accountinfosQuery';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Http\Headers;
|
||||
use Yeepay\Yop\Sdk\Internal\DefaultRequest;
|
||||
use Yeepay\Yop\Sdk\Internal\Request;
|
||||
use Yeepay\Yop\Sdk\Model\Transform\RequestMarshaller;
|
||||
use Yeepay\Yop\Sdk\Utils\ObjectSerializer;
|
||||
use Yeepay\Yop\Sdk\Utils\UUIDUtils;
|
||||
|
||||
class AccountinfosQueryRequestMarshaller implements RequestMarshaller
|
||||
{
|
||||
|
||||
/**
|
||||
* @var AccountinfosQueryRequestMarshaller
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
public static function __init()
|
||||
{
|
||||
self::$instance = new AccountinfosQueryRequestMarshaller();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AccountinfosQueryRequestMarshaller
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $serviceName = 'Account';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $httpMethod = 'GET';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $resourcePath = '/rest/v1.0/account/accountinfos/query';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $contentType = 'application/x-www-form-urlencoded';
|
||||
|
||||
/**
|
||||
* @param AccountinfosQueryRequest $request
|
||||
* @return Request
|
||||
*/
|
||||
public function marshal($request)
|
||||
{
|
||||
$internalRequest = new DefaultRequest($this->serviceName);
|
||||
$internalRequest->setResourcePath($this->resourcePath);
|
||||
$internalRequest->setHttpMethod($this->httpMethod);
|
||||
if (!empty($request->getRequestConfig()) && !empty($request->getRequestConfig()->getCustomRequestHeaders())) {
|
||||
foreach ($request->getRequestConfig()->getCustomRequestHeaders() as $name => $value) {
|
||||
$internalRequest->addHeader($name, $value);
|
||||
}
|
||||
}
|
||||
if (!isset($internalRequest->getHeaders()[Headers::YOP_REQUEST_ID])) {
|
||||
$internalRequest->addHeader(Headers::YOP_REQUEST_ID, UUIDUtils::uuid());
|
||||
}
|
||||
$internalRequest->addHeader(Headers::CONTENT_TYPE, $this->contentType);
|
||||
$internalRequest->addParameter('merchantNo',ObjectSerializer::sanitizeForSerialization($request->getMerchantNo(), 'string'));
|
||||
return $internalRequest;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
AccountinfosQueryRequestMarshaller::__init();
|
||||
36
lib/Service/Account/Model/AccountinfosQueryResponse.php
Normal file
36
lib/Service/Account/Model/AccountinfosQueryResponse.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Model\BaseResponse;
|
||||
|
||||
class AccountinfosQueryResponse extends BaseResponse
|
||||
{
|
||||
|
||||
/**
|
||||
* @var AccountinfosQueryQueryAccountInfoListRespDTOResult
|
||||
*/
|
||||
private $result;
|
||||
|
||||
function getResultClass()
|
||||
{
|
||||
return '\Yeepay\Yop\Sdk\Service\Account\Model\AccountinfosQueryQueryAccountInfoListRespDTOResult';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccountinfosQueryQueryAccountInfoListRespDTOResult $result
|
||||
*/
|
||||
function setResult($result)
|
||||
{
|
||||
$this->result = $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AccountinfosQueryQueryAccountInfoListRespDTOResult
|
||||
*/
|
||||
function getResult()
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Model\Transform\BaseResponseUnMarshaller;
|
||||
|
||||
class AccountinfosQueryResponseUnMarshaller extends BaseResponseUnMarshaller
|
||||
{
|
||||
|
||||
/**
|
||||
* @var AccountinfosQueryResponseUnMarshaller
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
public static function __init()
|
||||
{
|
||||
self::$instance = new AccountinfosQueryResponseUnMarshaller();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AccountinfosQueryResponseUnMarshaller
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AccountinfosQueryResponse
|
||||
*/
|
||||
protected function getResponseInstance()
|
||||
{
|
||||
return new AccountinfosQueryResponse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
AccountinfosQueryResponseUnMarshaller::__init();
|
||||
93
lib/Service/Account/Model/AutoWithdrawRuleCancelRequest.php
Normal file
93
lib/Service/Account/Model/AutoWithdrawRuleCancelRequest.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Model\BaseRequest;
|
||||
|
||||
class AutoWithdrawRuleCancelRequest extends BaseRequest
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $parentMerchantNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $merchantNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $ruleId;
|
||||
|
||||
/**
|
||||
* Gets parentMerchantNo
|
||||
* @return string
|
||||
*/
|
||||
public function getParentMerchantNo()
|
||||
{
|
||||
return $this->parentMerchantNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets parentMerchantNo
|
||||
* @param string $parentMerchantNo
|
||||
* @return AutoWithdrawRuleCancelRequest
|
||||
*/
|
||||
public function setParentMerchantNo($parentMerchantNo)
|
||||
{
|
||||
$this->parentMerchantNo = $parentMerchantNo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets merchantNo
|
||||
* @return string
|
||||
*/
|
||||
public function getMerchantNo()
|
||||
{
|
||||
return $this->merchantNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets merchantNo
|
||||
* @param string $merchantNo
|
||||
* @return AutoWithdrawRuleCancelRequest
|
||||
*/
|
||||
public function setMerchantNo($merchantNo)
|
||||
{
|
||||
$this->merchantNo = $merchantNo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets ruleId
|
||||
* @return string
|
||||
*/
|
||||
public function getRuleId()
|
||||
{
|
||||
return $this->ruleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets ruleId
|
||||
* @param string $ruleId
|
||||
* @return AutoWithdrawRuleCancelRequest
|
||||
*/
|
||||
public function setRuleId($ruleId)
|
||||
{
|
||||
$this->ruleId = $ruleId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function getOperationId()
|
||||
{
|
||||
return 'autoWithdrawRuleCancel';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Http\Headers;
|
||||
use Yeepay\Yop\Sdk\Internal\DefaultRequest;
|
||||
use Yeepay\Yop\Sdk\Internal\Request;
|
||||
use Yeepay\Yop\Sdk\Model\Transform\RequestMarshaller;
|
||||
use Yeepay\Yop\Sdk\Utils\ObjectSerializer;
|
||||
use Yeepay\Yop\Sdk\Utils\UUIDUtils;
|
||||
|
||||
class AutoWithdrawRuleCancelRequestMarshaller implements RequestMarshaller
|
||||
{
|
||||
|
||||
/**
|
||||
* @var AutoWithdrawRuleCancelRequestMarshaller
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
public static function __init()
|
||||
{
|
||||
self::$instance = new AutoWithdrawRuleCancelRequestMarshaller();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AutoWithdrawRuleCancelRequestMarshaller
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $serviceName = 'Account';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $httpMethod = 'POST';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $resourcePath = '/rest/v1.0/account/auto-withdraw-rule/cancel';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $contentType = 'application/x-www-form-urlencoded';
|
||||
|
||||
/**
|
||||
* @param AutoWithdrawRuleCancelRequest $request
|
||||
* @return Request
|
||||
*/
|
||||
public function marshal($request)
|
||||
{
|
||||
$internalRequest = new DefaultRequest($this->serviceName);
|
||||
$internalRequest->setResourcePath($this->resourcePath);
|
||||
$internalRequest->setHttpMethod($this->httpMethod);
|
||||
if (!empty($request->getRequestConfig()) && !empty($request->getRequestConfig()->getCustomRequestHeaders())) {
|
||||
foreach ($request->getRequestConfig()->getCustomRequestHeaders() as $name => $value) {
|
||||
$internalRequest->addHeader($name, $value);
|
||||
}
|
||||
}
|
||||
if (!isset($internalRequest->getHeaders()[Headers::YOP_REQUEST_ID])) {
|
||||
$internalRequest->addHeader(Headers::YOP_REQUEST_ID, UUIDUtils::uuid());
|
||||
}
|
||||
if ($request->getParentMerchantNo() != null) {
|
||||
$internalRequest->addParameter('parentMerchantNo',
|
||||
ObjectSerializer::sanitizeForSerialization($request->getParentMerchantNo(), 'string'));
|
||||
}
|
||||
if ($request->getMerchantNo() != null) {
|
||||
$internalRequest->addParameter('merchantNo',
|
||||
ObjectSerializer::sanitizeForSerialization($request->getMerchantNo(), 'string'));
|
||||
}
|
||||
if ($request->getRuleId() != null) {
|
||||
$internalRequest->addParameter('ruleId',
|
||||
ObjectSerializer::sanitizeForSerialization($request->getRuleId(), 'string'));
|
||||
}
|
||||
$internalRequest->addHeader(Headers::CONTENT_TYPE, $this->contentType);
|
||||
|
||||
return $internalRequest;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
AutoWithdrawRuleCancelRequestMarshaller::__init();
|
||||
36
lib/Service/Account/Model/AutoWithdrawRuleCancelResponse.php
Normal file
36
lib/Service/Account/Model/AutoWithdrawRuleCancelResponse.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Model\BaseResponse;
|
||||
|
||||
class AutoWithdrawRuleCancelResponse extends BaseResponse
|
||||
{
|
||||
|
||||
/**
|
||||
* @var AutoWithdrawRuleCancelYopAutoWithdrawRuleCancelResponseDTOResult
|
||||
*/
|
||||
private $result;
|
||||
|
||||
function getResultClass()
|
||||
{
|
||||
return '\Yeepay\Yop\Sdk\Service\Account\Model\AutoWithdrawRuleCancelYopAutoWithdrawRuleCancelResponseDTOResult';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AutoWithdrawRuleCancelYopAutoWithdrawRuleCancelResponseDTOResult $result
|
||||
*/
|
||||
function setResult($result)
|
||||
{
|
||||
$this->result = $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AutoWithdrawRuleCancelYopAutoWithdrawRuleCancelResponseDTOResult
|
||||
*/
|
||||
function getResult()
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Model\Transform\BaseResponseUnMarshaller;
|
||||
|
||||
class AutoWithdrawRuleCancelResponseUnMarshaller extends BaseResponseUnMarshaller
|
||||
{
|
||||
|
||||
/**
|
||||
* @var AutoWithdrawRuleCancelResponseUnMarshaller
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
public static function __init()
|
||||
{
|
||||
self::$instance = new AutoWithdrawRuleCancelResponseUnMarshaller();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AutoWithdrawRuleCancelResponseUnMarshaller
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AutoWithdrawRuleCancelResponse
|
||||
*/
|
||||
protected function getResponseInstance()
|
||||
{
|
||||
return new AutoWithdrawRuleCancelResponse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
AutoWithdrawRuleCancelResponseUnMarshaller::__init();
|
||||
@@ -0,0 +1,293 @@
|
||||
<?php
|
||||
/**
|
||||
* AutoWithdrawRuleCancelYopAutoWithdrawRuleCancelResponseDTOResult
|
||||
* PHP version 5
|
||||
* @author Swagger Codegen team
|
||||
* @package Yeepay\Yop\Sdk\
|
||||
* @category Class
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
|
||||
/**
|
||||
* 账户
|
||||
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
* Swagger Codegen version: 3.0.13
|
||||
*/
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use ArrayAccess;
|
||||
use Yeepay\Yop\Sdk\Model\ModelInterface;
|
||||
use Yeepay\Yop\Sdk\Utils\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* AutoWithdrawRuleCancelYopAutoWithdrawRuleCancelResponseDTOResult Class Doc Comment
|
||||
* @author Swagger Codegen team
|
||||
* @package Yeepay\Yop\Sdk\
|
||||
* @category Class
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
class AutoWithdrawRuleCancelYopAutoWithdrawRuleCancelResponseDTOResult implements ModelInterface, ArrayAccess
|
||||
{
|
||||
|
||||
const DISCRIMINATOR = null;
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
* @var string
|
||||
*/
|
||||
protected static $swaggerModelName = 'AutoWithdrawRuleCancelYopAutoWithdrawRuleCancelResponseDTOResult';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerTypes = [
|
||||
'returnCode' => 'string',
|
||||
'returnMsg' => 'string',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'returnCode' => null,
|
||||
'returnMsg' => null,
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
* @return array
|
||||
*/
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @return array
|
||||
*/
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'returnCode' => 'returnCode',
|
||||
'returnMsg' => 'returnMsg',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'returnCode' => 'setReturnCode',
|
||||
'returnMsg' => 'setReturnMsg',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'returnCode' => 'getReturnCode',
|
||||
'returnMsg' => 'getReturnMsg',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$swaggerModelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->container['returnCode'] = isset($data['returnCode']) ? $data['returnCode'] : null;
|
||||
$this->container['returnMsg'] = isset($data['returnMsg']) ? $data['returnMsg'] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show all the invalid properties with reasons.
|
||||
* @return array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
return $invalidProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate all the properties in the model
|
||||
* return true if all passed
|
||||
* @return bool True if all properties are valid
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets returnCode
|
||||
* @return string
|
||||
*/
|
||||
public function getReturnCode()
|
||||
{
|
||||
return $this->container['returnCode'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets returnCode
|
||||
* @param string $returnCode 系统返回码
|
||||
* @return $this
|
||||
*/
|
||||
public function setReturnCode($returnCode)
|
||||
{
|
||||
$this->container['returnCode'] = $returnCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets returnMsg
|
||||
* @return string
|
||||
*/
|
||||
public function getReturnMsg()
|
||||
{
|
||||
return $this->container['returnMsg'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets returnMsg
|
||||
* @param string $returnMsg 系统返回描述
|
||||
* @return $this
|
||||
*/
|
||||
public function setReturnMsg($returnMsg)
|
||||
{
|
||||
$this->container['returnMsg'] = $returnMsg;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
* @param integer $offset Offset
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
* @param integer $offset Offset
|
||||
* @return mixed
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return isset($this->container[$offset]) ? $this->container[$offset] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets value based on offset.
|
||||
* @param integer $offset Offset
|
||||
* @param mixed $value Value to be set
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if (is_null($offset)) {
|
||||
$this->container[] = $value;
|
||||
} else {
|
||||
$this->container[$offset] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets offset.
|
||||
* @param integer $offset Offset
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,510 @@
|
||||
<?php
|
||||
/**
|
||||
* AutoWithdrawRuleQueryAutoWithdrawRuleDTOResult
|
||||
* PHP version 5
|
||||
* @author Swagger Codegen team
|
||||
* @package Yeepay\Yop\Sdk\
|
||||
* @category Class
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
|
||||
/**
|
||||
* 账户
|
||||
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
* Swagger Codegen version: 3.0.13
|
||||
*/
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use ArrayAccess;
|
||||
use Yeepay\Yop\Sdk\Model\ModelInterface;
|
||||
use Yeepay\Yop\Sdk\Utils\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* AutoWithdrawRuleQueryAutoWithdrawRuleDTOResult Class Doc Comment
|
||||
* @author Swagger Codegen team
|
||||
* @package Yeepay\Yop\Sdk\
|
||||
* @category Class
|
||||
* @description
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
class AutoWithdrawRuleQueryAutoWithdrawRuleDTOResult implements ModelInterface, ArrayAccess
|
||||
{
|
||||
|
||||
const DISCRIMINATOR = null;
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
* @var string
|
||||
*/
|
||||
protected static $swaggerModelName = 'AutoWithdrawRuleQueryAutoWithdrawRuleDTOResult';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerTypes = [
|
||||
'ruleId' => 'string',
|
||||
'createTime' => 'string',
|
||||
'merchantNo' => 'string',
|
||||
'status' => 'string',
|
||||
'receiveType' => 'string',
|
||||
'bindId' => 'string',
|
||||
'bankAccountNo' => 'string',
|
||||
'triggerTime' => 'string',
|
||||
'remainAmount' => 'float',
|
||||
'remark' => 'string',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'ruleId' => null,
|
||||
'createTime' => 'date-time',
|
||||
'merchantNo' => null,
|
||||
'status' => null,
|
||||
'receiveType' => null,
|
||||
'bindId' => null,
|
||||
'bankAccountNo' => null,
|
||||
'triggerTime' => null,
|
||||
'remainAmount' => null,
|
||||
'remark' => null,
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
* @return array
|
||||
*/
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @return array
|
||||
*/
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'ruleId' => 'ruleId',
|
||||
'createTime' => 'createTime',
|
||||
'merchantNo' => 'merchantNo',
|
||||
'status' => 'status',
|
||||
'receiveType' => 'receiveType',
|
||||
'bindId' => 'bindId',
|
||||
'bankAccountNo' => 'bankAccountNo',
|
||||
'triggerTime' => 'triggerTime',
|
||||
'remainAmount' => 'remainAmount',
|
||||
'remark' => 'remark',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'ruleId' => 'setRuleId',
|
||||
'createTime' => 'setCreateTime',
|
||||
'merchantNo' => 'setMerchantNo',
|
||||
'status' => 'setStatus',
|
||||
'receiveType' => 'setReceiveType',
|
||||
'bindId' => 'setBindId',
|
||||
'bankAccountNo' => 'setBankAccountNo',
|
||||
'triggerTime' => 'setTriggerTime',
|
||||
'remainAmount' => 'setRemainAmount',
|
||||
'remark' => 'setRemark',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'ruleId' => 'getRuleId',
|
||||
'createTime' => 'getCreateTime',
|
||||
'merchantNo' => 'getMerchantNo',
|
||||
'status' => 'getStatus',
|
||||
'receiveType' => 'getReceiveType',
|
||||
'bindId' => 'getBindId',
|
||||
'bankAccountNo' => 'getBankAccountNo',
|
||||
'triggerTime' => 'getTriggerTime',
|
||||
'remainAmount' => 'getRemainAmount',
|
||||
'remark' => 'getRemark',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$swaggerModelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->container['ruleId'] = isset($data['ruleId']) ? $data['ruleId'] : null;
|
||||
$this->container['createTime'] = isset($data['createTime']) ? $data['createTime'] : null;
|
||||
$this->container['merchantNo'] = isset($data['merchantNo']) ? $data['merchantNo'] : null;
|
||||
$this->container['status'] = isset($data['status']) ? $data['status'] : null;
|
||||
$this->container['receiveType'] = isset($data['receiveType']) ? $data['receiveType'] : null;
|
||||
$this->container['bindId'] = isset($data['bindId']) ? $data['bindId'] : null;
|
||||
$this->container['bankAccountNo'] = isset($data['bankAccountNo']) ? $data['bankAccountNo'] : null;
|
||||
$this->container['triggerTime'] = isset($data['triggerTime']) ? $data['triggerTime'] : null;
|
||||
$this->container['remainAmount'] = isset($data['remainAmount']) ? $data['remainAmount'] : null;
|
||||
$this->container['remark'] = isset($data['remark']) ? $data['remark'] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show all the invalid properties with reasons.
|
||||
* @return array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
return $invalidProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate all the properties in the model
|
||||
* return true if all passed
|
||||
* @return bool True if all properties are valid
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets ruleId
|
||||
* @return string
|
||||
*/
|
||||
public function getRuleId()
|
||||
{
|
||||
return $this->container['ruleId'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets ruleId
|
||||
* @param string $ruleId 规则id
|
||||
* @return $this
|
||||
*/
|
||||
public function setRuleId($ruleId)
|
||||
{
|
||||
$this->container['ruleId'] = $ruleId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets createTime
|
||||
* @return string
|
||||
*/
|
||||
public function getCreateTime()
|
||||
{
|
||||
return $this->container['createTime'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets createTime
|
||||
* @param string $createTime 规则创建时间
|
||||
* @return $this
|
||||
*/
|
||||
public function setCreateTime($createTime)
|
||||
{
|
||||
$this->container['createTime'] = $createTime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets merchantNo
|
||||
* @return string
|
||||
*/
|
||||
public function getMerchantNo()
|
||||
{
|
||||
return $this->container['merchantNo'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets merchantNo
|
||||
* @param string $merchantNo 交易主体商编
|
||||
* @return $this
|
||||
*/
|
||||
public function setMerchantNo($merchantNo)
|
||||
{
|
||||
$this->container['merchantNo'] = $merchantNo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets status
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->container['status'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets status
|
||||
* @param string $status 规则状态
|
||||
* @return $this
|
||||
*/
|
||||
public function setStatus($status)
|
||||
{
|
||||
$this->container['status'] = $status;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets receiveType
|
||||
* @return string
|
||||
*/
|
||||
public function getReceiveType()
|
||||
{
|
||||
return $this->container['receiveType'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets receiveType
|
||||
* @param string $receiveType 提现到账类型
|
||||
* @return $this
|
||||
*/
|
||||
public function setReceiveType($receiveType)
|
||||
{
|
||||
$this->container['receiveType'] = $receiveType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets bindId
|
||||
* @return string
|
||||
*/
|
||||
public function getBindId()
|
||||
{
|
||||
return $this->container['bindId'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets bindId
|
||||
* @param string $bindId 提现卡id
|
||||
* @return $this
|
||||
*/
|
||||
public function setBindId($bindId)
|
||||
{
|
||||
$this->container['bindId'] = $bindId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets bankAccountNo
|
||||
* @return string
|
||||
*/
|
||||
public function getBankAccountNo()
|
||||
{
|
||||
return $this->container['bankAccountNo'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets bankAccountNo
|
||||
* @param string $bankAccountNo 提现卡卡号
|
||||
* @return $this
|
||||
*/
|
||||
public function setBankAccountNo($bankAccountNo)
|
||||
{
|
||||
$this->container['bankAccountNo'] = $bankAccountNo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets triggerTime
|
||||
* @return string
|
||||
*/
|
||||
public function getTriggerTime()
|
||||
{
|
||||
return $this->container['triggerTime'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets triggerTime
|
||||
* @param string $triggerTime 触发时间
|
||||
* @return $this
|
||||
*/
|
||||
public function setTriggerTime($triggerTime)
|
||||
{
|
||||
$this->container['triggerTime'] = $triggerTime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets remainAmount
|
||||
* @return float
|
||||
*/
|
||||
public function getRemainAmount()
|
||||
{
|
||||
return $this->container['remainAmount'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets remainAmount
|
||||
* @param float $remainAmount 保留金额
|
||||
* @return $this
|
||||
*/
|
||||
public function setRemainAmount($remainAmount)
|
||||
{
|
||||
$this->container['remainAmount'] = $remainAmount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets remark
|
||||
* @return string
|
||||
*/
|
||||
public function getRemark()
|
||||
{
|
||||
return $this->container['remark'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets remark
|
||||
* @param string $remark 银行附言
|
||||
* @return $this
|
||||
*/
|
||||
public function setRemark($remark)
|
||||
{
|
||||
$this->container['remark'] = $remark;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
* @param integer $offset Offset
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
* @param integer $offset Offset
|
||||
* @return mixed
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return isset($this->container[$offset]) ? $this->container[$offset] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets value based on offset.
|
||||
* @param integer $offset Offset
|
||||
* @param mixed $value Value to be set
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if (is_null($offset)) {
|
||||
$this->container[] = $value;
|
||||
} else {
|
||||
$this->container[$offset] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets offset.
|
||||
* @param integer $offset Offset
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
67
lib/Service/Account/Model/AutoWithdrawRuleQueryRequest.php
Normal file
67
lib/Service/Account/Model/AutoWithdrawRuleQueryRequest.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Model\BaseRequest;
|
||||
|
||||
class AutoWithdrawRuleQueryRequest extends BaseRequest
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $parentMerchantNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $merchantNo;
|
||||
|
||||
/**
|
||||
* Gets parentMerchantNo
|
||||
* @return string
|
||||
*/
|
||||
public function getParentMerchantNo()
|
||||
{
|
||||
return $this->parentMerchantNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets parentMerchantNo
|
||||
* @param string $parentMerchantNo
|
||||
* @return AutoWithdrawRuleQueryRequest
|
||||
*/
|
||||
public function setParentMerchantNo($parentMerchantNo)
|
||||
{
|
||||
$this->parentMerchantNo = $parentMerchantNo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets merchantNo
|
||||
* @return string
|
||||
*/
|
||||
public function getMerchantNo()
|
||||
{
|
||||
return $this->merchantNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets merchantNo
|
||||
* @param string $merchantNo
|
||||
* @return AutoWithdrawRuleQueryRequest
|
||||
*/
|
||||
public function setMerchantNo($merchantNo)
|
||||
{
|
||||
$this->merchantNo = $merchantNo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function getOperationId()
|
||||
{
|
||||
return 'autoWithdrawRuleQuery';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Http\Headers;
|
||||
use Yeepay\Yop\Sdk\Internal\DefaultRequest;
|
||||
use Yeepay\Yop\Sdk\Internal\Request;
|
||||
use Yeepay\Yop\Sdk\Model\Transform\RequestMarshaller;
|
||||
use Yeepay\Yop\Sdk\Utils\ObjectSerializer;
|
||||
use Yeepay\Yop\Sdk\Utils\UUIDUtils;
|
||||
|
||||
class AutoWithdrawRuleQueryRequestMarshaller implements RequestMarshaller
|
||||
{
|
||||
|
||||
/**
|
||||
* @var AutoWithdrawRuleQueryRequestMarshaller
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
public static function __init()
|
||||
{
|
||||
self::$instance = new AutoWithdrawRuleQueryRequestMarshaller();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AutoWithdrawRuleQueryRequestMarshaller
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $serviceName = 'Account';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $httpMethod = 'GET';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $resourcePath = '/rest/v1.0/account/auto-withdraw-rule/query';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $contentType = 'application/x-www-form-urlencoded';
|
||||
|
||||
/**
|
||||
* @param AutoWithdrawRuleQueryRequest $request
|
||||
* @return Request
|
||||
*/
|
||||
public function marshal($request)
|
||||
{
|
||||
$internalRequest = new DefaultRequest($this->serviceName);
|
||||
$internalRequest->setResourcePath($this->resourcePath);
|
||||
$internalRequest->setHttpMethod($this->httpMethod);
|
||||
if (!empty($request->getRequestConfig()) && !empty($request->getRequestConfig()->getCustomRequestHeaders())) {
|
||||
foreach ($request->getRequestConfig()->getCustomRequestHeaders() as $name => $value) {
|
||||
$internalRequest->addHeader($name, $value);
|
||||
}
|
||||
}
|
||||
if (!isset($internalRequest->getHeaders()[Headers::YOP_REQUEST_ID])) {
|
||||
$internalRequest->addHeader(Headers::YOP_REQUEST_ID, UUIDUtils::uuid());
|
||||
}
|
||||
|
||||
$internalRequest->addHeader(Headers::CONTENT_TYPE, $this->contentType);
|
||||
$internalRequest->addParameter('parentMerchantNo',ObjectSerializer::sanitizeForSerialization($request->getParentMerchantNo(), 'string'));
|
||||
$internalRequest->addParameter('merchantNo',ObjectSerializer::sanitizeForSerialization($request->getMerchantNo(), 'string'));
|
||||
return $internalRequest;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
AutoWithdrawRuleQueryRequestMarshaller::__init();
|
||||
36
lib/Service/Account/Model/AutoWithdrawRuleQueryResponse.php
Normal file
36
lib/Service/Account/Model/AutoWithdrawRuleQueryResponse.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Model\BaseResponse;
|
||||
|
||||
class AutoWithdrawRuleQueryResponse extends BaseResponse
|
||||
{
|
||||
|
||||
/**
|
||||
* @var AutoWithdrawRuleQueryYopAutoWithdrawRuleQueryResponseDTOResult
|
||||
*/
|
||||
private $result;
|
||||
|
||||
function getResultClass()
|
||||
{
|
||||
return '\Yeepay\Yop\Sdk\Service\Account\Model\AutoWithdrawRuleQueryYopAutoWithdrawRuleQueryResponseDTOResult';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AutoWithdrawRuleQueryYopAutoWithdrawRuleQueryResponseDTOResult $result
|
||||
*/
|
||||
function setResult($result)
|
||||
{
|
||||
$this->result = $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AutoWithdrawRuleQueryYopAutoWithdrawRuleQueryResponseDTOResult
|
||||
*/
|
||||
function getResult()
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Model\Transform\BaseResponseUnMarshaller;
|
||||
|
||||
class AutoWithdrawRuleQueryResponseUnMarshaller extends BaseResponseUnMarshaller
|
||||
{
|
||||
|
||||
/**
|
||||
* @var AutoWithdrawRuleQueryResponseUnMarshaller
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
public static function __init()
|
||||
{
|
||||
self::$instance = new AutoWithdrawRuleQueryResponseUnMarshaller();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AutoWithdrawRuleQueryResponseUnMarshaller
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AutoWithdrawRuleQueryResponse
|
||||
*/
|
||||
protected function getResponseInstance()
|
||||
{
|
||||
return new AutoWithdrawRuleQueryResponse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
AutoWithdrawRuleQueryResponseUnMarshaller::__init();
|
||||
@@ -0,0 +1,320 @@
|
||||
<?php
|
||||
/**
|
||||
* AutoWithdrawRuleQueryYopAutoWithdrawRuleQueryResponseDTOResult
|
||||
* PHP version 5
|
||||
* @author Swagger Codegen team
|
||||
* @package Yeepay\Yop\Sdk\
|
||||
* @category Class
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
|
||||
/**
|
||||
* 账户
|
||||
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
* Swagger Codegen version: 3.0.13
|
||||
*/
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use ArrayAccess;
|
||||
use Yeepay\Yop\Sdk\Model\ModelInterface;
|
||||
use Yeepay\Yop\Sdk\Utils\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* AutoWithdrawRuleQueryYopAutoWithdrawRuleQueryResponseDTOResult Class Doc Comment
|
||||
* @author Swagger Codegen team
|
||||
* @package Yeepay\Yop\Sdk\
|
||||
* @category Class
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
class AutoWithdrawRuleQueryYopAutoWithdrawRuleQueryResponseDTOResult implements ModelInterface, ArrayAccess
|
||||
{
|
||||
|
||||
const DISCRIMINATOR = null;
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
* @var string
|
||||
*/
|
||||
protected static $swaggerModelName = 'AutoWithdrawRuleQueryYopAutoWithdrawRuleQueryResponseDTOResult';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerTypes = [
|
||||
'returnCode' => 'string',
|
||||
'returnMsg' => 'string',
|
||||
'rules' => '\Yeepay\Yop\Sdk\Service\Account\Model\AutoWithdrawRuleQueryAutoWithdrawRuleDTOResult[]',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'returnCode' => null,
|
||||
'returnMsg' => null,
|
||||
'rules' => null,
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
* @return array
|
||||
*/
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @return array
|
||||
*/
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'returnCode' => 'returnCode',
|
||||
'returnMsg' => 'returnMsg',
|
||||
'rules' => 'rules',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'returnCode' => 'setReturnCode',
|
||||
'returnMsg' => 'setReturnMsg',
|
||||
'rules' => 'setRules',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'returnCode' => 'getReturnCode',
|
||||
'returnMsg' => 'getReturnMsg',
|
||||
'rules' => 'getRules',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$swaggerModelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->container['returnCode'] = isset($data['returnCode']) ? $data['returnCode'] : null;
|
||||
$this->container['returnMsg'] = isset($data['returnMsg']) ? $data['returnMsg'] : null;
|
||||
$this->container['rules'] = isset($data['rules']) ? $data['rules'] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show all the invalid properties with reasons.
|
||||
* @return array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
return $invalidProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate all the properties in the model
|
||||
* return true if all passed
|
||||
* @return bool True if all properties are valid
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets returnCode
|
||||
* @return string
|
||||
*/
|
||||
public function getReturnCode()
|
||||
{
|
||||
return $this->container['returnCode'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets returnCode
|
||||
* @param string $returnCode 系统返回码
|
||||
* @return $this
|
||||
*/
|
||||
public function setReturnCode($returnCode)
|
||||
{
|
||||
$this->container['returnCode'] = $returnCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets returnMsg
|
||||
* @return string
|
||||
*/
|
||||
public function getReturnMsg()
|
||||
{
|
||||
return $this->container['returnMsg'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets returnMsg
|
||||
* @param string $returnMsg 系统返回描述
|
||||
* @return $this
|
||||
*/
|
||||
public function setReturnMsg($returnMsg)
|
||||
{
|
||||
$this->container['returnMsg'] = $returnMsg;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets rules
|
||||
* @return \Yeepay\Yop\Sdk\Service\Account\Model\AutoWithdrawRuleQueryAutoWithdrawRuleDTOResult[]
|
||||
*/
|
||||
public function getRules()
|
||||
{
|
||||
return $this->container['rules'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets rules
|
||||
* @param \Yeepay\Yop\Sdk\Service\Account\Model\AutoWithdrawRuleQueryAutoWithdrawRuleDTOResult[] $rules 规则列表
|
||||
* @return $this
|
||||
*/
|
||||
public function setRules($rules)
|
||||
{
|
||||
$this->container['rules'] = $rules;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
* @param integer $offset Offset
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
* @param integer $offset Offset
|
||||
* @return mixed
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return isset($this->container[$offset]) ? $this->container[$offset] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets value based on offset.
|
||||
* @param integer $offset Offset
|
||||
* @param mixed $value Value to be set
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if (is_null($offset)) {
|
||||
$this->container[] = $value;
|
||||
} else {
|
||||
$this->container[$offset] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets offset.
|
||||
* @param integer $offset Offset
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
223
lib/Service/Account/Model/AutoWithdrawRuleSetRequest.php
Normal file
223
lib/Service/Account/Model/AutoWithdrawRuleSetRequest.php
Normal file
@@ -0,0 +1,223 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Model\BaseRequest;
|
||||
|
||||
class AutoWithdrawRuleSetRequest extends BaseRequest
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $parentMerchantNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $merchantNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $bindId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $bankAccountNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $receiveType;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $triggerTime;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $remainAmount;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $remark;
|
||||
|
||||
/**
|
||||
* Gets parentMerchantNo
|
||||
* @return string
|
||||
*/
|
||||
public function getParentMerchantNo()
|
||||
{
|
||||
return $this->parentMerchantNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets parentMerchantNo
|
||||
* @param string $parentMerchantNo
|
||||
* @return AutoWithdrawRuleSetRequest
|
||||
*/
|
||||
public function setParentMerchantNo($parentMerchantNo)
|
||||
{
|
||||
$this->parentMerchantNo = $parentMerchantNo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets merchantNo
|
||||
* @return string
|
||||
*/
|
||||
public function getMerchantNo()
|
||||
{
|
||||
return $this->merchantNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets merchantNo
|
||||
* @param string $merchantNo
|
||||
* @return AutoWithdrawRuleSetRequest
|
||||
*/
|
||||
public function setMerchantNo($merchantNo)
|
||||
{
|
||||
$this->merchantNo = $merchantNo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets bindId
|
||||
* @return string
|
||||
*/
|
||||
public function getBindId()
|
||||
{
|
||||
return $this->bindId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets bindId
|
||||
* @param string $bindId
|
||||
* @return AutoWithdrawRuleSetRequest
|
||||
*/
|
||||
public function setBindId($bindId)
|
||||
{
|
||||
$this->bindId = $bindId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets bankAccountNo
|
||||
* @return string
|
||||
*/
|
||||
public function getBankAccountNo()
|
||||
{
|
||||
return $this->bankAccountNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets bankAccountNo
|
||||
* @param string $bankAccountNo
|
||||
* @return AutoWithdrawRuleSetRequest
|
||||
*/
|
||||
public function setBankAccountNo($bankAccountNo)
|
||||
{
|
||||
$this->bankAccountNo = $bankAccountNo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets receiveType
|
||||
* @return string
|
||||
*/
|
||||
public function getReceiveType()
|
||||
{
|
||||
return $this->receiveType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets receiveType
|
||||
* @param string $receiveType
|
||||
* @return AutoWithdrawRuleSetRequest
|
||||
*/
|
||||
public function setReceiveType($receiveType)
|
||||
{
|
||||
$this->receiveType = $receiveType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets triggerTime
|
||||
* @return string
|
||||
*/
|
||||
public function getTriggerTime()
|
||||
{
|
||||
return $this->triggerTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets triggerTime
|
||||
* @param string $triggerTime
|
||||
* @return AutoWithdrawRuleSetRequest
|
||||
*/
|
||||
public function setTriggerTime($triggerTime)
|
||||
{
|
||||
$this->triggerTime = $triggerTime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets remainAmount
|
||||
* @return float
|
||||
*/
|
||||
public function getRemainAmount()
|
||||
{
|
||||
return $this->remainAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets remainAmount
|
||||
* @param float $remainAmount
|
||||
* @return AutoWithdrawRuleSetRequest
|
||||
*/
|
||||
public function setRemainAmount($remainAmount)
|
||||
{
|
||||
$this->remainAmount = $remainAmount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets remark
|
||||
* @return string
|
||||
*/
|
||||
public function getRemark()
|
||||
{
|
||||
return $this->remark;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets remark
|
||||
* @param string $remark
|
||||
* @return AutoWithdrawRuleSetRequest
|
||||
*/
|
||||
public function setRemark($remark)
|
||||
{
|
||||
$this->remark = $remark;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function getOperationId()
|
||||
{
|
||||
return 'autoWithdrawRuleSet';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Http\Headers;
|
||||
use Yeepay\Yop\Sdk\Internal\DefaultRequest;
|
||||
use Yeepay\Yop\Sdk\Internal\Request;
|
||||
use Yeepay\Yop\Sdk\Model\Transform\RequestMarshaller;
|
||||
use Yeepay\Yop\Sdk\Utils\ObjectSerializer;
|
||||
use Yeepay\Yop\Sdk\Utils\UUIDUtils;
|
||||
|
||||
class AutoWithdrawRuleSetRequestMarshaller implements RequestMarshaller
|
||||
{
|
||||
|
||||
/**
|
||||
* @var AutoWithdrawRuleSetRequestMarshaller
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
public static function __init()
|
||||
{
|
||||
self::$instance = new AutoWithdrawRuleSetRequestMarshaller();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AutoWithdrawRuleSetRequestMarshaller
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $serviceName = 'Account';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $httpMethod = 'POST';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $resourcePath = '/rest/v1.0/account/auto-withdraw-rule/set';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $contentType = 'application/x-www-form-urlencoded';
|
||||
|
||||
/**
|
||||
* @param AutoWithdrawRuleSetRequest $request
|
||||
* @return Request
|
||||
*/
|
||||
public function marshal($request)
|
||||
{
|
||||
$internalRequest = new DefaultRequest($this->serviceName);
|
||||
$internalRequest->setResourcePath($this->resourcePath);
|
||||
$internalRequest->setHttpMethod($this->httpMethod);
|
||||
if (!empty($request->getRequestConfig()) && !empty($request->getRequestConfig()->getCustomRequestHeaders())) {
|
||||
foreach ($request->getRequestConfig()->getCustomRequestHeaders() as $name => $value) {
|
||||
$internalRequest->addHeader($name, $value);
|
||||
}
|
||||
}
|
||||
if (!isset($internalRequest->getHeaders()[Headers::YOP_REQUEST_ID])) {
|
||||
$internalRequest->addHeader(Headers::YOP_REQUEST_ID, UUIDUtils::uuid());
|
||||
}
|
||||
if ($request->getParentMerchantNo() != null) {
|
||||
$internalRequest->addParameter('parentMerchantNo',
|
||||
ObjectSerializer::sanitizeForSerialization($request->getParentMerchantNo(), 'string'));
|
||||
}
|
||||
if ($request->getMerchantNo() != null) {
|
||||
$internalRequest->addParameter('merchantNo',
|
||||
ObjectSerializer::sanitizeForSerialization($request->getMerchantNo(), 'string'));
|
||||
}
|
||||
if ($request->getBindId() != null) {
|
||||
$internalRequest->addParameter('bindId',
|
||||
ObjectSerializer::sanitizeForSerialization($request->getBindId(), 'string'));
|
||||
}
|
||||
if ($request->getBankAccountNo() != null) {
|
||||
$internalRequest->addParameter('bankAccountNo',
|
||||
ObjectSerializer::sanitizeForSerialization($request->getBankAccountNo(), 'string'));
|
||||
}
|
||||
if ($request->getReceiveType() != null) {
|
||||
$internalRequest->addParameter('receiveType',
|
||||
ObjectSerializer::sanitizeForSerialization($request->getReceiveType(), 'string'));
|
||||
}
|
||||
if ($request->getTriggerTime() != null) {
|
||||
$internalRequest->addParameter('triggerTime',
|
||||
ObjectSerializer::sanitizeForSerialization($request->getTriggerTime(), 'string'));
|
||||
}
|
||||
if ($request->getRemainAmount() != null) {
|
||||
$internalRequest->addParameter('remainAmount',
|
||||
ObjectSerializer::sanitizeForSerialization($request->getRemainAmount(), 'float'));
|
||||
}
|
||||
if ($request->getRemark() != null) {
|
||||
$internalRequest->addParameter('remark',
|
||||
ObjectSerializer::sanitizeForSerialization($request->getRemark(), 'string'));
|
||||
}
|
||||
$internalRequest->addHeader(Headers::CONTENT_TYPE, $this->contentType);
|
||||
|
||||
return $internalRequest;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
AutoWithdrawRuleSetRequestMarshaller::__init();
|
||||
36
lib/Service/Account/Model/AutoWithdrawRuleSetResponse.php
Normal file
36
lib/Service/Account/Model/AutoWithdrawRuleSetResponse.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Model\BaseResponse;
|
||||
|
||||
class AutoWithdrawRuleSetResponse extends BaseResponse
|
||||
{
|
||||
|
||||
/**
|
||||
* @var AutoWithdrawRuleSetYopAutoWithdrawRuleSetResponseDTOResult
|
||||
*/
|
||||
private $result;
|
||||
|
||||
function getResultClass()
|
||||
{
|
||||
return '\Yeepay\Yop\Sdk\Service\Account\Model\AutoWithdrawRuleSetYopAutoWithdrawRuleSetResponseDTOResult';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AutoWithdrawRuleSetYopAutoWithdrawRuleSetResponseDTOResult $result
|
||||
*/
|
||||
function setResult($result)
|
||||
{
|
||||
$this->result = $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AutoWithdrawRuleSetYopAutoWithdrawRuleSetResponseDTOResult
|
||||
*/
|
||||
function getResult()
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Model\Transform\BaseResponseUnMarshaller;
|
||||
|
||||
class AutoWithdrawRuleSetResponseUnMarshaller extends BaseResponseUnMarshaller
|
||||
{
|
||||
|
||||
/**
|
||||
* @var AutoWithdrawRuleSetResponseUnMarshaller
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
public static function __init()
|
||||
{
|
||||
self::$instance = new AutoWithdrawRuleSetResponseUnMarshaller();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AutoWithdrawRuleSetResponseUnMarshaller
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AutoWithdrawRuleSetResponse
|
||||
*/
|
||||
protected function getResponseInstance()
|
||||
{
|
||||
return new AutoWithdrawRuleSetResponse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
AutoWithdrawRuleSetResponseUnMarshaller::__init();
|
||||
@@ -0,0 +1,320 @@
|
||||
<?php
|
||||
/**
|
||||
* AutoWithdrawRuleSetYopAutoWithdrawRuleSetResponseDTOResult
|
||||
* PHP version 5
|
||||
* @author Swagger Codegen team
|
||||
* @package Yeepay\Yop\Sdk\
|
||||
* @category Class
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
|
||||
/**
|
||||
* 账户
|
||||
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
* Swagger Codegen version: 3.0.13
|
||||
*/
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use ArrayAccess;
|
||||
use Yeepay\Yop\Sdk\Model\ModelInterface;
|
||||
use Yeepay\Yop\Sdk\Utils\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* AutoWithdrawRuleSetYopAutoWithdrawRuleSetResponseDTOResult Class Doc Comment
|
||||
* @author Swagger Codegen team
|
||||
* @package Yeepay\Yop\Sdk\
|
||||
* @category Class
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
class AutoWithdrawRuleSetYopAutoWithdrawRuleSetResponseDTOResult implements ModelInterface, ArrayAccess
|
||||
{
|
||||
|
||||
const DISCRIMINATOR = null;
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
* @var string
|
||||
*/
|
||||
protected static $swaggerModelName = 'AutoWithdrawRuleSetYopAutoWithdrawRuleSetResponseDTOResult';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerTypes = [
|
||||
'returnCode' => 'string',
|
||||
'returnMsg' => 'string',
|
||||
'ruleId' => 'string',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'returnCode' => null,
|
||||
'returnMsg' => null,
|
||||
'ruleId' => null,
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
* @return array
|
||||
*/
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @return array
|
||||
*/
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'returnCode' => 'returnCode',
|
||||
'returnMsg' => 'returnMsg',
|
||||
'ruleId' => 'ruleId',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'returnCode' => 'setReturnCode',
|
||||
'returnMsg' => 'setReturnMsg',
|
||||
'ruleId' => 'setRuleId',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'returnCode' => 'getReturnCode',
|
||||
'returnMsg' => 'getReturnMsg',
|
||||
'ruleId' => 'getRuleId',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$swaggerModelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->container['returnCode'] = isset($data['returnCode']) ? $data['returnCode'] : null;
|
||||
$this->container['returnMsg'] = isset($data['returnMsg']) ? $data['returnMsg'] : null;
|
||||
$this->container['ruleId'] = isset($data['ruleId']) ? $data['ruleId'] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show all the invalid properties with reasons.
|
||||
* @return array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
return $invalidProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate all the properties in the model
|
||||
* return true if all passed
|
||||
* @return bool True if all properties are valid
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets returnCode
|
||||
* @return string
|
||||
*/
|
||||
public function getReturnCode()
|
||||
{
|
||||
return $this->container['returnCode'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets returnCode
|
||||
* @param string $returnCode 返回码
|
||||
* @return $this
|
||||
*/
|
||||
public function setReturnCode($returnCode)
|
||||
{
|
||||
$this->container['returnCode'] = $returnCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets returnMsg
|
||||
* @return string
|
||||
*/
|
||||
public function getReturnMsg()
|
||||
{
|
||||
return $this->container['returnMsg'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets returnMsg
|
||||
* @param string $returnMsg 返回描述
|
||||
* @return $this
|
||||
*/
|
||||
public function setReturnMsg($returnMsg)
|
||||
{
|
||||
$this->container['returnMsg'] = $returnMsg;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets ruleId
|
||||
* @return string
|
||||
*/
|
||||
public function getRuleId()
|
||||
{
|
||||
return $this->container['ruleId'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets ruleId
|
||||
* @param string $ruleId 规则id
|
||||
* @return $this
|
||||
*/
|
||||
public function setRuleId($ruleId)
|
||||
{
|
||||
$this->container['ruleId'] = $ruleId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
* @param integer $offset Offset
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
* @param integer $offset Offset
|
||||
* @return mixed
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return isset($this->container[$offset]) ? $this->container[$offset] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets value based on offset.
|
||||
* @param integer $offset Offset
|
||||
* @param mixed $value Value to be set
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if (is_null($offset)) {
|
||||
$this->container[] = $value;
|
||||
} else {
|
||||
$this->container[$offset] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets offset.
|
||||
* @param integer $offset Offset
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,348 @@
|
||||
<?php
|
||||
/**
|
||||
* BalanceBankAccountListAccountInfoDetailResult
|
||||
* PHP version 5
|
||||
* @author Swagger Codegen team
|
||||
* @package Yeepay\Yop\Sdk\
|
||||
* @category Class
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
|
||||
/**
|
||||
* 账户
|
||||
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
* Swagger Codegen version: 3.0.13
|
||||
*/
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use ArrayAccess;
|
||||
use Yeepay\Yop\Sdk\Model\ModelInterface;
|
||||
use Yeepay\Yop\Sdk\Utils\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* BalanceBankAccountListAccountInfoDetailResult Class Doc Comment
|
||||
* @author Swagger Codegen team
|
||||
* @package Yeepay\Yop\Sdk\
|
||||
* @category Class
|
||||
* @description
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
class BalanceBankAccountListAccountInfoDetailResult implements ModelInterface, ArrayAccess
|
||||
{
|
||||
|
||||
const DISCRIMINATOR = null;
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
* @var string
|
||||
*/
|
||||
protected static $swaggerModelName = 'BalanceBankAccountListAccountInfoDetailResult';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerTypes = [
|
||||
'accountType' => 'string',
|
||||
'balance' => 'float',
|
||||
'availableBalance' => 'float',
|
||||
'freezeBalance' => 'float',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'accountType' => null,
|
||||
'balance' => null,
|
||||
'availableBalance' => null,
|
||||
'freezeBalance' => null,
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
* @return array
|
||||
*/
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @return array
|
||||
*/
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'accountType' => 'accountType',
|
||||
'balance' => 'balance',
|
||||
'availableBalance' => 'availableBalance',
|
||||
'freezeBalance' => 'freezeBalance',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'accountType' => 'setAccountType',
|
||||
'balance' => 'setBalance',
|
||||
'availableBalance' => 'setAvailableBalance',
|
||||
'freezeBalance' => 'setFreezeBalance',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'accountType' => 'getAccountType',
|
||||
'balance' => 'getBalance',
|
||||
'availableBalance' => 'getAvailableBalance',
|
||||
'freezeBalance' => 'getFreezeBalance',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$swaggerModelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->container['accountType'] = isset($data['accountType']) ? $data['accountType'] : null;
|
||||
$this->container['balance'] = isset($data['balance']) ? $data['balance'] : null;
|
||||
$this->container['availableBalance'] = isset($data['availableBalance']) ? $data['availableBalance'] : null;
|
||||
$this->container['freezeBalance'] = isset($data['freezeBalance']) ? $data['freezeBalance'] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show all the invalid properties with reasons.
|
||||
* @return array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
return $invalidProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate all the properties in the model
|
||||
* return true if all passed
|
||||
* @return bool True if all properties are valid
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets accountType
|
||||
* @return string
|
||||
*/
|
||||
public function getAccountType()
|
||||
{
|
||||
return $this->container['accountType'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets accountType
|
||||
* @param string $accountType 账户类型
|
||||
* @return $this
|
||||
*/
|
||||
public function setAccountType($accountType)
|
||||
{
|
||||
$this->container['accountType'] = $accountType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets balance
|
||||
* @return float
|
||||
*/
|
||||
public function getBalance()
|
||||
{
|
||||
return $this->container['balance'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets balance
|
||||
* @param float $balance 账户余额
|
||||
* @return $this
|
||||
*/
|
||||
public function setBalance($balance)
|
||||
{
|
||||
$this->container['balance'] = $balance;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets availableBalance
|
||||
* @return float
|
||||
*/
|
||||
public function getAvailableBalance()
|
||||
{
|
||||
return $this->container['availableBalance'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets availableBalance
|
||||
* @param float $availableBalance 可用余额
|
||||
* @return $this
|
||||
*/
|
||||
public function setAvailableBalance($availableBalance)
|
||||
{
|
||||
$this->container['availableBalance'] = $availableBalance;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets freezeBalance
|
||||
* @return float
|
||||
*/
|
||||
public function getFreezeBalance()
|
||||
{
|
||||
return $this->container['freezeBalance'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets freezeBalance
|
||||
* @param float $freezeBalance 冻结金额
|
||||
* @return $this
|
||||
*/
|
||||
public function setFreezeBalance($freezeBalance)
|
||||
{
|
||||
$this->container['freezeBalance'] = $freezeBalance;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
* @param integer $offset Offset
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
* @param integer $offset Offset
|
||||
* @return mixed
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return isset($this->container[$offset]) ? $this->container[$offset] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets value based on offset.
|
||||
* @param integer $offset Offset
|
||||
* @param mixed $value Value to be set
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if (is_null($offset)) {
|
||||
$this->container[] = $value;
|
||||
} else {
|
||||
$this->container[$offset] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets offset.
|
||||
* @param integer $offset Offset
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,374 @@
|
||||
<?php
|
||||
/**
|
||||
* BalanceBankAccountListQueryInnerAndBankAccountInfoRespDTOResult
|
||||
* PHP version 5
|
||||
* @author Swagger Codegen team
|
||||
* @package Yeepay\Yop\Sdk\
|
||||
* @category Class
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
|
||||
/**
|
||||
* 账户
|
||||
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
* Swagger Codegen version: 3.0.13
|
||||
*/
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use ArrayAccess;
|
||||
use Yeepay\Yop\Sdk\Model\ModelInterface;
|
||||
use Yeepay\Yop\Sdk\Utils\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* BalanceBankAccountListQueryInnerAndBankAccountInfoRespDTOResult Class Doc Comment
|
||||
* @author Swagger Codegen team
|
||||
* @package Yeepay\Yop\Sdk\
|
||||
* @category Class
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
class BalanceBankAccountListQueryInnerAndBankAccountInfoRespDTOResult implements ModelInterface, ArrayAccess
|
||||
{
|
||||
|
||||
const DISCRIMINATOR = null;
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
* @var string
|
||||
*/
|
||||
protected static $swaggerModelName = 'BalanceBankAccountListQueryInnerAndBankAccountInfoRespDTOResult';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerTypes = [
|
||||
'returnCode' => 'string',
|
||||
'returnMsg' => 'string',
|
||||
'merchantNo' => 'string',
|
||||
'totalAccountBalance' => 'float',
|
||||
'accountInfoList' => '\Yeepay\Yop\Sdk\Service\Account\Model\BalanceBankAccountListAccountInfoDetailResult[]',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'returnCode' => null,
|
||||
'returnMsg' => null,
|
||||
'merchantNo' => null,
|
||||
'totalAccountBalance' => null,
|
||||
'accountInfoList' => null,
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
* @return array
|
||||
*/
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @return array
|
||||
*/
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'returnCode' => 'returnCode',
|
||||
'returnMsg' => 'returnMsg',
|
||||
'merchantNo' => 'merchantNo',
|
||||
'totalAccountBalance' => 'totalAccountBalance',
|
||||
'accountInfoList' => 'accountInfoList',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'returnCode' => 'setReturnCode',
|
||||
'returnMsg' => 'setReturnMsg',
|
||||
'merchantNo' => 'setMerchantNo',
|
||||
'totalAccountBalance' => 'setTotalAccountBalance',
|
||||
'accountInfoList' => 'setAccountInfoList',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'returnCode' => 'getReturnCode',
|
||||
'returnMsg' => 'getReturnMsg',
|
||||
'merchantNo' => 'getMerchantNo',
|
||||
'totalAccountBalance' => 'getTotalAccountBalance',
|
||||
'accountInfoList' => 'getAccountInfoList',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$swaggerModelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->container['returnCode'] = isset($data['returnCode']) ? $data['returnCode'] : null;
|
||||
$this->container['returnMsg'] = isset($data['returnMsg']) ? $data['returnMsg'] : null;
|
||||
$this->container['merchantNo'] = isset($data['merchantNo']) ? $data['merchantNo'] : null;
|
||||
$this->container['totalAccountBalance'] = isset($data['totalAccountBalance']) ? $data['totalAccountBalance'] : null;
|
||||
$this->container['accountInfoList'] = isset($data['accountInfoList']) ? $data['accountInfoList'] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show all the invalid properties with reasons.
|
||||
* @return array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
return $invalidProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate all the properties in the model
|
||||
* return true if all passed
|
||||
* @return bool True if all properties are valid
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets returnCode
|
||||
* @return string
|
||||
*/
|
||||
public function getReturnCode()
|
||||
{
|
||||
return $this->container['returnCode'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets returnCode
|
||||
* @param string $returnCode 返回码
|
||||
* @return $this
|
||||
*/
|
||||
public function setReturnCode($returnCode)
|
||||
{
|
||||
$this->container['returnCode'] = $returnCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets returnMsg
|
||||
* @return string
|
||||
*/
|
||||
public function getReturnMsg()
|
||||
{
|
||||
return $this->container['returnMsg'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets returnMsg
|
||||
* @param string $returnMsg 返回描述
|
||||
* @return $this
|
||||
*/
|
||||
public function setReturnMsg($returnMsg)
|
||||
{
|
||||
$this->container['returnMsg'] = $returnMsg;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets merchantNo
|
||||
* @return string
|
||||
*/
|
||||
public function getMerchantNo()
|
||||
{
|
||||
return $this->container['merchantNo'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets merchantNo
|
||||
* @param string $merchantNo 商户编号
|
||||
* @return $this
|
||||
*/
|
||||
public function setMerchantNo($merchantNo)
|
||||
{
|
||||
$this->container['merchantNo'] = $merchantNo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets totalAccountBalance
|
||||
* @return float
|
||||
*/
|
||||
public function getTotalAccountBalance()
|
||||
{
|
||||
return $this->container['totalAccountBalance'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets totalAccountBalance
|
||||
* @param float $totalAccountBalance 总计金额
|
||||
* @return $this
|
||||
*/
|
||||
public function setTotalAccountBalance($totalAccountBalance)
|
||||
{
|
||||
$this->container['totalAccountBalance'] = $totalAccountBalance;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets accountInfoList
|
||||
* @return \Yeepay\Yop\Sdk\Service\Account\Model\BalanceBankAccountListAccountInfoDetailResult[]
|
||||
*/
|
||||
public function getAccountInfoList()
|
||||
{
|
||||
return $this->container['accountInfoList'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets accountInfoList
|
||||
* @param \Yeepay\Yop\Sdk\Service\Account\Model\BalanceBankAccountListAccountInfoDetailResult[] $accountInfoList 账户信息列表
|
||||
* @return $this
|
||||
*/
|
||||
public function setAccountInfoList($accountInfoList)
|
||||
{
|
||||
$this->container['accountInfoList'] = $accountInfoList;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
* @param integer $offset Offset
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
* @param integer $offset Offset
|
||||
* @return mixed
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return isset($this->container[$offset]) ? $this->container[$offset] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets value based on offset.
|
||||
* @param integer $offset Offset
|
||||
* @param mixed $value Value to be set
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if (is_null($offset)) {
|
||||
$this->container[] = $value;
|
||||
} else {
|
||||
$this->container[$offset] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets offset.
|
||||
* @param integer $offset Offset
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
93
lib/Service/Account/Model/BalanceBankAccountListRequest.php
Normal file
93
lib/Service/Account/Model/BalanceBankAccountListRequest.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Model\BaseRequest;
|
||||
|
||||
class BalanceBankAccountListRequest extends BaseRequest
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $parentMerchantNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $merchantNo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $bankCode;
|
||||
|
||||
/**
|
||||
* Gets parentMerchantNo
|
||||
* @return string
|
||||
*/
|
||||
public function getParentMerchantNo()
|
||||
{
|
||||
return $this->parentMerchantNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets parentMerchantNo
|
||||
* @param string $parentMerchantNo
|
||||
* @return BalanceBankAccountListRequest
|
||||
*/
|
||||
public function setParentMerchantNo($parentMerchantNo)
|
||||
{
|
||||
$this->parentMerchantNo = $parentMerchantNo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets merchantNo
|
||||
* @return string
|
||||
*/
|
||||
public function getMerchantNo()
|
||||
{
|
||||
return $this->merchantNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets merchantNo
|
||||
* @param string $merchantNo
|
||||
* @return BalanceBankAccountListRequest
|
||||
*/
|
||||
public function setMerchantNo($merchantNo)
|
||||
{
|
||||
$this->merchantNo = $merchantNo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets bankCode
|
||||
* @return string
|
||||
*/
|
||||
public function getBankCode()
|
||||
{
|
||||
return $this->bankCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets bankCode
|
||||
* @param string $bankCode
|
||||
* @return BalanceBankAccountListRequest
|
||||
*/
|
||||
public function setBankCode($bankCode)
|
||||
{
|
||||
$this->bankCode = $bankCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function getOperationId()
|
||||
{
|
||||
return 'balanceBankAccountList';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Http\Headers;
|
||||
use Yeepay\Yop\Sdk\Internal\DefaultRequest;
|
||||
use Yeepay\Yop\Sdk\Internal\Request;
|
||||
use Yeepay\Yop\Sdk\Model\Transform\RequestMarshaller;
|
||||
use Yeepay\Yop\Sdk\Utils\UUIDUtils;
|
||||
|
||||
class BalanceBankAccountListRequestMarshaller implements RequestMarshaller
|
||||
{
|
||||
|
||||
/**
|
||||
* @var BalanceBankAccountListRequestMarshaller
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
public static function __init()
|
||||
{
|
||||
self::$instance = new BalanceBankAccountListRequestMarshaller();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BalanceBankAccountListRequestMarshaller
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $serviceName = 'Account';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $httpMethod = 'GET';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $resourcePath = '/rest/v1.0/account/balance/bank-account/list';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $contentType = 'application/x-www-form-urlencoded';
|
||||
|
||||
/**
|
||||
* @param BalanceBankAccountListRequest $request
|
||||
* @return Request
|
||||
*/
|
||||
public function marshal($request)
|
||||
{
|
||||
$internalRequest = new DefaultRequest($this->serviceName);
|
||||
$internalRequest->setResourcePath($this->resourcePath);
|
||||
$internalRequest->setHttpMethod($this->httpMethod);
|
||||
if (!empty($request->getRequestConfig()) && !empty($request->getRequestConfig()->getCustomRequestHeaders())) {
|
||||
foreach ($request->getRequestConfig()->getCustomRequestHeaders() as $name => $value) {
|
||||
$internalRequest->addHeader($name, $value);
|
||||
}
|
||||
}
|
||||
if (!isset($internalRequest->getHeaders()[Headers::YOP_REQUEST_ID])) {
|
||||
$internalRequest->addHeader(Headers::YOP_REQUEST_ID, UUIDUtils::uuid());
|
||||
}
|
||||
$internalRequest->addHeader(Headers::CONTENT_TYPE, $this->contentType);
|
||||
|
||||
return $internalRequest;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BalanceBankAccountListRequestMarshaller::__init();
|
||||
36
lib/Service/Account/Model/BalanceBankAccountListResponse.php
Normal file
36
lib/Service/Account/Model/BalanceBankAccountListResponse.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Model\BaseResponse;
|
||||
|
||||
class BalanceBankAccountListResponse extends BaseResponse
|
||||
{
|
||||
|
||||
/**
|
||||
* @var BalanceBankAccountListQueryInnerAndBankAccountInfoRespDTOResult
|
||||
*/
|
||||
private $result;
|
||||
|
||||
function getResultClass()
|
||||
{
|
||||
return '\Yeepay\Yop\Sdk\Service\Account\Model\BalanceBankAccountListQueryInnerAndBankAccountInfoRespDTOResult';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BalanceBankAccountListQueryInnerAndBankAccountInfoRespDTOResult $result
|
||||
*/
|
||||
function setResult($result)
|
||||
{
|
||||
$this->result = $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BalanceBankAccountListQueryInnerAndBankAccountInfoRespDTOResult
|
||||
*/
|
||||
function getResult()
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Model\Transform\BaseResponseUnMarshaller;
|
||||
|
||||
class BalanceBankAccountListResponseUnMarshaller extends BaseResponseUnMarshaller
|
||||
{
|
||||
|
||||
/**
|
||||
* @var BalanceBankAccountListResponseUnMarshaller
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
public static function __init()
|
||||
{
|
||||
self::$instance = new BalanceBankAccountListResponseUnMarshaller();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BalanceBankAccountListResponseUnMarshaller
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BalanceBankAccountListResponse
|
||||
*/
|
||||
protected function getResponseInstance()
|
||||
{
|
||||
return new BalanceBankAccountListResponse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BalanceBankAccountListResponseUnMarshaller::__init();
|
||||
@@ -0,0 +1,428 @@
|
||||
<?php
|
||||
/**
|
||||
* BalanceQueryAccountInfoRespDTOResult
|
||||
* PHP version 5
|
||||
* @author Swagger Codegen team
|
||||
* @package Yeepay\Yop\Sdk\
|
||||
* @category Class
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
|
||||
/**
|
||||
* 账户
|
||||
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
* Swagger Codegen version: 3.0.13
|
||||
*/
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use ArrayAccess;
|
||||
use Yeepay\Yop\Sdk\Model\ModelInterface;
|
||||
use Yeepay\Yop\Sdk\Utils\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* BalanceQueryAccountInfoRespDTOResult Class Doc Comment
|
||||
* @author Swagger Codegen team
|
||||
* @package Yeepay\Yop\Sdk\
|
||||
* @category Class
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
class BalanceQueryAccountInfoRespDTOResult implements ModelInterface, ArrayAccess
|
||||
{
|
||||
|
||||
const DISCRIMINATOR = null;
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
* @var string
|
||||
*/
|
||||
protected static $swaggerModelName = 'BalanceQueryAccountInfoRespDTOResult';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerTypes = [
|
||||
'returnCode' => 'string',
|
||||
'returnMsg' => 'string',
|
||||
'merchantNo' => 'string',
|
||||
'accountNo' => 'string',
|
||||
'accountCreateTime' => 'string',
|
||||
'balance' => 'float',
|
||||
'accountStatus' => 'string',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $swaggerFormats = [
|
||||
'returnCode' => null,
|
||||
'returnMsg' => null,
|
||||
'merchantNo' => null,
|
||||
'accountNo' => null,
|
||||
'accountCreateTime' => 'date-time',
|
||||
'balance' => null,
|
||||
'accountStatus' => null,
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
* @return array
|
||||
*/
|
||||
public static function swaggerTypes()
|
||||
{
|
||||
return self::$swaggerTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
* @return array
|
||||
*/
|
||||
public static function swaggerFormats()
|
||||
{
|
||||
return self::$swaggerFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'returnCode' => 'returnCode',
|
||||
'returnMsg' => 'returnMsg',
|
||||
'merchantNo' => 'merchantNo',
|
||||
'accountNo' => 'accountNo',
|
||||
'accountCreateTime' => 'accountCreateTime',
|
||||
'balance' => 'balance',
|
||||
'accountStatus' => 'accountStatus',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'returnCode' => 'setReturnCode',
|
||||
'returnMsg' => 'setReturnMsg',
|
||||
'merchantNo' => 'setMerchantNo',
|
||||
'accountNo' => 'setAccountNo',
|
||||
'accountCreateTime' => 'setAccountCreateTime',
|
||||
'balance' => 'setBalance',
|
||||
'accountStatus' => 'setAccountStatus',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'returnCode' => 'getReturnCode',
|
||||
'returnMsg' => 'getReturnMsg',
|
||||
'merchantNo' => 'getMerchantNo',
|
||||
'accountNo' => 'getAccountNo',
|
||||
'accountCreateTime' => 'getAccountCreateTime',
|
||||
'balance' => 'getBalance',
|
||||
'accountStatus' => 'getAccountStatus',
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$swaggerModelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->container['returnCode'] = isset($data['returnCode']) ? $data['returnCode'] : null;
|
||||
$this->container['returnMsg'] = isset($data['returnMsg']) ? $data['returnMsg'] : null;
|
||||
$this->container['merchantNo'] = isset($data['merchantNo']) ? $data['merchantNo'] : null;
|
||||
$this->container['accountNo'] = isset($data['accountNo']) ? $data['accountNo'] : null;
|
||||
$this->container['accountCreateTime'] = isset($data['accountCreateTime']) ? $data['accountCreateTime'] : null;
|
||||
$this->container['balance'] = isset($data['balance']) ? $data['balance'] : null;
|
||||
$this->container['accountStatus'] = isset($data['accountStatus']) ? $data['accountStatus'] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show all the invalid properties with reasons.
|
||||
* @return array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
return $invalidProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate all the properties in the model
|
||||
* return true if all passed
|
||||
* @return bool True if all properties are valid
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets returnCode
|
||||
* @return string
|
||||
*/
|
||||
public function getReturnCode()
|
||||
{
|
||||
return $this->container['returnCode'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets returnCode
|
||||
* @param string $returnCode 返回码
|
||||
* @return $this
|
||||
*/
|
||||
public function setReturnCode($returnCode)
|
||||
{
|
||||
$this->container['returnCode'] = $returnCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets returnMsg
|
||||
* @return string
|
||||
*/
|
||||
public function getReturnMsg()
|
||||
{
|
||||
return $this->container['returnMsg'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets returnMsg
|
||||
* @param string $returnMsg 返回信息
|
||||
* @return $this
|
||||
*/
|
||||
public function setReturnMsg($returnMsg)
|
||||
{
|
||||
$this->container['returnMsg'] = $returnMsg;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets merchantNo
|
||||
* @return string
|
||||
*/
|
||||
public function getMerchantNo()
|
||||
{
|
||||
return $this->container['merchantNo'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets merchantNo
|
||||
* @param string $merchantNo 商户编号
|
||||
* @return $this
|
||||
*/
|
||||
public function setMerchantNo($merchantNo)
|
||||
{
|
||||
$this->container['merchantNo'] = $merchantNo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets accountNo
|
||||
* @return string
|
||||
*/
|
||||
public function getAccountNo()
|
||||
{
|
||||
return $this->container['accountNo'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets accountNo
|
||||
* @param string $accountNo 账户编号
|
||||
* @return $this
|
||||
*/
|
||||
public function setAccountNo($accountNo)
|
||||
{
|
||||
$this->container['accountNo'] = $accountNo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets accountCreateTime
|
||||
* @return string
|
||||
*/
|
||||
public function getAccountCreateTime()
|
||||
{
|
||||
return $this->container['accountCreateTime'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets accountCreateTime
|
||||
* @param string $accountCreateTime 账户创建时间
|
||||
* @return $this
|
||||
*/
|
||||
public function setAccountCreateTime($accountCreateTime)
|
||||
{
|
||||
$this->container['accountCreateTime'] = $accountCreateTime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets balance
|
||||
* @return float
|
||||
*/
|
||||
public function getBalance()
|
||||
{
|
||||
return $this->container['balance'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets balance
|
||||
* @param float $balance 账户余额
|
||||
* @return $this
|
||||
*/
|
||||
public function setBalance($balance)
|
||||
{
|
||||
$this->container['balance'] = $balance;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets accountStatus
|
||||
* @return string
|
||||
*/
|
||||
public function getAccountStatus()
|
||||
{
|
||||
return $this->container['accountStatus'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets accountStatus
|
||||
* @param string $accountStatus 账户状态
|
||||
* @return $this
|
||||
*/
|
||||
public function setAccountStatus($accountStatus)
|
||||
{
|
||||
$this->container['accountStatus'] = $accountStatus;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
* @param integer $offset Offset
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
* @param integer $offset Offset
|
||||
* @return mixed
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return isset($this->container[$offset]) ? $this->container[$offset] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets value based on offset.
|
||||
* @param integer $offset Offset
|
||||
* @param mixed $value Value to be set
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if (is_null($offset)) {
|
||||
$this->container[] = $value;
|
||||
} else {
|
||||
$this->container[$offset] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets offset.
|
||||
* @param integer $offset Offset
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
41
lib/Service/Account/Model/BalanceQueryRequest.php
Normal file
41
lib/Service/Account/Model/BalanceQueryRequest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Model\BaseRequest;
|
||||
|
||||
class BalanceQueryRequest extends BaseRequest
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $merchantNo;
|
||||
|
||||
/**
|
||||
* Gets merchantNo
|
||||
* @return string
|
||||
*/
|
||||
public function getMerchantNo()
|
||||
{
|
||||
return $this->merchantNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets merchantNo
|
||||
* @param string $merchantNo
|
||||
* @return BalanceQueryRequest
|
||||
*/
|
||||
public function setMerchantNo($merchantNo)
|
||||
{
|
||||
$this->merchantNo = $merchantNo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function getOperationId()
|
||||
{
|
||||
return 'balanceQuery';
|
||||
}
|
||||
|
||||
}
|
||||
76
lib/Service/Account/Model/BalanceQueryRequestMarshaller.php
Normal file
76
lib/Service/Account/Model/BalanceQueryRequestMarshaller.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Http\Headers;
|
||||
use Yeepay\Yop\Sdk\Internal\DefaultRequest;
|
||||
use Yeepay\Yop\Sdk\Internal\Request;
|
||||
use Yeepay\Yop\Sdk\Model\Transform\RequestMarshaller;
|
||||
use Yeepay\Yop\Sdk\Utils\UUIDUtils;
|
||||
|
||||
class BalanceQueryRequestMarshaller implements RequestMarshaller
|
||||
{
|
||||
|
||||
/**
|
||||
* @var BalanceQueryRequestMarshaller
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
public static function __init()
|
||||
{
|
||||
self::$instance = new BalanceQueryRequestMarshaller();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BalanceQueryRequestMarshaller
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $serviceName = 'Account';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $httpMethod = 'GET';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $resourcePath = '/rest/v1.0/account/balance/query';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $contentType = 'application/x-www-form-urlencoded';
|
||||
|
||||
/**
|
||||
* @param BalanceQueryRequest $request
|
||||
* @return Request
|
||||
*/
|
||||
public function marshal($request)
|
||||
{
|
||||
$internalRequest = new DefaultRequest($this->serviceName);
|
||||
$internalRequest->setResourcePath($this->resourcePath);
|
||||
$internalRequest->setHttpMethod($this->httpMethod);
|
||||
if (!empty($request->getRequestConfig()) && !empty($request->getRequestConfig()->getCustomRequestHeaders())) {
|
||||
foreach ($request->getRequestConfig()->getCustomRequestHeaders() as $name => $value) {
|
||||
$internalRequest->addHeader($name, $value);
|
||||
}
|
||||
}
|
||||
if (!isset($internalRequest->getHeaders()[Headers::YOP_REQUEST_ID])) {
|
||||
$internalRequest->addHeader(Headers::YOP_REQUEST_ID, UUIDUtils::uuid());
|
||||
}
|
||||
$internalRequest->addHeader(Headers::CONTENT_TYPE, $this->contentType);
|
||||
|
||||
return $internalRequest;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BalanceQueryRequestMarshaller::__init();
|
||||
36
lib/Service/Account/Model/BalanceQueryResponse.php
Normal file
36
lib/Service/Account/Model/BalanceQueryResponse.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Account\Model;
|
||||
|
||||
use Yeepay\Yop\Sdk\Model\BaseResponse;
|
||||
|
||||
class BalanceQueryResponse extends BaseResponse
|
||||
{
|
||||
|
||||
/**
|
||||
* @var BalanceQueryAccountInfoRespDTOResult
|
||||
*/
|
||||
private $result;
|
||||
|
||||
function getResultClass()
|
||||
{
|
||||
return '\Yeepay\Yop\Sdk\Service\Account\Model\BalanceQueryAccountInfoRespDTOResult';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BalanceQueryAccountInfoRespDTOResult $result
|
||||
*/
|
||||
function setResult($result)
|
||||
{
|
||||
$this->result = $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BalanceQueryAccountInfoRespDTOResult
|
||||
*/
|
||||
function getResult()
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user