Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoray committed Dec 3, 2024
1 parent be6161e commit 5e4c726
Show file tree
Hide file tree
Showing 159 changed files with 1,582 additions and 10,790 deletions.
4 changes: 4 additions & 0 deletions src/Contracts/SupportsResourceHydration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@

interface SupportsResourceHydration
{
public static function hydrate(bool $shouldAutoHydrate = true): void;

public function shouldAutoHydrate(): bool;

public function getTargetResourceClass(): string;
}
5 changes: 2 additions & 3 deletions src/EndpointCollection/CustomerEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,11 @@ public function update(string $id, $data = []): ?Customer
*
* @throws ApiException
*/
public function delete(string $id, $testmode = []): ?Customer
public function delete(string $id, $testmode = []): void
{
$testmode = Helpers::extractBool($testmode, 'testmode', false);

/** @var null|Customer */
return $this->send((new DeleteCustomerRequest($id))->test($testmode));
$this->send((new DeleteCustomerRequest($id))->test($testmode));
}

/**
Expand Down
8 changes: 5 additions & 3 deletions src/EndpointCollection/CustomerPaymentsEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ class CustomerPaymentsEndpointCollection extends EndpointCollection
/**
* Create a subscription for a Customer
*
* @param array|CreatePaymentPayload $payload
* @param array|CreatePaymentQuery $query
*
* @throws ApiException
*/
public function createFor(Customer $customer, array $payload = [], array $query = [], bool $testmode = false): Payment
public function createFor(Customer $customer, $payload = [], $query = [], bool $testmode = false): Payment
{
return $this->createForId($customer->id, $payload, $query, $testmode);
}
Expand Down Expand Up @@ -78,10 +80,10 @@ public function pageForId(string $customerId, ?string $from = null, ?int $limit
'filters' => $filters,
])->create();

