Skip to content

Commit

Permalink
Add sort order to project search
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianVennen committed Jan 8, 2024
1 parent ddb0225 commit 21a0e75
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 45 deletions.
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
invokerPackage: Aternos\HangarApi
artifactVersion: 3.1.1
artifactVersion: 3.2.0
generatorName: php
outputDir: .
sourceFolder: src
Expand Down
12 changes: 6 additions & 6 deletions lib/Api/APIKeysApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public function createKeyWithHttpInfo($create_api_key_form, string $contentType
}

switch($statusCode) {
case 201:
case 403:
if ('string' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
Expand All @@ -225,7 +225,7 @@ public function createKeyWithHttpInfo($create_api_key_form, string $contentType
$response->getStatusCode(),
$response->getHeaders()
];
case 403:
case 401:
if ('string' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
Expand All @@ -252,7 +252,7 @@ public function createKeyWithHttpInfo($create_api_key_form, string $contentType
$response->getStatusCode(),
$response->getHeaders()
];
case 401:
case 201:
if ('string' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
Expand Down Expand Up @@ -311,23 +311,23 @@ public function createKeyWithHttpInfo($create_api_key_form, string $contentType

} catch (ApiException $e) {
switch ($e->getCode()) {
case 201:
case 403:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'string',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 403:
case 401:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'string',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 401:
case 201:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'string',
Expand Down
20 changes: 10 additions & 10 deletions lib/Api/PermissionsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,8 @@ public function hasAllRequest($permissions, $slug = null, $organization = null,
* Checks whether you have at least one of the provided permissions
*
* @param \Aternos\HangarApi\Model\NamedPermission[] $permissions The permissions to check (required)
* @param string $slug The slug of the project to check permissions in. Must not be used together with `organizationName` (optional)
* @param string $organization The organization to check permissions in. Must not be used together with `projectOwner` and `projectSlug` (optional)
* @param string $slug The slug of the project to check permissions in. Must not be used together with `organization` (optional)
* @param string $organization The organization to check permissions in. Must not be used together with `slug` (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['hasAny'] to see the possible values for this operation
*
* @throws \Aternos\HangarApi\ApiException on non-2xx response or if the response body is not in the expected format
Expand All @@ -572,8 +572,8 @@ public function hasAny($permissions, $slug = null, $organization = null, string
* Checks whether you have at least one of the provided permissions
*
* @param \Aternos\HangarApi\Model\NamedPermission[] $permissions The permissions to check (required)
* @param string $slug The slug of the project to check permissions in. Must not be used together with `organizationName` (optional)
* @param string $organization The organization to check permissions in. Must not be used together with `projectOwner` and `projectSlug` (optional)
* @param string $slug The slug of the project to check permissions in. Must not be used together with `organization` (optional)
* @param string $organization The organization to check permissions in. Must not be used together with `slug` (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['hasAny'] to see the possible values for this operation
*
* @throws \Aternos\HangarApi\ApiException on non-2xx response or if the response body is not in the expected format
Expand Down Expand Up @@ -768,8 +768,8 @@ public function hasAnyWithHttpInfo($permissions, $slug = null, $organization = n
* Checks whether you have at least one of the provided permissions
*
* @param \Aternos\HangarApi\Model\NamedPermission[] $permissions The permissions to check (required)
* @param string $slug The slug of the project to check permissions in. Must not be used together with `organizationName` (optional)
* @param string $organization The organization to check permissions in. Must not be used together with `projectOwner` and `projectSlug` (optional)
* @param string $slug The slug of the project to check permissions in. Must not be used together with `organization` (optional)
* @param string $organization The organization to check permissions in. Must not be used together with `slug` (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['hasAny'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
Expand All @@ -791,8 +791,8 @@ function ($response) {
* Checks whether you have at least one of the provided permissions
*
* @param \Aternos\HangarApi\Model\NamedPermission[] $permissions The permissions to check (required)
* @param string $slug The slug of the project to check permissions in. Must not be used together with `organizationName` (optional)
* @param string $organization The organization to check permissions in. Must not be used together with `projectOwner` and `projectSlug` (optional)
* @param string $slug The slug of the project to check permissions in. Must not be used together with `organization` (optional)
* @param string $organization The organization to check permissions in. Must not be used together with `slug` (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['hasAny'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
Expand Down Expand Up @@ -843,8 +843,8 @@ function ($exception) {
* Create request for operation 'hasAny'
*
* @param \Aternos\HangarApi\Model\NamedPermission[] $permissions The permissions to check (required)
* @param string $slug The slug of the project to check permissions in. Must not be used together with `organizationName` (optional)
* @param string $organization The organization to check permissions in. Must not be used together with `projectOwner` and `projectSlug` (optional)
* @param string $slug The slug of the project to check permissions in. Must not be used together with `organization` (optional)
* @param string $organization The organization to check permissions in. Must not be used together with `slug` (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['hasAny'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
Expand Down
43 changes: 29 additions & 14 deletions lib/Api/ProjectsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -1735,7 +1735,8 @@ public function getProjectWatchersRequest($slug, $pagination, string $contentTyp
* @param string $category A category to filter for (optional)
* @param string $platform A platform to filter for (optional)
* @param string $owner The author of the project (optional)
* @param string $q The query to use when searching (optional)
* @param string $q Deprecated: Use 'query' instead (optional) (deprecated)
* @param string $query The query to use when searching (optional)
* @param string $license A license to filter for (optional)
* @param string $version A Minecraft version to filter for (optional)
* @param string $tag A tag to filter for (optional)
Expand All @@ -1745,9 +1746,9 @@ public function getProjectWatchersRequest($slug, $pagination, string $contentTyp
* @throws \InvalidArgumentException
* @return \Aternos\HangarApi\Model\PaginatedResultProject|\Aternos\HangarApi\Model\PaginatedResultProject|\Aternos\HangarApi\Model\PaginatedResultProject
*/
public function getProjects($pagination, $prioritize_exact_match = true, $sort = null, $category = null, $platform = null, $owner = null, $q = null, $license = null, $version = null, $tag = null, string $contentType = self::contentTypes['getProjects'][0])
public function getProjects($pagination, $prioritize_exact_match = true, $sort = null, $category = null, $platform = null, $owner = null, $q = null, $query = null, $license = null, $version = null, $tag = null, string $contentType = self::contentTypes['getProjects'][0])
{
list($response) = $this->getProjectsWithHttpInfo($pagination, $prioritize_exact_match, $sort, $category, $platform, $owner, $q, $license, $version, $tag, $contentType);
list($response) = $this->getProjectsWithHttpInfo($pagination, $prioritize_exact_match, $sort, $category, $platform, $owner, $q, $query, $license, $version, $tag, $contentType);
return $response;
}

Expand All @@ -1762,7 +1763,8 @@ public function getProjects($pagination, $prioritize_exact_match = true, $sort =
* @param string $category A category to filter for (optional)
* @param string $platform A platform to filter for (optional)
* @param string $owner The author of the project (optional)
* @param string $q The query to use when searching (optional)
* @param string $q Deprecated: Use 'query' instead (optional) (deprecated)
* @param string $query The query to use when searching (optional)
* @param string $license A license to filter for (optional)
* @param string $version A Minecraft version to filter for (optional)
* @param string $tag A tag to filter for (optional)
Expand All @@ -1772,9 +1774,9 @@ public function getProjects($pagination, $prioritize_exact_match = true, $sort =
* @throws \InvalidArgumentException
* @return array of \Aternos\HangarApi\Model\PaginatedResultProject|\Aternos\HangarApi\Model\PaginatedResultProject|\Aternos\HangarApi\Model\PaginatedResultProject, HTTP status code, HTTP response headers (array of strings)
*/
public function getProjectsWithHttpInfo($pagination, $prioritize_exact_match = true, $sort = null, $category = null, $platform = null, $owner = null, $q = null, $license = null, $version = null, $tag = null, string $contentType = self::contentTypes['getProjects'][0])
public function getProjectsWithHttpInfo($pagination, $prioritize_exact_match = true, $sort = null, $category = null, $platform = null, $owner = null, $q = null, $query = null, $license = null, $version = null, $tag = null, string $contentType = self::contentTypes['getProjects'][0])
{
$request = $this->getProjectsRequest($pagination, $prioritize_exact_match, $sort, $category, $platform, $owner, $q, $license, $version, $tag, $contentType);
$request = $this->getProjectsRequest($pagination, $prioritize_exact_match, $sort, $category, $platform, $owner, $q, $query, $license, $version, $tag, $contentType);

try {
$options = $this->createHttpClientOption();
Expand Down Expand Up @@ -1965,7 +1967,8 @@ public function getProjectsWithHttpInfo($pagination, $prioritize_exact_match = t
* @param string $category A category to filter for (optional)
* @param string $platform A platform to filter for (optional)
* @param string $owner The author of the project (optional)
* @param string $q The query to use when searching (optional)
* @param string $q Deprecated: Use 'query' instead (optional) (deprecated)
* @param string $query The query to use when searching (optional)
* @param string $license A license to filter for (optional)
* @param string $version A Minecraft version to filter for (optional)
* @param string $tag A tag to filter for (optional)
Expand All @@ -1974,9 +1977,9 @@ public function getProjectsWithHttpInfo($pagination, $prioritize_exact_match = t
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getProjectsAsync($pagination, $prioritize_exact_match = true, $sort = null, $category = null, $platform = null, $owner = null, $q = null, $license = null, $version = null, $tag = null, string $contentType = self::contentTypes['getProjects'][0])
public function getProjectsAsync($pagination, $prioritize_exact_match = true, $sort = null, $category = null, $platform = null, $owner = null, $q = null, $query = null, $license = null, $version = null, $tag = null, string $contentType = self::contentTypes['getProjects'][0])
{
return $this->getProjectsAsyncWithHttpInfo($pagination, $prioritize_exact_match, $sort, $category, $platform, $owner, $q, $license, $version, $tag, $contentType)
return $this->getProjectsAsyncWithHttpInfo($pagination, $prioritize_exact_match, $sort, $category, $platform, $owner, $q, $query, $license, $version, $tag, $contentType)
->then(
function ($response) {
return $response[0];
Expand All @@ -1995,7 +1998,8 @@ function ($response) {
* @param string $category A category to filter for (optional)
* @param string $platform A platform to filter for (optional)
* @param string $owner The author of the project (optional)
* @param string $q The query to use when searching (optional)
* @param string $q Deprecated: Use 'query' instead (optional) (deprecated)
* @param string $query The query to use when searching (optional)
* @param string $license A license to filter for (optional)
* @param string $version A Minecraft version to filter for (optional)
* @param string $tag A tag to filter for (optional)
Expand All @@ -2004,10 +2008,10 @@ function ($response) {
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function getProjectsAsyncWithHttpInfo($pagination, $prioritize_exact_match = true, $sort = null, $category = null, $platform = null, $owner = null, $q = null, $license = null, $version = null, $tag = null, string $contentType = self::contentTypes['getProjects'][0])
public function getProjectsAsyncWithHttpInfo($pagination, $prioritize_exact_match = true, $sort = null, $category = null, $platform = null, $owner = null, $q = null, $query = null, $license = null, $version = null, $tag = null, string $contentType = self::contentTypes['getProjects'][0])
{
$returnType = '\Aternos\HangarApi\Model\PaginatedResultProject';
$request = $this->getProjectsRequest($pagination, $prioritize_exact_match, $sort, $category, $platform, $owner, $q, $license, $version, $tag, $contentType);
$request = $this->getProjectsRequest($pagination, $prioritize_exact_match, $sort, $category, $platform, $owner, $q, $query, $license, $version, $tag, $contentType);

return $this->client
->sendAsync($request, $this->createHttpClientOption())
Expand Down Expand Up @@ -2054,7 +2058,8 @@ function ($exception) {
* @param string $category A category to filter for (optional)
* @param string $platform A platform to filter for (optional)
* @param string $owner The author of the project (optional)
* @param string $q The query to use when searching (optional)
* @param string $q Deprecated: Use 'query' instead (optional) (deprecated)
* @param string $query The query to use when searching (optional)
* @param string $license A license to filter for (optional)
* @param string $version A Minecraft version to filter for (optional)
* @param string $tag A tag to filter for (optional)
Expand All @@ -2063,7 +2068,7 @@ function ($exception) {
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
public function getProjectsRequest($pagination, $prioritize_exact_match = true, $sort = null, $category = null, $platform = null, $owner = null, $q = null, $license = null, $version = null, $tag = null, string $contentType = self::contentTypes['getProjects'][0])
public function getProjectsRequest($pagination, $prioritize_exact_match = true, $sort = null, $category = null, $platform = null, $owner = null, $q = null, $query = null, $license = null, $version = null, $tag = null, string $contentType = self::contentTypes['getProjects'][0])
{

// verify the required parameter 'pagination' is set
Expand All @@ -2083,6 +2088,7 @@ public function getProjectsRequest($pagination, $prioritize_exact_match = true,




$resourcePath = '/api/v1/projects';
$formParams = [];
$queryParams = [];
Expand Down Expand Up @@ -2154,6 +2160,15 @@ public function getProjectsRequest($pagination, $prioritize_exact_match = true,
false // required
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$query,
'query', // param base name
'string', // openApiType
'form', // style
true, // explode
false // required
) ?? []);
// query params
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
$license,
'license', // param base name
Expand Down
3 changes: 2 additions & 1 deletion lib/Client/HangarAPIClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,11 @@ public function getProjects(ProjectSearchOptions $options = new ProjectSearchOpt

$result = $this->projects->getProjects($options->getPagination(),
$options->isPrioritizeExactMatch(),
$options->getSortField()?->value,
$options->getSortParameter(),
$options->getCategory()?->value,
$options->getPlatform()?->value,
$options->getOwner(),
null,
$options->getQuery(),
$options->getLicense(),
$options->getVersion(),
Expand Down
Loading

0 comments on commit 21a0e75

Please sign in to comment.