Skip to content

Commit eb08ca3

Browse files
committed
chore: SDK update
1 parent 1a363fe commit eb08ca3

232 files changed

Lines changed: 31826 additions & 277 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.php-cs-fixer.dist.phpe

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/**
4+
* @generated
5+
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/HEAD/doc/config.rst
6+
*/
7+
$finder = PhpCsFixer\Finder::create()
8+
->in(__DIR__)
9+
->exclude('vendor')
10+
->exclude('test')
11+
->exclude('tests')
12+
;
13+
14+
$config = new PhpCsFixer\Config();
15+
return $config->setRules([
16+
'@PSR12' => true,
17+
'phpdoc_order' => true,
18+
'array_syntax' => [ 'syntax' => 'short' ],
19+
'strict_comparison' => true,
20+
'strict_param' => true,
21+
'no_trailing_whitespace' => false,
22+
'no_trailing_whitespace_in_comment' => false,
23+
'braces' => false,
24+
'single_blank_line_at_eof' => false,
25+
'blank_line_after_namespace' => false,
26+
'no_leading_import_slash' => false,
27+
])
28+
->setFinder($finder)
29+
;

src/Api/BillingCatalogApi.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ protected function getCatalogItemListV1Request(): Request
108108
return $this->buildRequest('GET', $resourcePath, $body, $query);
109109
}
110110

111-
112111
/**
113112
* @return array<string, mixed>
114113
*/

src/Api/BillingCatalogApi.phpe

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
<?php
2+
3+
/**
4+
* Hostinger API PHP SDK
5+
*
6+
* API Version: 0.0.1-beta
7+
* @url https://github.com/hostinger/api-php-sdk
8+
*
9+
* NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
10+
* If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
11+
*/
12+
13+
namespace Hostinger\Api;
14+
15+
use InvalidArgumentException;
16+
use GuzzleHttp\Client;
17+
use GuzzleHttp\ClientInterface;
18+
use GuzzleHttp\Exception\ConnectException;
19+
use GuzzleHttp\Exception\GuzzleException;
20+
use GuzzleHttp\Exception\RequestException;
21+
use GuzzleHttp\Psr7\Request;
22+
use GuzzleHttp\RequestOptions;
23+
use Hostinger\ApiException;
24+
use Hostinger\Configuration;
25+
use Hostinger\HeaderSelector;
26+
use Hostinger\ObjectSerializer;
27+
28+
class BillingCatalogApi
29+
{
30+
protected ClientInterface $client;
31+
32+
protected Configuration $config;
33+
34+
protected HeaderSelector $headerSelector;
35+
36+
public function __construct(
37+
?ClientInterface $client = null,
38+
?Configuration $config = null,
39+
?HeaderSelector $selector = null,
40+
) {
41+
$this->client = $client ?: new Client();
42+
$this->config = $config ?: Configuration::getDefaultConfiguration();
43+
$this->headerSelector = $selector ?: new HeaderSelector();
44+
}
45+
46+
public function getConfig(): Configuration
47+
{
48+
return $this->config;
49+
}
50+
51+
/**
52+
* Operation getCatalogItemListV1
53+
*
54+
* Get catalog item list
55+
*
56+
* @return \Hostinger\Model\BillingV1CatalogCatalogItemResource[]|\Hostinger\Model\CommonSchemaUnauthorizedResponseSchema|\Hostinger\Model\CommonSchemaErrorResponseSchema
57+
* @throws ApiException on non-2xx response or if the response body is not in the expected format
58+
* @throws InvalidArgumentException
59+
* @throws GuzzleException
60+
*/
61+
public function getCatalogItemListV1(): array|\Hostinger\Model\CommonSchemaUnauthorizedResponseSchema|\Hostinger\Model\CommonSchemaErrorResponseSchema
62+
{
63+
$request = $this->getCatalogItemListV1Request();
64+
65+
try {
66+
$response = $this->client->send($request, $this->createHttpClientOption());
67+
} catch (RequestException $e) {
68+
if ($this->config->shouldThrowException()) {
69+
throw ApiException::fromRequestException($e);
70+
} else {
71+
$response = $e->getResponse();
72+
}
73+
} catch (ConnectException $e) {
74+
throw ApiException::fromConnectException($e);
75+
}
76+
77+
$statusCode = $response->getStatusCode();
78+
$returnType = null;
79+
$content = \GuzzleHttp\Utils::jsonDecode((string) $response->getBody(), false, 512, JSON_THROW_ON_ERROR);
80+
81+
switch ($statusCode) {
82+
case 200:
83+
$returnType = '\Hostinger\Model\BillingV1CatalogCatalogItemResource[]';
84+
break;
85+
case 401:
86+
$returnType = '\Hostinger\Model\CommonSchemaUnauthorizedResponseSchema';
87+
break;
88+
case 500:
89+
$returnType = '\Hostinger\Model\CommonSchemaErrorResponseSchema';
90+
break;
91+
}
92+
93+
return ObjectSerializer::deserialize($content, $returnType);
94+
}
95+
96+
/**
97+
* Create request for operation 'getCatalogItemListV1'
98+
*
99+
* @throws InvalidArgumentException
100+
*/
101+
protected function getCatalogItemListV1Request(): Request
102+
{
103+
$resourcePath = '/api/billing/v1/catalog';
104+
105+
$body = null;
106+
$query = [];
107+
108+
return $this->buildRequest('GET', $resourcePath, $body, $query);
109+
}
110+
111+
112+
/**
113+
* @return array<string, mixed>
114+
*/
115+
protected function createHttpClientOption(): array
116+
{
117+
$options = [];
118+
if ($this->config->getDebug()) {
119+
$options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
120+
if (!$options[RequestOptions::DEBUG]) {
121+
throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile());
122+
}
123+
}
124+
125+
return $options;
126+
}
127+
128+
/**
129+
* @param array<string, string> $query
130+
*/
131+
protected function buildRequest(
132+
string $httpMethod,
133+
string $resourcePath,
134+
?string $body = null,
135+
array $query = [],
136+
string $contentType = 'application/json',
137+
): Request {
138+
$headers = $this->headerSelector->selectHeaders(
139+
accept: ['application/json'],
140+
contentType: $contentType,
141+
isMultipart: false
142+
);
143+
144+
// this endpoint requires Bearer authentication (access token)
145+
if (!empty($this->config->getAccessToken())) {
146+
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
147+
}
148+
149+
$query = ObjectSerializer::buildQuery($query);
150+
151+
return new Request(
152+
$httpMethod,
153+
$this->config->getHost() . $resourcePath . ($query ? "?$query" : ''),
154+
$headers,
155+
$body
156+
);
157+
}
158+
}