return $this->send(new GetPaginatedCustomerPaymentsRequest(
return $this->send((new GetPaginatedCustomerPaymentsRequest(
$customerId,
$query
))->test($testmode);
))->test($testmode));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/EndpointCollection/MandateEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MandateEndpointCollection extends EndpointCollection
/**
* Creates a mandate for a specific customer.
*
* @param array $payload
* @param array|CreateMandatePayload $payload
*
* @throws ApiException
*/
Expand Down
2 changes: 1 addition & 1 deletion src/EndpointCollection/MethodIssuerEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ public function enable(string $profileId, string $methodId, string $issuerId, ?s
*/
public function disable(string $profileId, string $methodId, string $issuerId): void
{
return $this->send(new DisableMethodIssuerRequest($profileId, $methodId, $issuerId));
$this->send(new DisableMethodIssuerRequest($profileId, $methodId, $issuerId));
}
}
7 changes: 4 additions & 3 deletions src/EndpointCollection/PaymentLinkEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function get(string $paymentLinkId, $testmode = []): PaymentLink
*
* @throws ApiException
*/
public function update(string $paymentLinkId, $payload = [], ?bool $testmode = null): PaymentLink
public function update(string $paymentLinkId, $payload = [], bool $testmode = false): PaymentLink
{
if (! $payload instanceof UpdatePaymentLinkPayload) {
$payload = UpdatePaymentLinkPayloadFactory::new($payload)->create();
Expand All @@ -77,7 +77,7 @@ public function update(string $paymentLinkId, $payload = [], ?bool $testmode = n
*
* @throws ApiException
*/
public function delete(string $paymentLinkId, ?bool $testmode = null): void
public function delete(string $paymentLinkId, bool $testmode = false): void
{
$this->send((new DeletePaymentLinkRequest($paymentLinkId))->test($testmode));
}
Expand Down Expand Up @@ -107,12 +107,13 @@ public function page(?string $from = null, ?int $limit = null, $testmode = []):
* Create an iterator for iterating over payment links retrieved from Mollie.
*
* @param string|null $from The first resource ID you want to include in your list.
* @param bool $testmode
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*/
public function iterator(
?string $from = null,
?int $limit = null,
?bool $testmode = null,
$testmode = [],
bool $iterateBackwards = false
): LazyCollection {
$testmode = Helpers::extractBool($testmode, 'testmode', false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class PaymentLinkPaymentEndpointCollection extends EndpointCollection
*
* @throws ApiException
*/
public function pageFor(PaymentLink $paymentLink, ?string $from = null, ?int $limit = null, ?array $filters = null): PaymentCollection
public function pageFor(PaymentLink $paymentLink, ?string $from = null, ?int $limit = null, array $filters = []): PaymentCollection
{
return $this->pageForId($paymentLink->id, $from, $limit, $filters);
}
Expand All @@ -32,7 +32,7 @@ public function pageFor(PaymentLink $paymentLink, ?string $from = null, ?int $li
*
* @throws ApiException
*/
public function pageForId(string $paymentLinkId, ?string $from = null, ?int $limit = null, ?array $filters = null): PaymentCollection
public function pageForId(string $paymentLinkId, ?string $from = null, ?int $limit = null, array $filters = []): PaymentCollection
{
$testmode = Helpers::extractBool($filters, 'testmode', false);
$query = SortablePaginatedQueryFactory::new([
Expand All @@ -55,7 +55,7 @@ public function iteratorFor(
PaymentLink $paymentLink,
?string $from = null,
?int $limit = null,
?array $filters = null,
array $filters = [],
bool $iterateBackwards = false
): LazyCollection {
return $this->iteratorForId(
Expand All @@ -77,7 +77,7 @@ public function iteratorForId(
string $paymentLinkId,
?string $from = null,
?int $limit = null,
?array $filters = null,
array $filters = [],
bool $iterateBackwards = false
): LazyCollection {
$testmode = Helpers::extractBool($filters, 'testmode', false);
Expand Down
4 changes: 2 additions & 2 deletions src/EndpointCollection/PaymentRouteEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PaymentRouteEndpointCollection extends EndpointCollection
*
* @throws ApiException
*/
public function updateReleaseDateFor(Payment $payment, string $routeId, string $releaseDate, ?bool $testmode = null): Route
public function updateReleaseDateFor(Payment $payment, string $routeId, string $releaseDate, bool $testmode = false): Route
{
return $this->updateReleaseDateForId($payment->id, $routeId, $releaseDate, $testmode);
}
Expand All @@ -30,7 +30,7 @@ public function updateReleaseDateFor(Payment $payment, string $routeId, string $
*
* @throws ApiException
*/
public function updateReleaseDateForId(string $paymentId, string $routeId, string $releaseDate, ?bool $testmode = null): Route
public function updateReleaseDateForId(string $paymentId, string $routeId, string $releaseDate, bool $testmode = false): Route
{
$payload = UpdatePaymentRoutePayloadFactory::new([
'releaseDate' => $releaseDate,
Expand Down
6 changes: 2 additions & 4 deletions src/EndpointCollection/ProfileEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,11 @@ public function update(string $profileId, $payload = []): ?Profile
* Will throw a ApiException if the profile id is invalid or the resource cannot be found.
* Returns with HTTP status No Content (204) if successful.
*
*
* @throws ApiException
*/
public function delete(string $profileId): ?Profile
public function delete(string $profileId): void
{
/** @var Profile|null */
return $this->send(new DeleteProfileRequest($profileId));
$this->send(new DeleteProfileRequest($profileId));
}

/**
Expand Down
159 changes: 159 additions & 0 deletions src/EndpointCollection/ProfileMethodEndpointCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
<?php

namespace Mollie\Api\EndpointCollection;

use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Http\Requests\EnableProfileMethodRequest;
use Mollie\Api\Http\Requests\DisableProfileMethodRequest;
use Mollie\Api\Resources\Method;
use Mollie\Api\Resources\Profile;

class ProfileMethodEndpointCollection extends EndpointCollection
{
/**
* Enable a method for the provided Profile ID.
* Alias of enableForId for backwards compatibility.
*
* @param string $profileId
* @param string $id
* @throws ApiException
*/
public function createForId(string $profileId, string $id): Method
{
return $this->enableForId($profileId, $id);
}

/**
* Enable a method for the provided Profile object.
* Alias of enableFor for backwards compatibility.
*
* @param Profile $profile
* @param string $id
* @throws ApiException
*/
public function createFor(Profile $profile, string $id): Method
{
return $this->enableFor($profile, $id);
}

/**
* Enable a method for the current profile.
* Alias of enable for backwards compatibility.
*
* @param string $id
* @throws ApiException
*/
public function createForCurrentProfile(string $id): Method
{
return $this->enable($id);
}

/**
* Enable a payment method for a specific profile.
*
* @param string $profileId The profile's ID or 'me' for the current profile
* @param string $id The payment method ID
* @throws ApiException
*/
public function enableForId(string $profileId, string $id): Method
{
/** @var Method */
return $this->send(new EnableProfileMethodRequest($profileId, $id));
}

/**
* Enable a payment method for the provided Profile object.
*
* @param Profile $profile
* @param string $id The payment method ID
* @throws ApiException
*/
public function enableFor(Profile $profile, string $id): Method
{
return $this->enableForId($profile->id, $id);
}

/**
* Enable a payment method for the current profile.
*
* @param string $id The payment method ID
* @throws ApiException
*/
public function enable(string $id): Method
{
return $this->enableForId('me', $id);
}

/**
* Disable a method for the provided Profile ID.
* Alias of disableForId for backwards compatibility.
*
* @param string $profileId
* @param string $id
* @throws ApiException
*/
public function deleteForId(string $profileId, string $id): void
{
$this->disableForId($profileId, $id);
}

/**
* Disable a method for the provided Profile object.
* Alias of disableFor for backwards compatibility.
*
* @param Profile $profile
* @param string $id
* @throws ApiException
*/
public function deleteFor(Profile $profile, string $id): void
{
$this->disableFor($profile, $id);
}

/**
* Disable a method for the current profile.
* Alias of disable for backwards compatibility.
*
* @param string $id
* @throws ApiException
*/
public function deleteForCurrentProfile(string $id): void
{
$this->disable($id);
}

/**
* Disable a payment method for a specific profile.
*
* @param string $profileId The profile's ID or 'me' for the current profile
* @param string $id The payment method ID
* @throws ApiException
*/
public function disableForId(string $profileId, string $id): void
{
$this->send(new DisableProfileMethodRequest($profileId, $id));
}

/**
* Disable a payment method for the provided Profile object.
*
* @param Profile $profile
* @param string $id The payment method ID
* @throws ApiException
*/
public function disableFor(Profile $profile, string $id): void
{
$this->disableForId($profile->id, $id);
}

/**
* Disable a payment method for the current profile.
*
* @param string $id The payment method ID
* @throws ApiException
*/
public function disable(string $id): void
{
$this->disableForId('me', $id);
}
}
Loading

0 comments on commit 5e4c726

Please sign in to comment.