fuc/vendor/alipaysdk/openapi/v3/src/Api/AlipayIserviceCcmSwArticleApi.php
2025-02-23 13:30:57 +08:00

2181 lines
90 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* AlipayIserviceCcmSwArticleApi
* PHP version 7.4
*
* @category Class
* @package Alipay\OpenAPISDK
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* 支付宝开放平台API
*
* 支付宝开放平台v3协议文档
*
* The version of the OpenAPI document: 2024-05-20
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.2.1
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Alipay\OpenAPISDK\Api;
use Alipay\OpenAPISDK\Util\AlipayConfigUtil;
use Alipay\OpenAPISDK\Util\AlipayLogger;
use Alipay\OpenAPISDK\Util\Model\CustomizedParams;
use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use Alipay\OpenAPISDK\ApiException;
use Alipay\OpenAPISDK\Configuration;
use Alipay\OpenAPISDK\HeaderSelector;
use Alipay\OpenAPISDK\ObjectSerializer;
/**
* AlipayIserviceCcmSwArticleApi Class Doc Comment
*
* @category Class
* @package Alipay\OpenAPISDK
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class AlipayIserviceCcmSwArticleApi
{
/**
* @var ClientInterface
*/
protected $client;
/**
* @var Configuration
*/
protected $config;
/**
* @var HeaderSelector
*/
protected $headerSelector;
/**
* @var int Host index
*/
protected $hostIndex;
/**
* @var AlipayConfigUtil
*/
protected $alipayConfigUtil;
/**
* @param ClientInterface $client
* @param Configuration $config
* @param HeaderSelector $selector
* @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
* @param AlipayConfigUtil $alipayConfigUtil
*/
public function __construct(
ClientInterface $client = null,
Configuration $config = null,
HeaderSelector $selector = null,
$hostIndex = 0,
AlipayConfigUtil $alipayConfigUtil = null
) {
$this->client = $client ?: new Client();
$this->config = $config ?: new Configuration();
$this->headerSelector = $selector ?: new HeaderSelector();
$this->hostIndex = $hostIndex;
$this->alipayConfigUtil = $alipayConfigUtil ?: new AlipayConfigUtil();
}
/**
* @return AlipayConfigUtil
*/
public function getAlipayConfigUtil(): AlipayConfigUtil
{
return $this->alipayConfigUtil;
}
/**
* @param AlipayConfigUtil $alipayConfigUtil
*/
public function setAlipayConfigUtil(AlipayConfigUtil $alipayConfigUtil): void
{
$this->alipayConfigUtil = $alipayConfigUtil;
}
/**
* Set the host index
*
* @param int $hostIndex Host index (required)
*/
public function setHostIndex($hostIndex): void
{
$this->hostIndex = $hostIndex;
}
/**
* Get the host index
*
* @return int Host index
*/
public function getHostIndex()
{
return $this->hostIndex;
}
/**
* @return Configuration
*/
public function getConfig()
{
return $this->config;
}
/**
* Operation batchquery
*
* 知识库-问答-批量查询
*
* @param \Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleBatchqueryModel $alipayIserviceCcmSwArticleBatchqueryModel alipayIserviceCcmSwArticleBatchqueryModel (optional)
* @param CustomizedParams $customizedParams
*
* @throws \Alipay\OpenAPISDK\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleBatchqueryResponseModel|\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleBatchqueryDefaultResponse
*/
public function batchquery($alipayIserviceCcmSwArticleBatchqueryModel = null, CustomizedParams $customizedParams = null)
{
list($response) = $this->batchqueryWithHttpInfo($alipayIserviceCcmSwArticleBatchqueryModel, $customizedParams);
return $response;
}
/**
* Operation batchqueryWithHttpInfo
*
* 知识库-问答-批量查询
*
* @param \Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleBatchqueryModel $alipayIserviceCcmSwArticleBatchqueryModel (optional)
* @param CustomizedParams $customizedParams
*
* @throws \Alipay\OpenAPISDK\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleBatchqueryResponseModel|\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleBatchqueryDefaultResponse, HTTP status code, HTTP response headers (array of strings)
*/
public function batchqueryWithHttpInfo($alipayIserviceCcmSwArticleBatchqueryModel = null, CustomizedParams $customizedParams = null)
{
$request = $this->batchqueryRequest($alipayIserviceCcmSwArticleBatchqueryModel, $customizedParams);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
if ($e->getResponse()) {
//验签
$this->alipayConfigUtil->verifyResponse((string)$e->getResponse()->getBody(),
$e->getResponse()->getHeaders(), true);
}
AlipayLogger::logBizError("code:{$e->getCode()}, message:{$e->getMessage()}");
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
);
} catch (ConnectException $e) {
AlipayLogger::logBizError("code:{$e->getCode()}, message:{$e->getMessage()}");
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
null,
null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
//验签
$bodyStr = (string)$response->getBody();
$this->alipayConfigUtil->verifyResponse($bodyStr, $response->getHeaders(), true);
AlipayLogger::logBizError("code:{$statusCode}, message:{$bodyStr}");
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
$bodyStr
);
}
switch($statusCode) {
case 200:
if ('\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleBatchqueryResponseModel' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
//验签
$this->alipayConfigUtil->verifyResponse($content, $response->getHeaders(), false);
//解密
$content = $this->alipayConfigUtil->decrypt($content);
if ('\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleBatchqueryResponseModel' !== 'string') {
$content = json_decode($content);
}
}
AlipayLogger::logBizResponseInfo($response->getStatusCode(), $content, $response->getHeaders());
return [
ObjectSerializer::deserialize($content, '\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleBatchqueryResponseModel', []),
$response->getStatusCode(),
$response->getHeaders()
];
default:
if ('\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleBatchqueryDefaultResponse' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
//验签
$this->alipayConfigUtil->verifyResponse($content, $response->getHeaders(), true);
if ('\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleBatchqueryDefaultResponse' !== 'string') {
$content = json_decode($content);
}
}
AlipayLogger::logBizResponseInfo($response->getStatusCode(), $content, $response->getHeaders());
return [
//ObjectSerializer::deserialize($content, '\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleBatchqueryDefaultResponse', []),
$content,
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleBatchqueryResponseModel';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
//验签
$this->alipayConfigUtil->verifyResponse($content, $response->getHeaders(), false);
//解密
$content = $this->alipayConfigUtil->decrypt($content);
if ($returnType !== 'string') {
$content = json_decode($content);
}
}
AlipayLogger::logBizResponseInfo($response->getStatusCode(), $content, $response->getHeaders());
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleBatchqueryResponseModel',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
default:
//$data = ObjectSerializer::deserialize(
// $e->getResponseBody(),
// '\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleBatchqueryDefaultResponse',
// $e->getResponseHeaders()
//);
//$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation batchqueryAsync
*
* 知识库-问答-批量查询
*
* @param \Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleBatchqueryModel $alipayIserviceCcmSwArticleBatchqueryModel (optional)
* @param CustomizedParams $customizedParams
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
* @deprecated
*/
public function batchqueryAsync($alipayIserviceCcmSwArticleBatchqueryModel = null, CustomizedParams $customizedParams = null)
{
return $this->batchqueryAsyncWithHttpInfo($alipayIserviceCcmSwArticleBatchqueryModel, $customizedParams)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation batchqueryAsyncWithHttpInfo
*
* 知识库-问答-批量查询
*
* @param \Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleBatchqueryModel $alipayIserviceCcmSwArticleBatchqueryModel (optional)
* @param CustomizedParams $customizedParams
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
* @deprecated
*/
public function batchqueryAsyncWithHttpInfo($alipayIserviceCcmSwArticleBatchqueryModel = null, CustomizedParams $customizedParams = null)
{
$returnType = '\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleBatchqueryResponseModel';
$request = $this->batchqueryRequest($alipayIserviceCcmSwArticleBatchqueryModel, $customizedParams);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
//验签
$this->alipayConfigUtil->verifyResponse($content, $response->getHeaders(), false);
//解密
$content = $this->alipayConfigUtil->decrypt($content);
if ($returnType !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
//验签
$this->alipayConfigUtil->verifyResponse((string)$response->getBody(), $response->getHeaders(), true);
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
);
}
/**
* Create request for operation 'batchquery'
*
* @param \Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleBatchqueryModel $alipayIserviceCcmSwArticleBatchqueryModel (optional)
* @param CustomizedParams $customizedParams
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
public function batchqueryRequest($alipayIserviceCcmSwArticleBatchqueryModel = null, CustomizedParams $customizedParams = null)
{
$resourcePath = '/v3/alipay/iservice/ccm/sw/article/batchquery';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
$signContent = '';
$isEncrypt = $this->alipayConfigUtil->isEncrypt();
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
if ($headers['Content-Type'] === 'multipart/form-data') {
$multipart = true;
unset($headers['Content-Type']);
}
// for model (json/xml)
//自定义body内容
if (($customizedParams != null && !$this->getAlipayConfigUtil()->checkEmpty($customizedParams->getBodyContent()))
&& ($headers['Content-Type'] === 'application/json' || $isEncrypt)) {
$signContent = $this->alipayConfigUtil->encrypt($customizedParams->getBodyContent(), $headers, $multipart);
$httpBody = $signContent;
} elseif (isset($alipayIserviceCcmSwArticleBatchqueryModel)) {
$signContent = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($alipayIserviceCcmSwArticleBatchqueryModel), JSON_UNESCAPED_UNICODE);
if ($headers['Content-Type'] === 'application/json' || $isEncrypt) {
$signContent = $this->alipayConfigUtil->encrypt($signContent, $headers, $multipart);
$httpBody = $signContent;
} else {
$httpBody = $alipayIserviceCcmSwArticleBatchqueryModel;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
if (is_string($formParamValueItem)) {
$signContent = $formParamValueItem;
}
//加密时非文件字段对应的Content-Type类型为text/plain
if ($isEncrypt && is_string($formParamValueItem)) {
$signContent = $this->alipayConfigUtil->encrypt($formParamValueItem, $headers, true);
$multipartContents[] = [
'name' => $formParamName,
'contents' => $signContent,
'headers' => ['Content-Type' => 'text/plain']
];
} else {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
'headers' => ['Content-Type' => 'application/json']
];
}
}
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$signContent = $this->alipayConfigUtil->encrypt(\GuzzleHttp\json_encode($formParams, JSON_UNESCAPED_UNICODE), $headers);
$httpBody = $signContent;
} else {
// for HTTP post (form)
$signContent = $this->alipayConfigUtil->encrypt(ObjectSerializer::buildQuery($formParams), $headers);
$httpBody = $signContent;
}
}
if ($isEncrypt) {
$headers['alipay-encrypt-type'] = $this->alipayConfigUtil->getEncryptType();
//除文件上传接口,加密后Content-Type均为"text/plain"
if (!$multipart) {
$headers['Content-Type'] = 'text/plain';
}
}
if ($customizedParams != null) {
//额外query参数
if (is_array($customizedParams->getQueryParams()) && count($customizedParams->getQueryParams()) >= 0) {
foreach ($customizedParams->getQueryParams() as $k => $v) {
if (is_array($v)) {
$v = ObjectSerializer::serializeCollection($v, 'form');
}
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue($v, $k) ?? []);
}
}
if (!$this->alipayConfigUtil->checkEmpty($customizedParams->getAppAuthToken())) {
$headerParams["alipay-app-auth-token"] = $customizedParams->getAppAuthToken();
}
//额外非全局header参数
if (is_array($customizedParams->getHeaderParams()) && count($customizedParams->getHeaderParams()) >= 0) {
foreach ($customizedParams->getHeaderParams() as $k => $v) {
if (is_array($v)) {
$v = ObjectSerializer::serializeCollection($v, 'form');
}
$headerParams[$k] = ObjectSerializer::toHeaderValue($v);
}
}
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
if ($this->config->getSdkVersion()) {
$defaultHeaders['alipay-sdk-version'] = $this->config->getSdkVersion();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
if (!array_key_exists('alipay-request-id', $headers)) {
$headers['alipay-request-id'] = $this->alipayConfigUtil->createUuid();
}
$query = ObjectSerializer::buildQuery($queryParams);
$url = $resourcePath . ($query ? "?{$query}" : '');
//加签
$this->alipayConfigUtil->sign('POST', $url, $signContent, $headers);
$basePath = $this->alipayConfigUtil->checkEmpty($this->alipayConfigUtil->getServerUrl()) ? $this->config->getHost() : $this->alipayConfigUtil->getServerUrl();
AlipayLogger::logBizInfo($basePath . $url, $signContent, 'POST', $multipart ? "multipart/form-data" : $headers['Content-Type'], $headers['alipay-request-id']);
return new Request(
'POST',
$basePath . $url,
$headers,
$httpBody
);
}
/**
* Operation create
*
* 知识库-问答-创建
*
* @param \Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleCreateModel $alipayIserviceCcmSwArticleCreateModel alipayIserviceCcmSwArticleCreateModel (optional)
* @param CustomizedParams $customizedParams
*
* @throws \Alipay\OpenAPISDK\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleCreateResponseModel|\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleCreateDefaultResponse
*/
public function create($alipayIserviceCcmSwArticleCreateModel = null, CustomizedParams $customizedParams = null)
{
list($response) = $this->createWithHttpInfo($alipayIserviceCcmSwArticleCreateModel, $customizedParams);
return $response;
}
/**
* Operation createWithHttpInfo
*
* 知识库-问答-创建
*
* @param \Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleCreateModel $alipayIserviceCcmSwArticleCreateModel (optional)
* @param CustomizedParams $customizedParams
*
* @throws \Alipay\OpenAPISDK\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleCreateResponseModel|\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleCreateDefaultResponse, HTTP status code, HTTP response headers (array of strings)
*/
public function createWithHttpInfo($alipayIserviceCcmSwArticleCreateModel = null, CustomizedParams $customizedParams = null)
{
$request = $this->createRequest($alipayIserviceCcmSwArticleCreateModel, $customizedParams);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
if ($e->getResponse()) {
//验签
$this->alipayConfigUtil->verifyResponse((string)$e->getResponse()->getBody(),
$e->getResponse()->getHeaders(), true);
}
AlipayLogger::logBizError("code:{$e->getCode()}, message:{$e->getMessage()}");
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
);
} catch (ConnectException $e) {
AlipayLogger::logBizError("code:{$e->getCode()}, message:{$e->getMessage()}");
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
null,
null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
//验签
$bodyStr = (string)$response->getBody();
$this->alipayConfigUtil->verifyResponse($bodyStr, $response->getHeaders(), true);
AlipayLogger::logBizError("code:{$statusCode}, message:{$bodyStr}");
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
$bodyStr
);
}
switch($statusCode) {
case 200:
if ('\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleCreateResponseModel' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
//验签
$this->alipayConfigUtil->verifyResponse($content, $response->getHeaders(), false);
//解密
$content = $this->alipayConfigUtil->decrypt($content);
if ('\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleCreateResponseModel' !== 'string') {
$content = json_decode($content);
}
}
AlipayLogger::logBizResponseInfo($response->getStatusCode(), $content, $response->getHeaders());
return [
ObjectSerializer::deserialize($content, '\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleCreateResponseModel', []),
$response->getStatusCode(),
$response->getHeaders()
];
default:
if ('\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleCreateDefaultResponse' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
//验签
$this->alipayConfigUtil->verifyResponse($content, $response->getHeaders(), true);
if ('\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleCreateDefaultResponse' !== 'string') {
$content = json_decode($content);
}
}
AlipayLogger::logBizResponseInfo($response->getStatusCode(), $content, $response->getHeaders());
return [
//ObjectSerializer::deserialize($content, '\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleCreateDefaultResponse', []),
$content,
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleCreateResponseModel';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
//验签
$this->alipayConfigUtil->verifyResponse($content, $response->getHeaders(), false);
//解密
$content = $this->alipayConfigUtil->decrypt($content);
if ($returnType !== 'string') {
$content = json_decode($content);
}
}
AlipayLogger::logBizResponseInfo($response->getStatusCode(), $content, $response->getHeaders());
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleCreateResponseModel',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
default:
//$data = ObjectSerializer::deserialize(
// $e->getResponseBody(),
// '\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleCreateDefaultResponse',
// $e->getResponseHeaders()
//);
//$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation createAsync
*
* 知识库-问答-创建
*
* @param \Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleCreateModel $alipayIserviceCcmSwArticleCreateModel (optional)
* @param CustomizedParams $customizedParams
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
* @deprecated
*/
public function createAsync($alipayIserviceCcmSwArticleCreateModel = null, CustomizedParams $customizedParams = null)
{
return $this->createAsyncWithHttpInfo($alipayIserviceCcmSwArticleCreateModel, $customizedParams)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation createAsyncWithHttpInfo
*
* 知识库-问答-创建
*
* @param \Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleCreateModel $alipayIserviceCcmSwArticleCreateModel (optional)
* @param CustomizedParams $customizedParams
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
* @deprecated
*/
public function createAsyncWithHttpInfo($alipayIserviceCcmSwArticleCreateModel = null, CustomizedParams $customizedParams = null)
{
$returnType = '\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleCreateResponseModel';
$request = $this->createRequest($alipayIserviceCcmSwArticleCreateModel, $customizedParams);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
//验签
$this->alipayConfigUtil->verifyResponse($content, $response->getHeaders(), false);
//解密
$content = $this->alipayConfigUtil->decrypt($content);
if ($returnType !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
//验签
$this->alipayConfigUtil->verifyResponse((string)$response->getBody(), $response->getHeaders(), true);
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
);
}
/**
* Create request for operation 'create'
*
* @param \Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleCreateModel $alipayIserviceCcmSwArticleCreateModel (optional)
* @param CustomizedParams $customizedParams
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
public function createRequest($alipayIserviceCcmSwArticleCreateModel = null, CustomizedParams $customizedParams = null)
{
$resourcePath = '/v3/alipay/iservice/ccm/sw/article/create';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
$signContent = '';
$isEncrypt = $this->alipayConfigUtil->isEncrypt();
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
if ($headers['Content-Type'] === 'multipart/form-data') {
$multipart = true;
unset($headers['Content-Type']);
}
// for model (json/xml)
//自定义body内容
if (($customizedParams != null && !$this->getAlipayConfigUtil()->checkEmpty($customizedParams->getBodyContent()))
&& ($headers['Content-Type'] === 'application/json' || $isEncrypt)) {
$signContent = $this->alipayConfigUtil->encrypt($customizedParams->getBodyContent(), $headers, $multipart);
$httpBody = $signContent;
} elseif (isset($alipayIserviceCcmSwArticleCreateModel)) {
$signContent = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($alipayIserviceCcmSwArticleCreateModel), JSON_UNESCAPED_UNICODE);
if ($headers['Content-Type'] === 'application/json' || $isEncrypt) {
$signContent = $this->alipayConfigUtil->encrypt($signContent, $headers, $multipart);
$httpBody = $signContent;
} else {
$httpBody = $alipayIserviceCcmSwArticleCreateModel;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
if (is_string($formParamValueItem)) {
$signContent = $formParamValueItem;
}
//加密时非文件字段对应的Content-Type类型为text/plain
if ($isEncrypt && is_string($formParamValueItem)) {
$signContent = $this->alipayConfigUtil->encrypt($formParamValueItem, $headers, true);
$multipartContents[] = [
'name' => $formParamName,
'contents' => $signContent,
'headers' => ['Content-Type' => 'text/plain']
];
} else {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
'headers' => ['Content-Type' => 'application/json']
];
}
}
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$signContent = $this->alipayConfigUtil->encrypt(\GuzzleHttp\json_encode($formParams, JSON_UNESCAPED_UNICODE), $headers);
$httpBody = $signContent;
} else {
// for HTTP post (form)
$signContent = $this->alipayConfigUtil->encrypt(ObjectSerializer::buildQuery($formParams), $headers);
$httpBody = $signContent;
}
}
if ($isEncrypt) {
$headers['alipay-encrypt-type'] = $this->alipayConfigUtil->getEncryptType();
//除文件上传接口,加密后Content-Type均为"text/plain"
if (!$multipart) {
$headers['Content-Type'] = 'text/plain';
}
}
if ($customizedParams != null) {
//额外query参数
if (is_array($customizedParams->getQueryParams()) && count($customizedParams->getQueryParams()) >= 0) {
foreach ($customizedParams->getQueryParams() as $k => $v) {
if (is_array($v)) {
$v = ObjectSerializer::serializeCollection($v, 'form');
}
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue($v, $k) ?? []);
}
}
if (!$this->alipayConfigUtil->checkEmpty($customizedParams->getAppAuthToken())) {
$headerParams["alipay-app-auth-token"] = $customizedParams->getAppAuthToken();
}
//额外非全局header参数
if (is_array($customizedParams->getHeaderParams()) && count($customizedParams->getHeaderParams()) >= 0) {
foreach ($customizedParams->getHeaderParams() as $k => $v) {
if (is_array($v)) {
$v = ObjectSerializer::serializeCollection($v, 'form');
}
$headerParams[$k] = ObjectSerializer::toHeaderValue($v);
}
}
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
if ($this->config->getSdkVersion()) {
$defaultHeaders['alipay-sdk-version'] = $this->config->getSdkVersion();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
if (!array_key_exists('alipay-request-id', $headers)) {
$headers['alipay-request-id'] = $this->alipayConfigUtil->createUuid();
}
$query = ObjectSerializer::buildQuery($queryParams);
$url = $resourcePath . ($query ? "?{$query}" : '');
//加签
$this->alipayConfigUtil->sign('PUT', $url, $signContent, $headers);
$basePath = $this->alipayConfigUtil->checkEmpty($this->alipayConfigUtil->getServerUrl()) ? $this->config->getHost() : $this->alipayConfigUtil->getServerUrl();
AlipayLogger::logBizInfo($basePath . $url, $signContent, 'PUT', $multipart ? "multipart/form-data" : $headers['Content-Type'], $headers['alipay-request-id']);
return new Request(
'PUT',
$basePath . $url,
$headers,
$httpBody
);
}
/**
* Operation delete
*
* 知识库-问答-删除
*
* @param CustomizedParams $customizedParams
*
* @throws \Alipay\OpenAPISDK\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return object|\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleDeleteDefaultResponse
*/
public function delete(CustomizedParams $customizedParams = null)
{
list($response) = $this->deleteWithHttpInfo($customizedParams);
return $response;
}
/**
* Operation deleteWithHttpInfo
*
* 知识库-问答-删除
*
* @param CustomizedParams $customizedParams
*
* @throws \Alipay\OpenAPISDK\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of object|\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleDeleteDefaultResponse, HTTP status code, HTTP response headers (array of strings)
*/
public function deleteWithHttpInfo(CustomizedParams $customizedParams = null)
{
$request = $this->deleteRequest($customizedParams);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
if ($e->getResponse()) {
//验签
$this->alipayConfigUtil->verifyResponse((string)$e->getResponse()->getBody(),
$e->getResponse()->getHeaders(), true);
}
AlipayLogger::logBizError("code:{$e->getCode()}, message:{$e->getMessage()}");
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
);
} catch (ConnectException $e) {
AlipayLogger::logBizError("code:{$e->getCode()}, message:{$e->getMessage()}");
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
null,
null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
//验签
$bodyStr = (string)$response->getBody();
$this->alipayConfigUtil->verifyResponse($bodyStr, $response->getHeaders(), true);
AlipayLogger::logBizError("code:{$statusCode}, message:{$bodyStr}");
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
$bodyStr
);
}
switch($statusCode) {
case 200:
if ('object' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
//验签
$this->alipayConfigUtil->verifyResponse($content, $response->getHeaders(), false);
//解密
$content = $this->alipayConfigUtil->decrypt($content);
if ('object' !== 'string') {
$content = json_decode($content);
}
}
AlipayLogger::logBizResponseInfo($response->getStatusCode(), $content, $response->getHeaders());
return [
ObjectSerializer::deserialize($content, 'object', []),
$response->getStatusCode(),
$response->getHeaders()
];
default:
if ('\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleDeleteDefaultResponse' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
//验签
$this->alipayConfigUtil->verifyResponse($content, $response->getHeaders(), true);
if ('\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleDeleteDefaultResponse' !== 'string') {
$content = json_decode($content);
}
}
AlipayLogger::logBizResponseInfo($response->getStatusCode(), $content, $response->getHeaders());
return [
//ObjectSerializer::deserialize($content, '\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleDeleteDefaultResponse', []),
$content,
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = 'object';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
//验签
$this->alipayConfigUtil->verifyResponse($content, $response->getHeaders(), false);
//解密
$content = $this->alipayConfigUtil->decrypt($content);
if ($returnType !== 'string') {
$content = json_decode($content);
}
}
AlipayLogger::logBizResponseInfo($response->getStatusCode(), $content, $response->getHeaders());
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'object',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
default:
//$data = ObjectSerializer::deserialize(
// $e->getResponseBody(),
// '\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleDeleteDefaultResponse',
// $e->getResponseHeaders()
//);
//$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation deleteAsync
*
* 知识库-问答-删除
*
* @param CustomizedParams $customizedParams
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
* @deprecated
*/
public function deleteAsync(CustomizedParams $customizedParams = null)
{
return $this->deleteAsyncWithHttpInfo($customizedParams)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation deleteAsyncWithHttpInfo
*
* 知识库-问答-删除
*
* @param CustomizedParams $customizedParams
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
* @deprecated
*/
public function deleteAsyncWithHttpInfo(CustomizedParams $customizedParams = null)
{
$returnType = 'object';
$request = $this->deleteRequest($customizedParams);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
//验签
$this->alipayConfigUtil->verifyResponse($content, $response->getHeaders(), false);
//解密
$content = $this->alipayConfigUtil->decrypt($content);
if ($returnType !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
//验签
$this->alipayConfigUtil->verifyResponse((string)$response->getBody(), $response->getHeaders(), true);
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
);
}
/**
* Create request for operation 'delete'
*
* @param CustomizedParams $customizedParams
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
public function deleteRequest(CustomizedParams $customizedParams = null)
{
$resourcePath = '/v3/alipay/iservice/ccm/sw/article/delete';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
$signContent = '';
$isEncrypt = $this->alipayConfigUtil->isEncrypt();
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
if ($headers['Content-Type'] === 'multipart/form-data') {
$multipart = true;
unset($headers['Content-Type']);
}
// for model (json/xml)
if (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
if (is_string($formParamValueItem)) {
$signContent = $formParamValueItem;
}
//加密时非文件字段对应的Content-Type类型为text/plain
if ($isEncrypt && is_string($formParamValueItem)) {
$signContent = $this->alipayConfigUtil->encrypt($formParamValueItem, $headers, true);
$multipartContents[] = [
'name' => $formParamName,
'contents' => $signContent,
'headers' => ['Content-Type' => 'text/plain']
];
} else {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
'headers' => ['Content-Type' => 'application/json']
];
}
}
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$signContent = $this->alipayConfigUtil->encrypt(\GuzzleHttp\json_encode($formParams, JSON_UNESCAPED_UNICODE), $headers);
$httpBody = $signContent;
} else {
// for HTTP post (form)
$signContent = $this->alipayConfigUtil->encrypt(ObjectSerializer::buildQuery($formParams), $headers);
$httpBody = $signContent;
}
}
if ($isEncrypt) {
$headers['alipay-encrypt-type'] = $this->alipayConfigUtil->getEncryptType();
//除文件上传接口,加密后Content-Type均为"text/plain"
if (!$multipart) {
$headers['Content-Type'] = 'text/plain';
}
}
if ($customizedParams != null) {
//额外query参数
if (is_array($customizedParams->getQueryParams()) && count($customizedParams->getQueryParams()) >= 0) {
foreach ($customizedParams->getQueryParams() as $k => $v) {
if (is_array($v)) {
$v = ObjectSerializer::serializeCollection($v, 'form');
}
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue($v, $k) ?? []);
}
}
if (!$this->alipayConfigUtil->checkEmpty($customizedParams->getAppAuthToken())) {
$headerParams["alipay-app-auth-token"] = $customizedParams->getAppAuthToken();
}
//额外非全局header参数
if (is_array($customizedParams->getHeaderParams()) && count($customizedParams->getHeaderParams()) >= 0) {
foreach ($customizedParams->getHeaderParams() as $k => $v) {
if (is_array($v)) {
$v = ObjectSerializer::serializeCollection($v, 'form');
}
$headerParams[$k] = ObjectSerializer::toHeaderValue($v);
}
}
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
if ($this->config->getSdkVersion()) {
$defaultHeaders['alipay-sdk-version'] = $this->config->getSdkVersion();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
if (!array_key_exists('alipay-request-id', $headers)) {
$headers['alipay-request-id'] = $this->alipayConfigUtil->createUuid();
}
$query = ObjectSerializer::buildQuery($queryParams);
$url = $resourcePath . ($query ? "?{$query}" : '');
//加签
$this->alipayConfigUtil->sign('DELETE', $url, $signContent, $headers);
$basePath = $this->alipayConfigUtil->checkEmpty($this->alipayConfigUtil->getServerUrl()) ? $this->config->getHost() : $this->alipayConfigUtil->getServerUrl();
AlipayLogger::logBizInfo($basePath . $url, $signContent, 'DELETE', $multipart ? "multipart/form-data" : $headers['Content-Type'], $headers['alipay-request-id']);
return new Request(
'DELETE',
$basePath . $url,
$headers,
$httpBody
);
}
/**
* Operation get
*
* 知识库-问答-获取
*
* @param string $ccsInstanceId 子部门ID,不传为默认部门 (optional)
* @param int $id 文章ID (optional)
* @param CustomizedParams $customizedParams
*
* @throws \Alipay\OpenAPISDK\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return \Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleGetResponseModel|\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleGetDefaultResponse
*/
public function get($ccsInstanceId = null, $id = null, CustomizedParams $customizedParams = null)
{
list($response) = $this->getWithHttpInfo($ccsInstanceId, $id, $customizedParams);
return $response;
}
/**
* Operation getWithHttpInfo
*
* 知识库-问答-获取
*
* @param string $ccsInstanceId 子部门ID,不传为默认部门 (optional)
* @param int $id 文章ID (optional)
* @param CustomizedParams $customizedParams
*
* @throws \Alipay\OpenAPISDK\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of \Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleGetResponseModel|\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleGetDefaultResponse, HTTP status code, HTTP response headers (array of strings)
*/
public function getWithHttpInfo($ccsInstanceId = null, $id = null, CustomizedParams $customizedParams = null)
{
$request = $this->getRequest($ccsInstanceId, $id, $customizedParams);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
if ($e->getResponse()) {
//验签
$this->alipayConfigUtil->verifyResponse((string)$e->getResponse()->getBody(),
$e->getResponse()->getHeaders(), true);
}
AlipayLogger::logBizError("code:{$e->getCode()}, message:{$e->getMessage()}");
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
);
} catch (ConnectException $e) {
AlipayLogger::logBizError("code:{$e->getCode()}, message:{$e->getMessage()}");
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
null,
null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
//验签
$bodyStr = (string)$response->getBody();
$this->alipayConfigUtil->verifyResponse($bodyStr, $response->getHeaders(), true);
AlipayLogger::logBizError("code:{$statusCode}, message:{$bodyStr}");
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
$bodyStr
);
}
switch($statusCode) {
case 200:
if ('\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleGetResponseModel' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
//验签
$this->alipayConfigUtil->verifyResponse($content, $response->getHeaders(), false);
//解密
$content = $this->alipayConfigUtil->decrypt($content);
if ('\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleGetResponseModel' !== 'string') {
$content = json_decode($content);
}
}
AlipayLogger::logBizResponseInfo($response->getStatusCode(), $content, $response->getHeaders());
return [
ObjectSerializer::deserialize($content, '\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleGetResponseModel', []),
$response->getStatusCode(),
$response->getHeaders()
];
default:
if ('\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleGetDefaultResponse' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
//验签
$this->alipayConfigUtil->verifyResponse($content, $response->getHeaders(), true);
if ('\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleGetDefaultResponse' !== 'string') {
$content = json_decode($content);
}
}
AlipayLogger::logBizResponseInfo($response->getStatusCode(), $content, $response->getHeaders());
return [
//ObjectSerializer::deserialize($content, '\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleGetDefaultResponse', []),
$content,
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleGetResponseModel';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
//验签
$this->alipayConfigUtil->verifyResponse($content, $response->getHeaders(), false);
//解密
$content = $this->alipayConfigUtil->decrypt($content);
if ($returnType !== 'string') {
$content = json_decode($content);
}
}
AlipayLogger::logBizResponseInfo($response->getStatusCode(), $content, $response->getHeaders());
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleGetResponseModel',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
default:
//$data = ObjectSerializer::deserialize(
// $e->getResponseBody(),
// '\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleGetDefaultResponse',
// $e->getResponseHeaders()
//);
//$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation getAsync
*
* 知识库-问答-获取
*
* @param string $ccsInstanceId 子部门ID,不传为默认部门 (optional)
* @param int $id 文章ID (optional)
* @param CustomizedParams $customizedParams
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
* @deprecated
*/
public function getAsync($ccsInstanceId = null, $id = null, CustomizedParams $customizedParams = null)
{
return $this->getAsyncWithHttpInfo($ccsInstanceId, $id, $customizedParams)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation getAsyncWithHttpInfo
*
* 知识库-问答-获取
*
* @param string $ccsInstanceId 子部门ID,不传为默认部门 (optional)
* @param int $id 文章ID (optional)
* @param CustomizedParams $customizedParams
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
* @deprecated
*/
public function getAsyncWithHttpInfo($ccsInstanceId = null, $id = null, CustomizedParams $customizedParams = null)
{
$returnType = '\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleGetResponseModel';
$request = $this->getRequest($ccsInstanceId, $id, $customizedParams);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
//验签
$this->alipayConfigUtil->verifyResponse($content, $response->getHeaders(), false);
//解密
$content = $this->alipayConfigUtil->decrypt($content);
if ($returnType !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
//验签
$this->alipayConfigUtil->verifyResponse((string)$response->getBody(), $response->getHeaders(), true);
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
);
}
/**
* Create request for operation 'get'
*
* @param string $ccsInstanceId 子部门ID,不传为默认部门 (optional)
* @param int $id 文章ID (optional)
* @param CustomizedParams $customizedParams
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
public function getRequest($ccsInstanceId = null, $id = null, CustomizedParams $customizedParams = null)
{
$resourcePath = '/v3/alipay/iservice/ccm/sw/article/get';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
$signContent = '';
$isEncrypt = $this->alipayConfigUtil->isEncrypt();
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$ccsInstanceId,
'ccs_instance_id', // param base name
'string', // openApiType
'form', // style
true, // explode
false // required
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$id,
'id', // param base name
'integer', // openApiType
'form', // style
true, // explode
false // required
) ?? []);
$headers = $this->headerSelector->selectHeaders(
['application/json'],
[]
);
if ($headers['Content-Type'] === 'multipart/form-data') {
$multipart = true;
unset($headers['Content-Type']);
}
// for model (json/xml)
if (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
if (is_string($formParamValueItem)) {
$signContent = $formParamValueItem;
}
//加密时非文件字段对应的Content-Type类型为text/plain
if ($isEncrypt && is_string($formParamValueItem)) {
$signContent = $this->alipayConfigUtil->encrypt($formParamValueItem, $headers, true);
$multipartContents[] = [
'name' => $formParamName,
'contents' => $signContent,
'headers' => ['Content-Type' => 'text/plain']
];
} else {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
'headers' => ['Content-Type' => 'application/json']
];
}
}
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$signContent = $this->alipayConfigUtil->encrypt(\GuzzleHttp\json_encode($formParams, JSON_UNESCAPED_UNICODE), $headers);
$httpBody = $signContent;
} else {
// for HTTP post (form)
$signContent = $this->alipayConfigUtil->encrypt(ObjectSerializer::buildQuery($formParams), $headers);
$httpBody = $signContent;
}
}
if ($isEncrypt) {
$headers['alipay-encrypt-type'] = $this->alipayConfigUtil->getEncryptType();
//除文件上传接口,加密后Content-Type均为"text/plain"
if (!$multipart) {
$headers['Content-Type'] = 'text/plain';
}
}
if ($customizedParams != null) {
//额外query参数
if (is_array($customizedParams->getQueryParams()) && count($customizedParams->getQueryParams()) >= 0) {
foreach ($customizedParams->getQueryParams() as $k => $v) {
if (is_array($v)) {
$v = ObjectSerializer::serializeCollection($v, 'form');
}
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue($v, $k) ?? []);
}
}
if (!$this->alipayConfigUtil->checkEmpty($customizedParams->getAppAuthToken())) {
$headerParams["alipay-app-auth-token"] = $customizedParams->getAppAuthToken();
}
//额外非全局header参数
if (is_array($customizedParams->getHeaderParams()) && count($customizedParams->getHeaderParams()) >= 0) {
foreach ($customizedParams->getHeaderParams() as $k => $v) {
if (is_array($v)) {
$v = ObjectSerializer::serializeCollection($v, 'form');
}
$headerParams[$k] = ObjectSerializer::toHeaderValue($v);
}
}
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
if ($this->config->getSdkVersion()) {
$defaultHeaders['alipay-sdk-version'] = $this->config->getSdkVersion();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
if (!array_key_exists('alipay-request-id', $headers)) {
$headers['alipay-request-id'] = $this->alipayConfigUtil->createUuid();
}
$query = ObjectSerializer::buildQuery($queryParams);
$url = $resourcePath . ($query ? "?{$query}" : '');
//加签
$this->alipayConfigUtil->sign('GET', $url, $signContent, $headers);
$basePath = $this->alipayConfigUtil->checkEmpty($this->alipayConfigUtil->getServerUrl()) ? $this->config->getHost() : $this->alipayConfigUtil->getServerUrl();
AlipayLogger::logBizInfo($basePath . $url, $signContent, 'GET', $multipart ? "multipart/form-data" : $headers['Content-Type'], $headers['alipay-request-id']);
return new Request(
'GET',
$basePath . $url,
$headers,
$httpBody
);
}
/**
* Operation modify
*
* 知识库-问答-修改
*
* @param \Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleModifyModel $alipayIserviceCcmSwArticleModifyModel alipayIserviceCcmSwArticleModifyModel (optional)
* @param CustomizedParams $customizedParams
*
* @throws \Alipay\OpenAPISDK\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return object|\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleModifyDefaultResponse
*/
public function modify($alipayIserviceCcmSwArticleModifyModel = null, CustomizedParams $customizedParams = null)
{
list($response) = $this->modifyWithHttpInfo($alipayIserviceCcmSwArticleModifyModel, $customizedParams);
return $response;
}
/**
* Operation modifyWithHttpInfo
*
* 知识库-问答-修改
*
* @param \Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleModifyModel $alipayIserviceCcmSwArticleModifyModel (optional)
* @param CustomizedParams $customizedParams
*
* @throws \Alipay\OpenAPISDK\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of object|\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleModifyDefaultResponse, HTTP status code, HTTP response headers (array of strings)
*/
public function modifyWithHttpInfo($alipayIserviceCcmSwArticleModifyModel = null, CustomizedParams $customizedParams = null)
{
$request = $this->modifyRequest($alipayIserviceCcmSwArticleModifyModel, $customizedParams);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
if ($e->getResponse()) {
//验签
$this->alipayConfigUtil->verifyResponse((string)$e->getResponse()->getBody(),
$e->getResponse()->getHeaders(), true);
}
AlipayLogger::logBizError("code:{$e->getCode()}, message:{$e->getMessage()}");
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
);
} catch (ConnectException $e) {
AlipayLogger::logBizError("code:{$e->getCode()}, message:{$e->getMessage()}");
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
null,
null
);
}
$statusCode = $response->getStatusCode();
if ($statusCode < 200 || $statusCode > 299) {
//验签
$bodyStr = (string)$response->getBody();
$this->alipayConfigUtil->verifyResponse($bodyStr, $response->getHeaders(), true);
AlipayLogger::logBizError("code:{$statusCode}, message:{$bodyStr}");
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
$bodyStr
);
}
switch($statusCode) {
case 200:
if ('object' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
//验签
$this->alipayConfigUtil->verifyResponse($content, $response->getHeaders(), false);
//解密
$content = $this->alipayConfigUtil->decrypt($content);
if ('object' !== 'string') {
$content = json_decode($content);
}
}
AlipayLogger::logBizResponseInfo($response->getStatusCode(), $content, $response->getHeaders());
return [
ObjectSerializer::deserialize($content, 'object', []),
$response->getStatusCode(),
$response->getHeaders()
];
default:
if ('\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleModifyDefaultResponse' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
//验签
$this->alipayConfigUtil->verifyResponse($content, $response->getHeaders(), true);
if ('\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleModifyDefaultResponse' !== 'string') {
$content = json_decode($content);
}
}
AlipayLogger::logBizResponseInfo($response->getStatusCode(), $content, $response->getHeaders());
return [
//ObjectSerializer::deserialize($content, '\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleModifyDefaultResponse', []),
$content,
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = 'object';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
//验签
$this->alipayConfigUtil->verifyResponse($content, $response->getHeaders(), false);
//解密
$content = $this->alipayConfigUtil->decrypt($content);
if ($returnType !== 'string') {
$content = json_decode($content);
}
}
AlipayLogger::logBizResponseInfo($response->getStatusCode(), $content, $response->getHeaders());
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'object',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
default:
//$data = ObjectSerializer::deserialize(
// $e->getResponseBody(),
// '\Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleModifyDefaultResponse',
// $e->getResponseHeaders()
//);
//$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation modifyAsync
*
* 知识库-问答-修改
*
* @param \Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleModifyModel $alipayIserviceCcmSwArticleModifyModel (optional)
* @param CustomizedParams $customizedParams
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
* @deprecated
*/
public function modifyAsync($alipayIserviceCcmSwArticleModifyModel = null, CustomizedParams $customizedParams = null)
{
return $this->modifyAsyncWithHttpInfo($alipayIserviceCcmSwArticleModifyModel, $customizedParams)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation modifyAsyncWithHttpInfo
*
* 知识库-问答-修改
*
* @param \Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleModifyModel $alipayIserviceCcmSwArticleModifyModel (optional)
* @param CustomizedParams $customizedParams
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
* @deprecated
*/
public function modifyAsyncWithHttpInfo($alipayIserviceCcmSwArticleModifyModel = null, CustomizedParams $customizedParams = null)
{
$returnType = 'object';
$request = $this->modifyRequest($alipayIserviceCcmSwArticleModifyModel, $customizedParams);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
//验签
$this->alipayConfigUtil->verifyResponse($content, $response->getHeaders(), false);
//解密
$content = $this->alipayConfigUtil->decrypt($content);
if ($returnType !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
//验签
$this->alipayConfigUtil->verifyResponse((string)$response->getBody(), $response->getHeaders(), true);
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
);
}
/**
* Create request for operation 'modify'
*
* @param \Alipay\OpenAPISDK\Model\AlipayIserviceCcmSwArticleModifyModel $alipayIserviceCcmSwArticleModifyModel (optional)
* @param CustomizedParams $customizedParams
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
public function modifyRequest($alipayIserviceCcmSwArticleModifyModel = null, CustomizedParams $customizedParams = null)
{
$resourcePath = '/v3/alipay/iservice/ccm/sw/article/modify';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
$signContent = '';
$isEncrypt = $this->alipayConfigUtil->isEncrypt();
$headers = $this->headerSelector->selectHeaders(
['application/json'],
['application/json']
);
if ($headers['Content-Type'] === 'multipart/form-data') {
$multipart = true;
unset($headers['Content-Type']);
}
// for model (json/xml)
//自定义body内容
if (($customizedParams != null && !$this->getAlipayConfigUtil()->checkEmpty($customizedParams->getBodyContent()))
&& ($headers['Content-Type'] === 'application/json' || $isEncrypt)) {
$signContent = $this->alipayConfigUtil->encrypt($customizedParams->getBodyContent(), $headers, $multipart);
$httpBody = $signContent;
} elseif (isset($alipayIserviceCcmSwArticleModifyModel)) {
$signContent = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($alipayIserviceCcmSwArticleModifyModel), JSON_UNESCAPED_UNICODE);
if ($headers['Content-Type'] === 'application/json' || $isEncrypt) {
$signContent = $this->alipayConfigUtil->encrypt($signContent, $headers, $multipart);
$httpBody = $signContent;
} else {
$httpBody = $alipayIserviceCcmSwArticleModifyModel;
}
} elseif (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
if (is_string($formParamValueItem)) {
$signContent = $formParamValueItem;
}
//加密时非文件字段对应的Content-Type类型为text/plain
if ($isEncrypt && is_string($formParamValueItem)) {
$signContent = $this->alipayConfigUtil->encrypt($formParamValueItem, $headers, true);
$multipartContents[] = [
'name' => $formParamName,
'contents' => $signContent,
'headers' => ['Content-Type' => 'text/plain']
];
} else {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
'headers' => ['Content-Type' => 'application/json']
];
}
}
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ($headers['Content-Type'] === 'application/json') {
$signContent = $this->alipayConfigUtil->encrypt(\GuzzleHttp\json_encode($formParams, JSON_UNESCAPED_UNICODE), $headers);
$httpBody = $signContent;
} else {
// for HTTP post (form)
$signContent = $this->alipayConfigUtil->encrypt(ObjectSerializer::buildQuery($formParams), $headers);
$httpBody = $signContent;
}
}
if ($isEncrypt) {
$headers['alipay-encrypt-type'] = $this->alipayConfigUtil->getEncryptType();
//除文件上传接口,加密后Content-Type均为"text/plain"
if (!$multipart) {
$headers['Content-Type'] = 'text/plain';
}
}
if ($customizedParams != null) {
//额外query参数
if (is_array($customizedParams->getQueryParams()) && count($customizedParams->getQueryParams()) >= 0) {
foreach ($customizedParams->getQueryParams() as $k => $v) {
if (is_array($v)) {
$v = ObjectSerializer::serializeCollection($v, 'form');
}
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue($v, $k) ?? []);
}
}
if (!$this->alipayConfigUtil->checkEmpty($customizedParams->getAppAuthToken())) {
$headerParams["alipay-app-auth-token"] = $customizedParams->getAppAuthToken();
}
//额外非全局header参数
if (is_array($customizedParams->getHeaderParams()) && count($customizedParams->getHeaderParams()) >= 0) {
foreach ($customizedParams->getHeaderParams() as $k => $v) {
if (is_array($v)) {
$v = ObjectSerializer::serializeCollection($v, 'form');
}
$headerParams[$k] = ObjectSerializer::toHeaderValue($v);
}
}
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
if ($this->config->getSdkVersion()) {
$defaultHeaders['alipay-sdk-version'] = $this->config->getSdkVersion();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
if (!array_key_exists('alipay-request-id', $headers)) {
$headers['alipay-request-id'] = $this->alipayConfigUtil->createUuid();
}
$query = ObjectSerializer::buildQuery($queryParams);
$url = $resourcePath . ($query ? "?{$query}" : '');
//加签
$this->alipayConfigUtil->sign('PATCH', $url, $signContent, $headers);
$basePath = $this->alipayConfigUtil->checkEmpty($this->alipayConfigUtil->getServerUrl()) ? $this->config->getHost() : $this->alipayConfigUtil->getServerUrl();
AlipayLogger::logBizInfo($basePath . $url, $signContent, 'PATCH', $multipart ? "multipart/form-data" : $headers['Content-Type'], $headers['alipay-request-id']);
return new Request(
'PATCH',
$basePath . $url,
$headers,
$httpBody
);
}
/**
* Create http client option
*
* @throws \RuntimeException on file opening failure
* @return array of http client options
*/
protected function createHttpClientOption()
{
$options = [];
if ($this->config->getDebug()) {
$options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
if (!$options[RequestOptions::DEBUG]) {
throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile());
}
}
return $options;
}
}