Skip to content

Commit ad19b45

Browse files
author
李严
committed
Merge branch 'billing-PHP-2022-01-01-online-323-2024_02_01_15_26_38' into 'master'
Billing php 2022 01 01 online 323 2024 02 01 15 26 38 See merge request iaasng/volcengine-php-sdk!63
2 parents 5421052 + a81b2e8 commit ad19b45

File tree

5 files changed

+3446
-2
lines changed

5 files changed

+3446
-2
lines changed

meta.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"lasted": "1.0.10",
3-
"meta_commit": "792376a0f440d9877dea58f9089a872539eb7204"
2+
"lasted": "1.0.11",
3+
"meta_commit": "25427c7684dff4d500db02f50d861d3a0c7278db"
44
}

src/Billing/Api/BILLINGApi.php

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,189 @@ public function getConfig()
5858
return $this->config;
5959
}
6060

61+
public function listAmortizedCostBillDaily($body)
62+
{
63+
list($response) = $this->listAmortizedCostBillDailyWithHttpInfo($body);
64+
return $response;
65+
}
66+
67+
public function listAmortizedCostBillDailyWithHttpInfo($body)
68+
{
69+
$returnType = '\Volcengine\Billing\Model\ListAmortizedCostBillDailyResponse';
70+
$request = $this->listAmortizedCostBillDailyRequest($body);
71+
72+
$options = $this->createHttpClientOption();
73+
try {
74+
$response = $this->client->send($request, $options);
75+
} catch (RequestException $e) {
76+
throw new ApiException(
77+
"[{$e->getCode()}] {$e->getMessage()}",
78+
$e->getCode(),
79+
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
80+
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
81+
);
82+
}
83+
84+
$statusCode = $response->getStatusCode();
85+
86+
if ($statusCode < 200 || $statusCode > 299) {
87+
throw new ApiException(
88+
sprintf(
89+
'[%d] Error connecting to the API (%s)',
90+
$statusCode,
91+
$request->getUri()
92+
),
93+
$statusCode,
94+
$response->getHeaders(),
95+
$response->getBody()
96+
);
97+
}
98+
99+
$responseContent = $response->getBody()->getContents();
100+
$content = json_decode($responseContent);
101+
102+
if (isset($content->{'ResponseMetadata'}->{'Error'})) {
103+
throw new ApiException(
104+
sprintf(
105+
'[%d] Return Error From the API (%s)',
106+
$statusCode,
107+
$request->getUri()
108+
),
109+
$statusCode,
110+
$response->getHeaders(),
111+
$responseContent);
112+
}
113+
$content = $content->{'Result'};
114+
115+
return [
116+
ObjectSerializer::deserialize($content, $returnType, []),
117+
$response->getStatusCode(),
118+
$response->getHeaders()
119+
];
120+
}
121+
122+
public function listAmortizedCostBillDailyAsync($body)
123+
{
124+
return $this->listAmortizedCostBillDailyAsyncWithHttpInfo($body)
125+
->then(
126+
function ($response) {
127+
return $response[0];
128+
}
129+
);
130+
}
131+
132+
public function listAmortizedCostBillDailyAsyncWithHttpInfo($body)
133+
{
134+
$returnType = '\Volcengine\Billing\Model\ListAmortizedCostBillDailyResponse';
135+
$request = $this->listAmortizedCostBillDailyRequest($body);
136+
$uri = $request->getUri();
137+
138+
return $this->client
139+
->sendAsync($request, $this->createHttpClientOption())
140+
->then(
141+
function ($response) use ($uri, $returnType) {
142+
$responseContent = $response->getBody()->getContents();
143+
$content = json_decode($responseContent);
144+
$statusCode = $response->getStatusCode();
145+
146+
if (isset($content->{'ResponseMetadata'}->{'Error'})) {
147+
throw new ApiException(
148+
sprintf(
149+
'[%d] Return Error From the API (%s)',
150+
$statusCode,
151+
$uri
152+
),
153+
$statusCode,
154+
$response->getHeaders(),
155+
$responseContent);
156+
}
157+
$content = $content->{'Result'};
158+
159+
return [
160+
ObjectSerializer::deserialize($content, $returnType, []),
161+
$response->getStatusCode(),
162+
$response->getHeaders()
163+
];
164+
},
165+
function ($exception) {
166+
$response = $exception->getResponse();
167+
$statusCode = $response->getStatusCode();
168+
throw new ApiException(
169+
sprintf(
170+
'[%d] Error connecting to the API (%s)',
171+
$statusCode,
172+
$exception->getRequest()->getUri()
173+
),
174+
$statusCode,
175+
$response->getHeaders(),
176+
$response->getBody()
177+
);
178+
}
179+
);
180+
}
181+
182+
protected function listAmortizedCostBillDailyRequest($body)
183+
{
184+
// verify the required parameter 'body' is set
185+
if ($body === null || (is_array($body) && count($body) === 0)) {
186+
throw new \InvalidArgumentException(
187+
'Missing the required parameter $body when calling listAmortizedCostBillDaily'
188+
);
189+
}
190+
191+
$resourcePath = '/ListAmortizedCostBillDaily/2022-01-01/billing/post/application_json/';
192+
$queryParams = [];
193+
$httpBody = $body;
194+
195+
$headers = $this->headerSelector->selectHeaders(
196+
['application/json'],
197+
['application/json']
198+
);
199+
200+
$defaultHeaders = [];
201+
if ($this->config->getUserAgent()) {
202+
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
203+
}
204+
if ($this->config->getHost()) {
205+
$defaultHeaders['Host'] = $this->config->getHost();
206+
}
207+
208+
$headers = array_merge(
209+
$defaultHeaders,
210+
$headers
211+
);
212+
213+
$paths = explode("/", $resourcePath);
214+
$service = $paths[3];
215+
$method = strtoupper($paths[4]);
216+
217+
// format request body
218+
if ($method == 'GET' && $headers['Content-Type'] === 'text/plain') {
219+
$queryParams = Utils::transRequest($httpBody);
220+
$httpBody = '';
221+
} else {
222+
$httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($body));
223+
}
224+
225+
$queryParams['Action'] = $paths[1];
226+
$queryParams['Version'] = $paths[2];
227+
$resourcePath = '/';
228+
229+
$query = '';
230+
ksort($queryParams); // sort query first
231+
foreach ($queryParams as $k => $v) {
232+
$query .= rawurlencode($k) . '=' . rawurlencode($v) . '&';
233+
}
234+
$query = substr($query, 0, -1);
235+
236+
$headers = Utils::signv4($this->config->getAk(), $this->config->getSk(), $this->config->getRegion(), $service,
237+
$httpBody, $query, $method, $resourcePath, $headers);
238+
239+
return new Request($method,
240+
'https://' . $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
241+
$headers, $httpBody);
242+
}
243+
61244
public function listAmortizedCostBillDetail($body)
62245
{
63246
list($response) = $this->listAmortizedCostBillDetailWithHttpInfo($body);

0 commit comments

Comments
 (0)