Skip to content

Commit

Permalink
feat: add verification endpoints and extend marketplace functionality
Browse files Browse the repository at this point in the history
- Added methods to verify addresses and companies in the MiscClient.
- Introduced new request and response classes for address and company verification.
- Extended the MarketplaceClient to include methods for retrieving extension instances for customers and projects.
- Updated CreateRelocation request and body to include an optional userId field.
- Added cancellationForbidden property to the Termination schema to indicate if cancellation is allowed.
  • Loading branch information
mittwald-machine committed Jan 6, 2025
1 parent 4dfe22d commit 20b2fec
Show file tree
Hide file tree
Showing 34 changed files with 4,118 additions and 762 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<?php

declare(strict_types=1);

namespace Mittwald\ApiClient\Generated\V2\Clients\Marketplace\ExtensionGetExtensionInstanceForCustomer;

use InvalidArgumentException;
use JsonSchema\Validator;
use Mittwald\ApiClient\Client\ResponseContainer;
use Mittwald\ApiClient\Generated\V2\Schemas\Commons\Error;
use Psr\Http\Message\ResponseInterface;

class ExtensionGetExtensionInstanceForCustomerDefaultResponse implements ResponseContainer
{
/**
* Schema used to validate input for creating instances of this class
*/
private static array $schema = [
'type' => 'object',
'required' => [
'body',
],
'properties' => [
'body' => [
'$ref' => '#/components/schemas/de.mittwald.v1.commons.Error',
],
],
];

private Error $body;

private ResponseInterface|null $httpResponse = null;

public function __construct(Error $body)
{
$this->body = $body;
}

public function getBody(): Error
{
return $this->body;
}

public function withBody(Error $body): self
{
$clone = clone $this;
$clone->body = $body;

return $clone;
}

/**
* Builds a new instance from an input array
*
* @param array|object $input Input data
* @param bool $validate Set this to false to skip validation; use at own risk
* @return ExtensionGetExtensionInstanceForCustomerDefaultResponse Created instance
* @throws InvalidArgumentException
*/
public static function buildFromInput(array|object $input, bool $validate = true): ExtensionGetExtensionInstanceForCustomerDefaultResponse
{
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input;
if ($validate) {
static::validateInput($input);
}

$body = Error::buildFromInput($input->{'body'}, validate: $validate);

$obj = new self($body);

return $obj;
}

/**
* Converts this object back to a simple array that can be JSON-serialized
*
* @return array Converted array
*/
public function toJson(): array
{
$output = [];
$output['body'] = $this->body->toJson();

return $output;
}

/**
* Validates an input array
*
* @param array|object $input Input data
* @param bool $return Return instead of throwing errors
* @return bool Validation result
* @throws InvalidArgumentException
*/
public static function validateInput(array|object $input, bool $return = false): bool
{
$validator = new \Mittwald\ApiClient\Validator\Validator();
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input;
$validator->validate($input, static::$schema);

if (!$validator->isValid() && !$return) {
$errors = array_map(function (array $e): string {
return $e["property"] . ": " . $e["message"];
}, $validator->getErrors());
throw new InvalidArgumentException(join(", ", $errors));
}

return $validator->isValid();
}

public function __clone()
{
}

public static function fromResponse(ResponseInterface $httpResponse): self
{
$parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true);
$response = static::buildFromInput(['body' => $parsedBody], validate: false);
$response->httpResponse = $httpResponse;
return $response;
}

