Skip to content

Commit

Permalink
feat: update pagination parameters and add membership properties to U…
Browse files Browse the repository at this point in the history
…ser schema

- Changed the minimum values for pagination fields `limit`, `page`, and `skip` to be 1, and set default value for `skip` to 0 in respective request classes.
- Updated the User and UserInternal schemas to include `customerMemberships` and `projectMemberships` properties, allowing for better user tracking and organization.
- Adjusted corresponding getters and setters to manage the new membership properties.
  • Loading branch information
mittwald-machine committed Sep 26, 2024
1 parent 034bcb2 commit 92b02e5
Show file tree
Hide file tree
Showing 10 changed files with 755 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ class ListAppinstallationsRequest
'format' => 'uuid',
'type' => 'string',
],
'limit' => [
'minimum' => 0,
'page' => [
'type' => 'integer',
'minimum' => 1,
],
'page' => [
'minimum' => 0,
'limit' => [
'type' => 'integer',
'minimum' => 1,
],
'skip' => [
'minimum' => 0,
'type' => 'integer',
'default' => 0,
],
],
'required' => [
Expand All @@ -41,11 +41,11 @@ class ListAppinstallationsRequest

private string $projectId;

private ?int $limit = null;

private ?int $page = null;

private ?int $skip = null;
private ?int $limit = null;

private int $skip = 0;

private array $headers = [

Expand All @@ -61,19 +61,19 @@ public function getProjectId(): string
return $this->projectId;
}

public function getLimit(): ?int
public function getPage(): ?int
{
return $this->limit ?? null;
return $this->page ?? null;
}

public function getPage(): ?int
public function getLimit(): ?int
{
return $this->page ?? null;
return $this->limit ?? null;
}

public function getSkip(): ?int
public function getSkip(): int
{
return $this->skip ?? null;
return $this->skip;
}

public function withProjectId(string $projectId): self
Expand All @@ -90,46 +90,46 @@ public function withProjectId(string $projectId): self
return $clone;
}

public function withLimit(int $limit): self
public function withPage(int $page): self
{
$validator = new Validator();
$validator->validate($limit, static::$schema['properties']['limit']);
$validator->validate($page, static::$schema['properties']['page']);
if (!$validator->isValid()) {
throw new InvalidArgumentException($validator->getErrors()[0]['message']);
}

$clone = clone $this;
$clone->limit = $limit;
$clone->page = $page;

return $clone;
}

public function withoutLimit(): self
public function withoutPage(): self
{
$clone = clone $this;
unset($clone->limit);
unset($clone->page);

return $clone;
}

public function withPage(int $page): self
public function withLimit(int $limit): self
{
$validator = new Validator();
$validator->validate($page, static::$schema['properties']['page']);
$validator->validate($limit, static::$schema['properties']['limit']);
if (!$validator->isValid()) {
throw new InvalidArgumentException($validator->getErrors()[0]['message']);
}

$clone = clone $this;
$clone->page = $page;
$clone->limit = $limit;

return $clone;
}

public function withoutPage(): self
public function withoutLimit(): self
{
$clone = clone $this;
unset($clone->page);
unset($clone->limit);

return $clone;
}
Expand All @@ -148,14 +148,6 @@ public function withSkip(int $skip): self
return $clone;
}

public function withoutSkip(): self
{
$clone = clone $this;
unset($clone->skip);

return $clone;
}

