Skip to content

Commit 5c03b39

Browse files
committed
Update API DocOcrMax: add request parameters Authorize.
1 parent 3e8a633 commit 5c03b39

File tree

3 files changed

+114
-39
lines changed

3 files changed

+114
-39
lines changed

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2025-11-28 Version: 3.15.2
2+
- Update API DocOcrMax: add request parameters Authorize.
3+
4+
15
2025-10-17 Version: 3.15.1
26
- Update API DocOcrMax: add request parameters OcrValueStandard.
37

src/Cloudauthintl.php

Lines changed: 96 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
namespace AlibabaCloud\SDK\Cloudauthintl\V20220809;
66

77
use AlibabaCloud\Dara\Dara;
8+
use AlibabaCloud\Dara\Exception\DaraException;
9+
use AlibabaCloud\Dara\Exception\DaraUnableRetryException;
810
use AlibabaCloud\Dara\Models\FileField;
911
use AlibabaCloud\Dara\Models\RuntimeOptions;
1012
use AlibabaCloud\Dara\Request;
13+
use AlibabaCloud\Dara\RetryPolicy\RetryPolicyContext;
1114
use AlibabaCloud\Dara\Util\FormUtil;
1215
use AlibabaCloud\Dara\Util\StreamUtil;
1316
use AlibabaCloud\Dara\Util\XML;
@@ -105,48 +108,98 @@ public function __construct($config)
105108
}
106109