src/Api/BillingOrdersApi.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,12 @@ protected function createNewServiceOrderV1Request(\Hostinger\Model\BillingV1Orde
105105
{
106106
$resourcePath = '/api/billing/v1/orders';
107107

108-
109-
110108
$body = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($billingV1OrderStoreRequest));
111109
$query = [];
112110

113111
return $this->buildRequest('POST', $resourcePath, $body, $query);
114112
}
115113

116-
117114
/**
118115
* @return array<string, mixed>
119116
*/

src/Api/BillingOrdersApi.phpe

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
<?php
2+
3+
/**
4+
* Hostinger API PHP SDK
5+
*
6+
* API Version: 0.0.1-beta
7+
* @url https://github.com/hostinger/api-php-sdk
8+
*
9+
* NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
10+
* If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
11+
*/
12+
13+
namespace Hostinger\Api;
14+
15+
use InvalidArgumentException;
16+
use GuzzleHttp\Client;
17+
use GuzzleHttp\ClientInterface;
18+
use GuzzleHttp\Exception\ConnectException;
19+
use GuzzleHttp\Exception\GuzzleException;
20+
use GuzzleHttp\Exception\RequestException;
21+
use GuzzleHttp\Psr7\Request;
22+
use GuzzleHttp\RequestOptions;
23+
use Hostinger\ApiException;
24+
use Hostinger\Configuration;
25+
use Hostinger\HeaderSelector;
26+
use Hostinger\ObjectSerializer;
27+
28+
class BillingOrdersApi
29+
{
30+
protected ClientInterface $client;
31+
32+
protected Configuration $config;
33+
34+
protected HeaderSelector $headerSelector;
35+
36+
public function __construct(
37+
?ClientInterface $client = null,
38+
?Configuration $config = null,
39+
?HeaderSelector $selector = null,
40+
) {
41+
$this->client = $client ?: new Client();
42+
$this->config = $config ?: Configuration::getDefaultConfiguration();
43+
$this->headerSelector = $selector ?: new HeaderSelector();
44+
}
45+
46+
public function getConfig(): Configuration
47+
{
48+
return $this->config;
49+
}
50+
51+
/**
52+
* Operation createNewServiceOrderV1
53+
*
54+
* Create new service order
55+
*
56+
* @return \Hostinger\Model\BillingV1OrderOrderResource|\Hostinger\Model\CommonSchemaUnprocessableContentResponseSchema|\Hostinger\Model\CommonSchemaUnauthorizedResponseSchema|\Hostinger\Model\CommonSchemaErrorResponseSchema
57+
* @throws ApiException on non-2xx response or if the response body is not in the expected format
58+
* @throws InvalidArgumentException
59+
* @throws GuzzleException
60+
*/
61+
public function createNewServiceOrderV1(\Hostinger\Model\BillingV1OrderStoreRequest $billingV1OrderStoreRequest, ): \Hostinger\Model\BillingV1OrderOrderResource|\Hostinger\Model\CommonSchemaUnprocessableContentResponseSchema|\Hostinger\Model\CommonSchemaUnauthorizedResponseSchema|\Hostinger\Model\CommonSchemaErrorResponseSchema
62+
{
63+
$request = $this->createNewServiceOrderV1Request($billingV1OrderStoreRequest, );
64+
65+
try {
66+
$response = $this->client->send($request, $this->createHttpClientOption());
67+
} catch (RequestException $e) {
68+
if ($this->config->shouldThrowException()) {
69+
throw ApiException::fromRequestException($e);
70+
} else {
71+
$response = $e->getResponse();
72+
}
73+
} catch (ConnectException $e) {
74+
throw ApiException::fromConnectException($e);
75+
}
76+
77+
$statusCode = $response->getStatusCode();
78+
$returnType = null;
79+
$content = \GuzzleHttp\Utils::jsonDecode((string) $response->getBody(), false, 512, JSON_THROW_ON_ERROR);
80+
81+
switch ($statusCode) {
82+
case 200:
83+
$returnType = '\Hostinger\Model\BillingV1OrderOrderResource';
84+
break;
85+
case 422:
86+
$returnType = '\Hostinger\Model\CommonSchemaUnprocessableContentResponseSchema';
87+
break;
88+
case 401:
89+
$returnType = '\Hostinger\Model\CommonSchemaUnauthorizedResponseSchema';
90+
break;
91+
case 500:
92+
$returnType = '\Hostinger\Model\CommonSchemaErrorResponseSchema';
93+
break;
94+
}
95+
96+
return ObjectSerializer::deserialize($content, $returnType);
97+
}
98+
99+
/**
100+
* Create request for operation 'createNewServiceOrderV1'
101+
*
102+
* @throws InvalidArgumentException
103+
*/
104+
protected function createNewServiceOrderV1Request(\Hostinger\Model\BillingV1OrderStoreRequest $billingV1OrderStoreRequest,): Request
105+
{
106+
$resourcePath = '/api/billing/v1/orders';
107+
108+
109+
110+
$body = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($billingV1OrderStoreRequest));
111+
$query = [];
112+
113+
return $this->buildRequest('POST', $resourcePath, $body, $query);
114+
}
115+
116+
117+
/**
118+
* @return array<string, mixed>
119+
*/
120+
protected function createHttpClientOption(): array
121+
{
122+
$options = [];
123+
if ($this->config->getDebug()) {
124+
$options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
125+
if (!$options[RequestOptions::DEBUG]) {
126+
throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile());
127+
}
128+
}
129+
130+
return $options;
131+
}
132+
133+
/**
134+
* @param array<string, string> $query
135+
*/
136+
protected function buildRequest(
137+
string $httpMethod,
138+
string $resourcePath,
139+
?string $body = null,
140+
array $query = [],
141+
string $contentType = 'application/json',
142+
): Request {
143+
$headers = $this->headerSelector->selectHeaders(
144+
accept: ['application/json'],
145+
contentType: $contentType,
146+
isMultipart: false
147+
);
148+
149+
// this endpoint requires Bearer authentication (access token)
150+
if (!empty($this->config->getAccessToken())) {
151+
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
152+
}
153+
154+
$query = ObjectSerializer::buildQuery($query);
155+
156+
return new Request(
157+
$httpMethod,
158+
$this->config->getHost() . $resourcePath . ($query ? "?$query" : ''),
159+
$headers,
160+
$body
161+
);
162+
}
163+
}

0 commit comments

Comments
 (0)