/**
* Builds a new instance from an input array
*
Expand All @@ -172,22 +164,22 @@ public static function buildFromInput(array|object $input, bool $validate = true
}

$projectId = $input->{'projectId'};
$limit = null;
if (isset($input->{'limit'})) {
$limit = (int)($input->{'limit'});
}
$page = null;
if (isset($input->{'page'})) {
$page = (int)($input->{'page'});
}
$skip = null;
$limit = null;
if (isset($input->{'limit'})) {
$limit = (int)($input->{'limit'});
}
$skip = 0;
if (isset($input->{'skip'})) {
$skip = (int)($input->{'skip'});
}

$obj = new self($projectId);
$obj->limit = $limit;
$obj->page = $page;
$obj->limit = $limit;
$obj->skip = $skip;
return $obj;
}
Expand All @@ -201,15 +193,13 @@ public function toJson(): array
{
$output = [];
$output['projectId'] = $this->projectId;
if (isset($this->limit)) {
$output['limit'] = $this->limit;
}
if (isset($this->page)) {
$output['page'] = $this->page;
}
if (isset($this->skip)) {
$output['skip'] = $this->skip;
if (isset($this->limit)) {
$output['limit'] = $this->limit;
}
$output['skip'] = $this->skip;

return $output;
}
Expand Down Expand Up @@ -271,15 +261,18 @@ public function buildRequestOptions(): array
{
$mapped = $this->toJson();
$query = [];
if (isset($mapped['limit'])) {
$query['limit'] = $mapped['limit'];
}
if (isset($mapped['page'])) {
$query['page'] = $mapped['page'];
}
if (isset($mapped['limit'])) {
$query['limit'] = $mapped['limit'];
}
if (isset($mapped['skip'])) {
$query['skip'] = $mapped['skip'];
}
if (isset($mapped['page'])) {
$query['page'] = $mapped['page'];
}
return [
'query' => $query,
'headers' => $this->headers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ class ListAppinstallationsForUserRequest
'type' => 'object',
'properties' => [
'limit' => [
'minimum' => 0,
'type' => 'integer',
'minimum' => 1,
],
'page' => [
'minimum' => 0,
'skip' => [
'type' => 'integer',
'default' => 0,
],
'skip' => [
'minimum' => 0,
'page' => [
'type' => 'integer',
'minimum' => 1,
],
],
'required' => [
Expand All @@ -37,9 +37,9 @@ class ListAppinstallationsForUserRequest

private ?int $limit = null;

private ?int $page = null;
private int $skip = 0;

private ?int $skip = null;
private ?int $page = null;

private array $headers = [

Expand All @@ -57,14 +57,14 @@ public function getLimit(): ?int
return $this->limit ?? null;
}

public function getPage(): ?int
public function getSkip(): int
{
return $this->page ?? null;
return $this->skip;
}

public function getSkip(): ?int
public function getPage(): ?int
{
return $this->skip ?? null;
return $this->page ?? null;
}

public function withLimit(int $limit): self
Expand All @@ -89,46 +89,38 @@ public function withoutLimit(): self
return $clone;
}

public function withPage(int $page): self
public function withSkip(int $skip): self
{
$validator = new Validator();
$validator->validate($page, static::$schema['properties']['page']);
$validator->validate($skip, static::$schema['properties']['skip']);
if (!$validator->isValid()) {
throw new InvalidArgumentException($validator->getErrors()[0]['message']);
}

$clone = clone $this;
$clone->page = $page;

return $clone;
}

public function withoutPage(): self
{
$clone = clone $this;
unset($clone->page);
$clone->skip = $skip;

return $clone;
}

public function withSkip(int $skip): self
public function withPage(int $page): self
{
$validator = new Validator();
$validator->validate($skip, static::$schema['properties']['skip']);
$validator->validate($page, static::$schema['properties']['page']);
if (!$validator->isValid()) {
throw new InvalidArgumentException($validator->getErrors()[0]['message']);
}

$clone = clone $this;
$clone->skip = $skip;
$clone->page = $page;

return $clone;
}

public function withoutSkip(): self
public function withoutPage(): self
{
$clone = clone $this;
unset($clone->skip);
unset($clone->page);

return $clone;
}
Expand All @@ -152,19 +144,19 @@ public static function buildFromInput(array|object $input, bool $validate = true
if (isset($input->{'limit'})) {
$limit = (int)($input->{'limit'});
}
$skip = 0;
if (isset($input->{'skip'})) {
$skip = (int)($input->{'skip'});
}
$page = null;
if (isset($input->{'page'})) {
$page = (int)($input->{'page'});
}
$skip = null;
if (isset($input->{'skip'})) {
$skip = (int)($input->{'skip'});
}

$obj = new self();
$obj->limit = $limit;
$obj->page = $page;
$obj->skip = $skip;
$obj->page = $page;
return $obj;
}

Expand All @@ -179,12 +171,10 @@ public function toJson(): array
if (isset($this->limit)) {
$output['limit'] = $this->limit;
}
$output['skip'] = $this->skip;
if (isset($this->page)) {
$output['page'] = $this->page;
}
if (isset($this->skip)) {
$output['skip'] = $this->skip;
}

return $output;
}
Expand Down Expand Up @@ -248,12 +238,12 @@ public function buildRequestOptions(): array
if (isset($mapped['limit'])) {
$query['limit'] = $mapped['limit'];
}
if (isset($mapped['page'])) {
$query['page'] = $mapped['page'];
}
if (isset($mapped['skip'])) {
$query['skip'] = $mapped['skip'];
}
if (isset($mapped['page'])) {
$query['page'] = $mapped['page'];
}
return [
'query' => $query,
'headers' => $this->headers,
Expand Down
Loading

0 comments on commit 92b02e5

Please sign in to comment.