107110
/**
108-
* @param string $bucketName
109-
* @param mixed[] $form
111+
* @param string $bucketName
112+
* @param mixed[] $form
113+
* @param RuntimeOptions $runtime
110114
*
111115
* @return mixed[]
112116
*/
113-
public function _postOSSObject($bucketName, $form)
114-
{
115-
$_request = new Request();
116-
$boundary = FormUtil::getBoundary();
117-
$_request->protocol = 'HTTPS';
118-
$_request->method = 'POST';
119-
$_request->pathname = '/';
120-
$_request->headers = [
121-
'host' => '' . @$form['host'],
122-
'date' => Utils::getDateUTCString(),
123-
'user-agent' => Utils::getUserAgent(''),
117+
public function _postOSSObject($bucketName, $form, $runtime)
118+
{
119+
$_runtime = [
120+
'key' => '' . ($runtime->key ?: $this->_key),
121+
'cert' => '' . ($runtime->cert ?: $this->_cert),
122+
'ca' => '' . ($runtime->ca ?: $this->_ca),
123+
'readTimeout' => (($runtime->readTimeout ?: $this->_readTimeout) + 0),
124+
'connectTimeout' => (($runtime->connectTimeout ?: $this->_connectTimeout) + 0),
125+
'httpProxy' => '' . ($runtime->httpProxy ?: $this->_httpProxy),
126+
'httpsProxy' => '' . ($runtime->httpsProxy ?: $this->_httpsProxy),
127+
'noProxy' => '' . ($runtime->noProxy ?: $this->_noProxy),
128+
'socks5Proxy' => '' . ($runtime->socks5Proxy ?: $this->_socks5Proxy),
129+
'socks5NetWork' => '' . ($runtime->socks5NetWork ?: $this->_socks5NetWork),
130+
'maxIdleConns' => (($runtime->maxIdleConns ?: $this->_maxIdleConns) + 0),
131+
'retryOptions' => $this->_retryOptions,
132+
'ignoreSSL' => (bool) (($runtime->ignoreSSL ?: false)),
133+
'tlsMinVersion' => $this->_tlsMinVersion,
124134
];
125-
@$_request->headers['content-type'] = 'multipart/form-data; boundary=' . $boundary . '';
126-
$_request->body = FormUtil::toFileForm($form, $boundary);
127-
$_response = Dara::send($_request);
128-
129-
$respMap = null;
130-
$bodyStr = StreamUtil::readAsString($_response->body);
131-
if (($_response->statusCode >= 400) && ($_response->statusCode < 600)) {
132-
$respMap = XML::parseXml($bodyStr, null);
133-
$err = @$respMap['Error'];
134-
135-
throw new ClientException([
136-
'code' => '' . @$err['Code'],
137-
'message' => '' . @$err['Message'],
138-
'data' => [
139-
'httpCode' => $_response->statusCode,
140-
'requestId' => '' . @$err['RequestId'],
141-
'hostId' => '' . @$err['HostId'],
142-
],
143-
]);
144-
}
145-
146-
$respMap = XML::parseXml($bodyStr, null);
147135

148-
return Dara::merge([
149-
], $respMap);
136+
$_retriesAttempted = 0;
137+
$_lastRequest = null;
138+
$_lastResponse = null;
139+
$_context = new RetryPolicyContext([
140+
'retriesAttempted' => $_retriesAttempted,
141+
]);
142+
while (Dara::shouldRetry($_runtime['retryOptions'], $_context)) {
143+
if ($_retriesAttempted > 0) {
144+
$_backoffTime = Dara::getBackoffDelay($_runtime['retryOptions'], $_context);
145+
if ($_backoffTime > 0) {
146+
Dara::sleep($_backoffTime);
147+
}
148+
}
149+
150+
++$_retriesAttempted;
151+
152+
try {
153+
$_request = new Request();
154+
$boundary = FormUtil::getBoundary();
155+
$_request->protocol = 'HTTPS';
156+
$_request->method = 'POST';
157+
$_request->pathname = '/';
158+
$_request->headers = [
159+
'host' => '' . @$form['host'],
160+
'date' => Utils::getDateUTCString(),
161+
'user-agent' => Utils::getUserAgent(''),
162+
];
163+
@$_request->headers['content-type'] = 'multipart/form-data; boundary=' . $boundary . '';
164+
$_request->body = FormUtil::toFileForm($form, $boundary);
165+
$_lastRequest = $_request;
166+
$_response = Dara::send($_request, $_runtime);
167+
$_lastResponse = $_response;
168+
169+
$respMap = null;
170+
$bodyStr = StreamUtil::readAsString($_response->body);
171+
if (($_response->statusCode >= 400) && ($_response->statusCode < 600)) {
172+
$respMap = XML::parseXml($bodyStr, null);
173+
$err = @$respMap['Error'];
174+
175+
throw new ClientException([
176+
'code' => '' . @$err['Code'],
177+
'message' => '' . @$err['Message'],
178+
'data' => [
179+
'httpCode' => $_response->statusCode,
180+
'requestId' => '' . @$err['RequestId'],
181+
'hostId' => '' . @$err['HostId'],
182+
],
183+
]);
184+
}
185+
186+
$respMap = XML::parseXml($bodyStr, null);
187+
188+
return Dara::merge([
189+
], $respMap);
190+
} catch (DaraException $e) {
191+
$_context = new RetryPolicyContext([
192+
'retriesAttempted' => $_retriesAttempted,
193+
'lastRequest' => $_lastRequest,
194+
'lastResponse' => $_lastResponse,
195+
'exception' => $e,
196+
]);
197+
198+
continue;
199+
}
200+
}
201+
202+
throw new DaraUnableRetryException($_context);
150203
}
151204

152205
/**
@@ -1160,7 +1213,7 @@ public function credentialVerifyIntlAdvance($request, $runtime)
11601213
'file' => $fileObj,
11611214
'success_action_status' => '201',
11621215
];
1163-
$this->_postOSSObject(@$authResponseBody['Bucket'], $ossHeader);
1216+
$this->_postOSSObject(@$authResponseBody['Bucket'], $ossHeader, $runtime);
11641217
$credentialVerifyIntlReq->imageFile = 'http://' . @$authResponseBody['Bucket'] . '.' . @$authResponseBody['Endpoint'] . '/' . @$authResponseBody['ObjectKey'] . '';
11651218
}
11661219

@@ -1424,7 +1477,7 @@ public function deepfakeDetectIntlStreamAdvance($request, $runtime)
14241477
'file' => $fileObj,
14251478
'success_action_status' => '201',
14261479
];
1427-
$this->_postOSSObject(@$authResponseBody['Bucket'], $ossHeader);
1480+
$this->_postOSSObject(@$authResponseBody['Bucket'], $ossHeader, $runtime);
14281481
$deepfakeDetectIntlStreamReq->faceFile = 'http://' . @$authResponseBody['Bucket'] . '.' . @$authResponseBody['Endpoint'] . '/' . @$authResponseBody['ObjectKey'] . '';
14291482
}
14301483

@@ -1731,6 +1784,10 @@ public function docOcrMaxWithOptions($request, $runtime)
17311784
}
17321785

17331786
$body = [];
1787+
if (null !== $request->authorize) {
1788+
@$body['Authorize'] = $request->authorize;
1789+
}
1790+
17341791
if (null !== $request->docPage) {
17351792
@$body['DocPage'] = $request->docPage;
17361793
}

src/Models/DocOcrMaxRequest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99
class DocOcrMaxRequest extends Model
1010
{
11+
/**
12+
* @var string
13+
*/
14+
public $authorize;
15+
1116
/**
1217
* @var string
1318
*/
@@ -78,6 +83,7 @@ class DocOcrMaxRequest extends Model
7883
*/
7984
public $spoof;
8085
protected $_name = [
86+
'authorize' => 'Authorize',
8187
'docPage' => 'DocPage',
8288
'docType' => 'DocType',
8389
'idOcrPictureBase64' => 'IdOcrPictureBase64',
@@ -102,6 +108,10 @@ public function validate()
102108
public function toArray($noStream = false)
103109
{
104110
$res = [];
111+
if (null !== $this->authorize) {
112+
$res['Authorize'] = $this->authorize;
113+
}
114+
105115
if (null !== $this->docPage) {
106116
$res['DocPage'] = $this->docPage;
107117
}
@@ -169,6 +179,10 @@ public function toMap($noStream = false)
169179
public static function fromMap($map = [])
170180
{
171181
$model = new self();
182+
if (isset($map['Authorize'])) {
183+
$model->authorize = $map['Authorize'];
184+
}
185+
172186
if (isset($map['DocPage'])) {
173187
$model->docPage = $map['DocPage'];
174188
}

0 commit comments

Comments
 (0)