public function getResponse(): ResponseInterface|null
{
return $this->httpResponse;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<?php

declare(strict_types=1);

namespace Mittwald\ApiClient\Generated\V2\Clients\Marketplace\ExtensionGetExtensionInstanceForCustomer;

use InvalidArgumentException;
use JsonSchema\Validator;
use Mittwald\ApiClient\Client\ResponseContainer;
use Mittwald\ApiClient\Generated\V2\Schemas\Commons\Error;
use Psr\Http\Message\ResponseInterface;

class ExtensionGetExtensionInstanceForCustomerNotFoundResponse implements ResponseContainer
{
/**
* Schema used to validate input for creating instances of this class
*/
private static array $schema = [
'type' => 'object',
'required' => [
'body',
],
'properties' => [
'body' => [
'$ref' => '#/components/schemas/de.mittwald.v1.commons.Error',
],
],
];

private Error $body;

private ResponseInterface|null $httpResponse = null;

public function __construct(Error $body)
{
$this->body = $body;
}

public function getBody(): Error
{
return $this->body;
}

public function withBody(Error $body): self
{
$clone = clone $this;
$clone->body = $body;

return $clone;
}

/**
* Builds a new instance from an input array
*
* @param array|object $input Input data
* @param bool $validate Set this to false to skip validation; use at own risk
* @return ExtensionGetExtensionInstanceForCustomerNotFoundResponse Created instance
* @throws InvalidArgumentException
*/
public static function buildFromInput(array|object $input, bool $validate = true): ExtensionGetExtensionInstanceForCustomerNotFoundResponse
{
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input;
if ($validate) {
static::validateInput($input);
}

$body = Error::buildFromInput($input->{'body'}, validate: $validate);

$obj = new self($body);

return $obj;
}

/**
* Converts this object back to a simple array that can be JSON-serialized
*
* @return array Converted array
*/
public function toJson(): array
{
$output = [];
$output['body'] = $this->body->toJson();

return $output;
}

/**
* Validates an input array
*
* @param array|object $input Input data
* @param bool $return Return instead of throwing errors
* @return bool Validation result
* @throws InvalidArgumentException
*/
public static function validateInput(array|object $input, bool $return = false): bool
{
$validator = new \Mittwald\ApiClient\Validator\Validator();
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input;
$validator->validate($input, static::$schema);

if (!$validator->isValid() && !$return) {
$errors = array_map(function (array $e): string {
return $e["property"] . ": " . $e["message"];
}, $validator->getErrors());
throw new InvalidArgumentException(join(", ", $errors));
}

return $validator->isValid();
}

public function __clone()
{
}

public static function fromResponse(ResponseInterface $httpResponse): self
{
$parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true);
$response = static::buildFromInput(['body' => $parsedBody], validate: false);
$response->httpResponse = $httpResponse;
return $response;
}

public function getResponse(): ResponseInterface|null
{
return $this->httpResponse;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<?php

declare(strict_types=1);

namespace Mittwald\ApiClient\Generated\V2\Clients\Marketplace\ExtensionGetExtensionInstanceForCustomer;

use InvalidArgumentException;
use JsonSchema\Validator;
use Mittwald\ApiClient\Client\ResponseContainer;
use Mittwald\ApiClient\Generated\V2\Schemas\Marketplace\ExtensionInstance;
use Psr\Http\Message\ResponseInterface;

class ExtensionGetExtensionInstanceForCustomerOKResponse implements ResponseContainer
{
/**
* Schema used to validate input for creating instances of this class
*/
private static array $schema = [
'type' => 'object',
'required' => [
'body',
],
'properties' => [
'body' => [
'$ref' => '#/components/schemas/de.mittwald.v1.marketplace.ExtensionInstance',
],
],
];

private ExtensionInstance $body;

private ResponseInterface|null $httpResponse = null;

public function __construct(ExtensionInstance $body)
{
$this->body = $body;
}

public function getBody(): ExtensionInstance
{
return $this->body;
}

public function withBody(ExtensionInstance $body): self
{
$clone = clone $this;
$clone->body = $body;

return $clone;
}

/**
* Builds a new instance from an input array
*
* @param array|object $input Input data
* @param bool $validate Set this to false to skip validation; use at own risk
* @return ExtensionGetExtensionInstanceForCustomerOKResponse Created instance
* @throws InvalidArgumentException
*/
public static function buildFromInput(array|object $input, bool $validate = true): ExtensionGetExtensionInstanceForCustomerOKResponse
{
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input;
if ($validate) {
static::validateInput($input);
}

$body = ExtensionInstance::buildFromInput($input->{'body'}, validate: $validate);

$obj = new self($body);

return $obj;
}

/**
* Converts this object back to a simple array that can be JSON-serialized
*
* @return array Converted array
*/
public function toJson(): array
{
$output = [];
$output['body'] = $this->body->toJson();

return $output;
}

/**
* Validates an input array
*
* @param array|object $input Input data
* @param bool $return Return instead of throwing errors
* @return bool Validation result
* @throws InvalidArgumentException
*/
public static function validateInput(array|object $input, bool $return = false): bool
{
$validator = new \Mittwald\ApiClient\Validator\Validator();
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input;
$validator->validate($input, static::$schema);

if (!$validator->isValid() && !$return) {
$errors = array_map(function (array $e): string {
return $e["property"] . ": " . $e["message"];
}, $validator->getErrors());
throw new InvalidArgumentException(join(", ", $errors));
}

return $validator->isValid();
}

public function __clone()
{
}

public static function fromResponse(ResponseInterface $httpResponse): self
{
$parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true);
$response = static::buildFromInput(['body' => $parsedBody], validate: false);
$response->httpResponse = $httpResponse;
return $response;
}

public function getResponse(): ResponseInterface|null
{
return $this->httpResponse;
}
}
Loading

0 comments on commit 20b2fec

Please sign in to comment.