Skip to content

Commit

Permalink
refactor: replace deprecated LeaveProject and LeaveCustomer methods w…
Browse files Browse the repository at this point in the history
…ith their alternatives

This commit removes the old `leaveProject` and `leaveCustomer` methods from the `ProjectClient` and `CustomerClient` classes and replaces them with `deprecatedProjectLeaveProject` and `deprecatedCustomerLeaveCustomer` methods. These new methods handle the deprecation and provide a clear alternative for users. Additionally, this update changes references to related request and response classes, improving maintainability and clarity in the API.
  • Loading branch information
mittwald-machine committed Jan 16, 2025
1 parent b750cfb commit 8bad622
Show file tree
Hide file tree
Showing 18 changed files with 496 additions and 249 deletions.
21 changes: 11 additions & 10 deletions src/Generated/V2/Clients/Customer/CustomerClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Mittwald\ApiClient\Generated\V2\Clients\Customer\DeleteCustomer\DeleteCustomerRequest;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\DeleteCustomerInvite\DeleteCustomerInviteRequest;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\DeleteCustomerMembership\DeleteCustomerMembershipRequest;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\DeprecatedCustomerLeaveCustomer\DeprecatedCustomerLeaveCustomerRequest;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\GetCustomer\GetCustomerOKResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\GetCustomer\GetCustomerRequest;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\GetCustomerInvite\GetCustomerInviteOKResponse;
Expand All @@ -33,7 +34,6 @@
use Mittwald\ApiClient\Generated\V2\Clients\Customer\GetWallet\GetWalletRequest;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\IsCustomerLegallyCompetent\IsCustomerLegallyCompetentOKResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\IsCustomerLegallyCompetent\IsCustomerLegallyCompetentRequest;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\LeaveCustomer\LeaveCustomerRequest;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\ListCustomerInvites\ListCustomerInvitesOKResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\ListCustomerInvites\ListCustomerInvitesRequest;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\ListCustomerMemberships\ListCustomerMembershipsOKResponse;
Expand Down Expand Up @@ -210,15 +210,6 @@ public function getWallet(GetWalletRequest $request): GetWalletOKResponse;
* @return IsCustomerLegallyCompetentOKResponse Check if customer is allowed to order a paid item.
*/
public function isCustomerLegallyCompetent(IsCustomerLegallyCompetentRequest $request): IsCustomerLegallyCompetentOKResponse;
/**
* Leave a Customer.
*
* @see https://developer.mittwald.de/reference/v2/#tag/Customer/operation/customer-leave-customer
* @throws GuzzleException
* @throws UnexpectedResponseException
* @param LeaveCustomerRequest $request An object representing the request for this operation
*/
public function leaveCustomer(LeaveCustomerRequest $request): EmptyResponse;
/**
* List CustomerInvites belonging to the executing user.
*
Expand Down Expand Up @@ -317,4 +308,14 @@ public function updateCustomer(UpdateCustomerRequest $request): UpdateCustomerOK
* @param UpdateCustomerMembershipRequest $request An object representing the request for this operation
*/
public function updateCustomerMembership(UpdateCustomerMembershipRequest $request): EmptyResponse;
/**
* Leave a Customer.
*
* @see https://developer.mittwald.de/reference/v2/#tag/Customer/operation/deprecated-customer-leave-customer
* @throws GuzzleException
* @throws UnexpectedResponseException
* @param DeprecatedCustomerLeaveCustomerRequest $request An object representing the request for this operation
* @deprecated
*/
public function deprecatedCustomerLeaveCustomer(DeprecatedCustomerLeaveCustomerRequest $request): EmptyResponse;
}
49 changes: 25 additions & 24 deletions src/Generated/V2/Clients/Customer/CustomerClientImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
use Mittwald\ApiClient\Generated\V2\Clients\Customer\DeleteCustomerMembership\DeleteCustomerMembershipDefaultResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\DeleteCustomerMembership\DeleteCustomerMembershipRequest;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\DeleteCustomerMembership\DeleteCustomerMembershipTooManyRequestsResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\DeprecatedCustomerLeaveCustomer\DeprecatedCustomerLeaveCustomerDefaultResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\DeprecatedCustomerLeaveCustomer\DeprecatedCustomerLeaveCustomerRequest;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\DeprecatedCustomerLeaveCustomer\DeprecatedCustomerLeaveCustomerTooManyRequestsResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\GetCustomer\GetCustomerDefaultResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\GetCustomer\GetCustomerForbiddenResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\GetCustomer\GetCustomerNotFoundResponse;
Expand Down Expand Up @@ -94,9 +97,6 @@
use Mittwald\ApiClient\Generated\V2\Clients\Customer\IsCustomerLegallyCompetent\IsCustomerLegallyCompetentOKResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\IsCustomerLegallyCompetent\IsCustomerLegallyCompetentRequest;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\IsCustomerLegallyCompetent\IsCustomerLegallyCompetentTooManyRequestsResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\LeaveCustomer\LeaveCustomerDefaultResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\LeaveCustomer\LeaveCustomerRequest;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\LeaveCustomer\LeaveCustomerTooManyRequestsResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\ListCustomerInvites\ListCustomerInvitesDefaultResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\ListCustomerInvites\ListCustomerInvitesForbiddenResponse;
use Mittwald\ApiClient\Generated\V2\Clients\Customer\ListCustomerInvites\ListCustomerInvitesNotFoundResponse;
Expand Down Expand Up @@ -523,27 +523,6 @@ public function isCustomerLegallyCompetent(IsCustomerLegallyCompetentRequest $re
});
}

