增加聚合支付托管下单
This commit is contained in:
104
lib/Service/Offline/Model/CreateShopRequestMarshaller.php
Normal file
104
lib/Service/Offline/Model/CreateShopRequestMarshaller.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Yeepay\Yop\Sdk\Service\Offline\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 CreateShopRequestMarshaller implements RequestMarshaller
|
||||
{
|
||||
/**
|
||||
* @var CreateShopRequestMarshaller
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
public static function __init()
|
||||
{
|
||||
self::$instance = new CreateShopRequestMarshaller();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CreateShopRequestMarshaller
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $serviceName = 'Offline';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $httpMethod = 'POST';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $resourcePath = '/rest/v1.0/offline/create-shop';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $contentType = 'application/x-www-form-urlencoded';
|
||||
|
||||
|
||||
/**
|
||||
* @param CreateShopRequest $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->getAddress() != null){
|
||||
$internalRequest->addParameter('address', ObjectSerializer::sanitizeForSerialization($request->getAddress(), 'string'));
|
||||
}
|
||||
if($request->getProvince() != null){
|
||||
$internalRequest->addParameter('province', ObjectSerializer::sanitizeForSerialization($request->getProvince(), 'string'));
|
||||
}
|
||||
if($request->getCity() != null){
|
||||
$internalRequest->addParameter('city', ObjectSerializer::sanitizeForSerialization($request->getCity(), 'string'));
|
||||
}
|
||||
if($request->getDistrict() != null){
|
||||
$internalRequest->addParameter('district', ObjectSerializer::sanitizeForSerialization($request->getDistrict(), 'string'));
|
||||
}
|
||||
if($request->getMobile() != null){
|
||||
$internalRequest->addParameter('mobile', ObjectSerializer::sanitizeForSerialization($request->getMobile(), 'string'));
|
||||
}
|
||||
if($request->getShopName() != null){
|
||||
$internalRequest->addParameter('shopName', ObjectSerializer::sanitizeForSerialization($request->getShopName(), 'string'));
|
||||
}
|
||||
if($request->getParentMerchantNo() != null){
|
||||
$internalRequest->addParameter('parentMerchantNo', ObjectSerializer::sanitizeForSerialization($request->getParentMerchantNo(), 'string'));
|
||||
}
|
||||
if($request->getLinkman() != null){
|
||||
$internalRequest->addParameter('linkman', ObjectSerializer::sanitizeForSerialization($request->getLinkman(), 'string'));
|
||||
}
|
||||
if($request->getMerchantNo() != null){
|
||||
$internalRequest->addParameter('merchantNo', ObjectSerializer::sanitizeForSerialization($request->getMerchantNo(), 'string'));
|
||||
}
|
||||
$internalRequest->addHeader(Headers::CONTENT_TYPE, $this->contentType);
|
||||
|
||||
return $internalRequest;
|
||||
}
|
||||
}
|
||||
CreateShopRequestMarshaller::__init();
|
||||
Reference in New Issue
Block a user