Skip to content

Commit

Permalink
feat(contract): add invoice replace settings and new wallet functiona…
Browse files Browse the repository at this point in the history
…lities

- Implemented `invoiceReplaceInvoiceSettings` method in `ContractClient` and `ContractClientImpl`.
- Added new customer functionalities: `createRecommendationSuggestion`, `createWallet`, and `getWallet` in `CustomerClient` and `CustomerClientImpl`.
- Updated API references and request/response handling for the new features.
  • Loading branch information
mittwald-machine committed Oct 24, 2024
1 parent 899a0c6 commit b23f31b
Show file tree
Hide file tree
Showing 44 changed files with 6,133 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Generated/V2/Clients/Contract/ContractClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
use Mittwald\ApiClient\Generated\V2\Clients\Contract\InvoiceGetFileAccessToken\InvoiceGetFileAccessTokenRequest;
use Mittwald\ApiClient\Generated\V2\Clients\Contract\InvoiceListCustomerInvoices\InvoiceListCustomerInvoicesOKResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Contract\InvoiceListCustomerInvoices\InvoiceListCustomerInvoicesRequest;
use Mittwald\ApiClient\Generated\V2\Clients\Contract\InvoiceReplaceInvoiceSettings\InvoiceReplaceInvoiceSettingsOKResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Contract\InvoiceReplaceInvoiceSettings\InvoiceReplaceInvoiceSettingsRequest;
use Mittwald\ApiClient\Generated\V2\Clients\Contract\InvoiceUpdateInvoiceSettings\InvoiceUpdateInvoiceSettingsOKResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Contract\InvoiceUpdateInvoiceSettings\InvoiceUpdateInvoiceSettingsRequest;
use Mittwald\ApiClient\Generated\V2\Clients\Contract\ListContracts\ListContractsOKResponse;
Expand Down Expand Up @@ -264,6 +266,15 @@ public function invoiceGetFileAccessToken(InvoiceGetFileAccessTokenRequest $requ
* @param InvoiceListCustomerInvoicesRequest $request An object representing the request for this operation
*/
public function invoiceListCustomerInvoices(InvoiceListCustomerInvoicesRequest $request): InvoiceListCustomerInvoicesOKResponse;
/**
* Update InvoiceSettings of a Customer.
*
* @see https://developer.mittwald.de/reference/v2/#tag/Contract/operation/invoice-replace-invoice-settings
* @throws GuzzleException
* @throws UnexpectedResponseException
* @param InvoiceReplaceInvoiceSettingsRequest $request An object representing the request for this operation
*/
public function invoiceReplaceInvoiceSettings(InvoiceReplaceInvoiceSettingsRequest $request): InvoiceReplaceInvoiceSettingsOKResponse;
/**
* Update InvoiceSettings of a Customer.
*
Expand Down
29 changes: 29 additions & 0 deletions src/Generated/V2/Clients/Contract/ContractClientImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@
use Mittwald\ApiClient\Generated\V2\Clients\Contract\InvoiceListCustomerInvoices\InvoiceListCustomerInvoicesOKResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Contract\InvoiceListCustomerInvoices\InvoiceListCustomerInvoicesRequest;
use Mittwald\ApiClient\Generated\V2\Clients\Contract\InvoiceListCustomerInvoices\InvoiceListCustomerInvoicesTooManyRequestsResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Contract\InvoiceReplaceInvoiceSettings\InvoiceReplaceInvoiceSettingsBadRequestResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Contract\InvoiceReplaceInvoiceSettings\InvoiceReplaceInvoiceSettingsDefaultResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Contract\InvoiceReplaceInvoiceSettings\InvoiceReplaceInvoiceSettingsNotFoundResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Contract\InvoiceReplaceInvoiceSettings\InvoiceReplaceInvoiceSettingsOKResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Contract\InvoiceReplaceInvoiceSettings\InvoiceReplaceInvoiceSettingsRequest;
use Mittwald\ApiClient\Generated\V2\Clients\Contract\InvoiceReplaceInvoiceSettings\InvoiceReplaceInvoiceSettingsTooManyRequestsResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Contract\InvoiceUpdateInvoiceSettings\InvoiceUpdateInvoiceSettingsBadRequestResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Contract\InvoiceUpdateInvoiceSettings\InvoiceUpdateInvoiceSettingsDefaultResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Contract\InvoiceUpdateInvoiceSettings\InvoiceUpdateInvoiceSettingsNotFoundResponse;
Expand Down Expand Up @@ -643,6 +649,29 @@ public function invoiceListCustomerInvoices(InvoiceListCustomerInvoicesRequest $
});
}

/**
* Update InvoiceSettings of a Customer.
*
* @see https://developer.mittwald.de/reference/v2/#tag/Contract/operation/invoice-replace-invoice-settings
* @throws GuzzleException
* @throws UnexpectedResponseException
* @param InvoiceReplaceInvoiceSettingsRequest $request An object representing the request for this operation
*/
public function invoiceReplaceInvoiceSettings(InvoiceReplaceInvoiceSettingsRequest $request): InvoiceReplaceInvoiceSettingsOKResponse
{
$httpRequest = new Request(InvoiceReplaceInvoiceSettingsRequest::method, $request->buildUrl());
$httpResponse = $this->client->send($httpRequest, $request->buildRequestOptions());
if ($httpResponse->getStatusCode() === 200) {
return InvoiceReplaceInvoiceSettingsOKResponse::fromResponse($httpResponse);
}
throw new UnexpectedResponseException(match ($httpResponse->getStatusCode()) {
400 => InvoiceReplaceInvoiceSettingsBadRequestResponse::fromResponse($httpResponse),
404 => InvoiceReplaceInvoiceSettingsNotFoundResponse::fromResponse($httpResponse),
429 => InvoiceReplaceInvoiceSettingsTooManyRequestsResponse::fromResponse($httpResponse),
default => InvoiceReplaceInvoiceSettingsDefaultResponse::fromResponse($httpResponse),
});
}

/**
* Update InvoiceSettings of a Customer.
*
Expand Down
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\Contract\InvoiceReplaceInvoiceSettings;

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

class InvoiceReplaceInvoiceSettingsBadRequestResponse 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.ValidationErrors',
],
],
];

private ValidationErrors $body;

private ResponseInterface|null $httpResponse = null;

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

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

public function withBody(ValidationErrors $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 InvoiceReplaceInvoiceSettingsBadRequestResponse Created instance
* @throws InvalidArgumentException
*/
public static function buildFromInput(array|object $input, bool $validate = true): InvoiceReplaceInvoiceSettingsBadRequestResponse
{
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input;
if ($validate) {
static::validateInput($input);
}

$body = ValidationErrors::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\Contract\InvoiceReplaceInvoiceSettings;

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

class InvoiceReplaceInvoiceSettingsDefaultResponse 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 InvoiceReplaceInvoiceSettingsDefaultResponse Created instance
* @throws InvalidArgumentException
*/
public static function buildFromInput(array|object $input, bool $validate = true): InvoiceReplaceInvoiceSettingsDefaultResponse
{
$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;
}
}
Loading

0 comments on commit b23f31b

Please sign in to comment.