/**
* Leave a Customer.
*
* @see https://developer.mittwald.de/reference/v2/#tag/Customer/operation/customer-leave-customer
* @throws GuzzleException
* @throws UnexpectedResponseException
* @param LeaveCustomerRequest $request An object representing the request for this operation
*/
public function leaveCustomer(LeaveCustomerRequest $request): EmptyResponse
{
$httpRequest = new Request(LeaveCustomerRequest::method, $request->buildUrl());
$httpResponse = $this->client->send($httpRequest, $request->buildRequestOptions());
if ($httpResponse->getStatusCode() === 204) {
return new EmptyResponse($httpResponse);
}
throw new UnexpectedResponseException(match ($httpResponse->getStatusCode()) {
429 => LeaveCustomerTooManyRequestsResponse::fromResponse($httpResponse),
default => LeaveCustomerDefaultResponse::fromResponse($httpResponse),
});
}

/**
* List CustomerInvites belonging to the executing user.
*
Expand Down Expand Up @@ -775,4 +754,26 @@ public function updateCustomerMembership(UpdateCustomerMembershipRequest $reques
default => UpdateCustomerMembershipDefaultResponse::fromResponse($httpResponse),
});
}

/**
* Leave a Customer.
*
* @see https://developer.mittwald.de/reference/v2/#tag/Customer/operation/deprecated-customer-leave-customer
* @throws GuzzleException
* @throws UnexpectedResponseException
* @param DeprecatedCustomerLeaveCustomerRequest $request An object representing the request for this operation
* @deprecated
*/
public function deprecatedCustomerLeaveCustomer(DeprecatedCustomerLeaveCustomerRequest $request): EmptyResponse
{
$httpRequest = new Request(DeprecatedCustomerLeaveCustomerRequest::method, $request->buildUrl());
$httpResponse = $this->client->send($httpRequest, $request->buildRequestOptions());
if ($httpResponse->getStatusCode() === 204) {
return new EmptyResponse($httpResponse);
}
throw new UnexpectedResponseException(match ($httpResponse->getStatusCode()) {
429 => DeprecatedCustomerLeaveCustomerTooManyRequestsResponse::fromResponse($httpResponse),
default => DeprecatedCustomerLeaveCustomerDefaultResponse::fromResponse($httpResponse),
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

declare(strict_types=1);

namespace Mittwald\ApiClient\Generated\V2\Clients\Project\LeaveProject;
namespace Mittwald\ApiClient\Generated\V2\Clients\Customer\DeprecatedCustomerLeaveCustomer;

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

class LeaveProjectDefaultResponse implements ResponseContainer
class DeprecatedCustomerLeaveCustomerDefaultResponse implements ResponseContainer
{
/**
* Schema used to validate input for creating instances of this class
Expand Down Expand Up @@ -54,10 +54,10 @@ public function withBody(Error $body): self
*
* @param array|object $input Input data
* @param bool $validate Set this to false to skip validation; use at own risk
* @return LeaveProjectDefaultResponse Created instance
* @return DeprecatedCustomerLeaveCustomerDefaultResponse Created instance
* @throws InvalidArgumentException
*/
public static function buildFromInput(array|object $input, bool $validate = true): LeaveProjectDefaultResponse
public static function buildFromInput(array|object $input, bool $validate = true): DeprecatedCustomerLeaveCustomerDefaultResponse
{
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input;
if ($validate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

declare(strict_types=1);

namespace Mittwald\ApiClient\Generated\V2\Clients\Customer\LeaveCustomer;
namespace Mittwald\ApiClient\Generated\V2\Clients\Customer\DeprecatedCustomerLeaveCustomer;

use InvalidArgumentException;
use JsonSchema\Validator;

class LeaveCustomerRequest
class DeprecatedCustomerLeaveCustomerRequest
{
public const method = 'post';

Expand Down Expand Up @@ -100,10 +100,10 @@ public function withBody($body): self
*
* @param array|object $input Input data
* @param bool $validate Set this to false to skip validation; use at own risk
* @return LeaveCustomerRequest Created instance
* @return DeprecatedCustomerLeaveCustomerRequest Created instance
* @throws InvalidArgumentException
*/
public static function buildFromInput(array|object $input, bool $validate = true): LeaveCustomerRequest
public static function buildFromInput(array|object $input, bool $validate = true): DeprecatedCustomerLeaveCustomerRequest
{
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input;
if ($validate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

declare(strict_types=1);

namespace Mittwald\ApiClient\Generated\V2\Clients\Project\LeaveProject;
namespace Mittwald\ApiClient\Generated\V2\Clients\Customer\DeprecatedCustomerLeaveCustomer;

use InvalidArgumentException;
use JsonSchema\Validator;
use Mittwald\ApiClient\Client\ResponseContainer;
use Psr\Http\Message\ResponseInterface;

class LeaveProjectTooManyRequestsResponse implements ResponseContainer
class DeprecatedCustomerLeaveCustomerTooManyRequestsResponse implements ResponseContainer
{
/**
* Schema used to validate input for creating instances of this class
Expand All @@ -36,21 +36,21 @@ class LeaveProjectTooManyRequestsResponse implements ResponseContainer
],
];

private LeaveProjectTooManyRequestsResponseBody $body;
private DeprecatedCustomerLeaveCustomerTooManyRequestsResponseBody $body;

private ResponseInterface|null $httpResponse = null;

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

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

public function withBody(LeaveProjectTooManyRequestsResponseBody $body): self
public function withBody(DeprecatedCustomerLeaveCustomerTooManyRequestsResponseBody $body): self
{
$clone = clone $this;
$clone->body = $body;
Expand All @@ -63,17 +63,17 @@ public function withBody(LeaveProjectTooManyRequestsResponseBody $body): self
*
* @param array|object $input Input data
* @param bool $validate Set this to false to skip validation; use at own risk
* @return LeaveProjectTooManyRequestsResponse Created instance
* @return DeprecatedCustomerLeaveCustomerTooManyRequestsResponse Created instance
* @throws InvalidArgumentException
*/
public static function buildFromInput(array|object $input, bool $validate = true): LeaveProjectTooManyRequestsResponse
public static function buildFromInput(array|object $input, bool $validate = true): DeprecatedCustomerLeaveCustomerTooManyRequestsResponse
{
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input;
if ($validate) {
static::validateInput($input);
}

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

$obj = new self($body);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

declare(strict_types=1);

namespace Mittwald\ApiClient\Generated\V2\Clients\Customer\LeaveCustomer;
namespace Mittwald\ApiClient\Generated\V2\Clients\Customer\DeprecatedCustomerLeaveCustomer;

use InvalidArgumentException;
use JsonSchema\Validator;

class LeaveCustomerTooManyRequestsResponseBody
class DeprecatedCustomerLeaveCustomerTooManyRequestsResponseBody
{
/**
* Schema used to validate input for creating instances of this class
Expand Down Expand Up @@ -96,10 +96,10 @@ public function withoutType(): self
*
* @param array|object $input Input data
* @param bool $validate Set this to false to skip validation; use at own risk
* @return LeaveCustomerTooManyRequestsResponseBody Created instance
* @return DeprecatedCustomerLeaveCustomerTooManyRequestsResponseBody Created instance
* @throws InvalidArgumentException
*/
public static function buildFromInput(array|object $input, bool $validate = true): LeaveCustomerTooManyRequestsResponseBody
public static function buildFromInput(array|object $input, bool $validate = true): DeprecatedCustomerLeaveCustomerTooManyRequestsResponseBody
{
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input;
if ($validate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

declare(strict_types=1);

namespace Mittwald\ApiClient\Generated\V2\Clients\Customer\LeaveCustomer;
namespace Mittwald\ApiClient\Generated\V2\Clients\Project\DeprecatedProjectLeaveProject;

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

class LeaveCustomerDefaultResponse implements ResponseContainer
class DeprecatedProjectLeaveProjectDefaultResponse implements ResponseContainer
{
/**
* Schema used to validate input for creating instances of this class
Expand Down Expand Up @@ -54,10 +54,10 @@ public function withBody(Error $body): self
*
* @param array|object $input Input data
* @param bool $validate Set this to false to skip validation; use at own risk
* @return LeaveCustomerDefaultResponse Created instance
* @return DeprecatedProjectLeaveProjectDefaultResponse Created instance
* @throws InvalidArgumentException
*/
public static function buildFromInput(array|object $input, bool $validate = true): LeaveCustomerDefaultResponse
public static function buildFromInput(array|object $input, bool $validate = true): DeprecatedProjectLeaveProjectDefaultResponse
{
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input;
if ($validate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

declare(strict_types=1);

namespace Mittwald\ApiClient\Generated\V2\Clients\Project\LeaveProject;
namespace Mittwald\ApiClient\Generated\V2\Clients\Project\DeprecatedProjectLeaveProject;

use InvalidArgumentException;
use JsonSchema\Validator;

class LeaveProjectRequest
class DeprecatedProjectLeaveProjectRequest
{
public const method = 'post';

Expand Down Expand Up @@ -100,10 +100,10 @@ public function withBody($body): self
*
* @param array|object $input Input data
* @param bool $validate Set this to false to skip validation; use at own risk
* @return LeaveProjectRequest Created instance
* @return DeprecatedProjectLeaveProjectRequest Created instance
* @throws InvalidArgumentException
*/
public static function buildFromInput(array|object $input, bool $validate = true): LeaveProjectRequest
public static function buildFromInput(array|object $input, bool $validate = true): DeprecatedProjectLeaveProjectRequest
{
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input;
if ($validate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

declare(strict_types=1);

namespace Mittwald\ApiClient\Generated\V2\Clients\Customer\LeaveCustomer;
namespace Mittwald\ApiClient\Generated\V2\Clients\Project\DeprecatedProjectLeaveProject;

use InvalidArgumentException;
use JsonSchema\Validator;
use Mittwald\ApiClient\Client\ResponseContainer;
use Psr\Http\Message\ResponseInterface;

class LeaveCustomerTooManyRequestsResponse implements ResponseContainer
class DeprecatedProjectLeaveProjectTooManyRequestsResponse implements ResponseContainer
{
/**
* Schema used to validate input for creating instances of this class
Expand All @@ -36,21 +36,21 @@ class LeaveCustomerTooManyRequestsResponse implements ResponseContainer
],
];

private LeaveCustomerTooManyRequestsResponseBody $body;
private DeprecatedProjectLeaveProjectTooManyRequestsResponseBody $body;

private ResponseInterface|null $httpResponse = null;

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

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

public function withBody(LeaveCustomerTooManyRequestsResponseBody $body): self
public function withBody(DeprecatedProjectLeaveProjectTooManyRequestsResponseBody $body): self
{
$clone = clone $this;
$clone->body = $body;
Expand All @@ -63,17 +63,17 @@ public function withBody(LeaveCustomerTooManyRequestsResponseBody $body): self
*
* @param array|object $input Input data
* @param bool $validate Set this to false to skip validation; use at own risk
* @return LeaveCustomerTooManyRequestsResponse Created instance
* @return DeprecatedProjectLeaveProjectTooManyRequestsResponse Created instance
* @throws InvalidArgumentException
*/
public static function buildFromInput(array|object $input, bool $validate = true): LeaveCustomerTooManyRequestsResponse
public static function buildFromInput(array|object $input, bool $validate = true): DeprecatedProjectLeaveProjectTooManyRequestsResponse
{
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input;
if ($validate) {
static::validateInput($input);
}

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

$obj = new self($body);

Expand Down
Loading

0 comments on commit 8bad622

Please sign in to comment.