-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
127 changed files
with
4,955 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ | |
|
||
interface Testable | ||
{ | ||
public function getTestmode(): bool; | ||
public function getTestmode(): ?bool; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
src/EndpointCollection/SettlementEndpointCollection.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?php | ||
|
||
namespace Mollie\Api\EndpointCollection; | ||
|
||
use Mollie\Api\Exceptions\ApiException; | ||
use Mollie\Api\Factories\PaginatedQueryFactory; | ||
use Mollie\Api\Helpers; | ||
use Mollie\Api\Http\Requests\GetPaginatedSettlementRequest; | ||
use Mollie\Api\Http\Requests\GetSettlementRequest; | ||
use Mollie\Api\Resources\LazyCollection; | ||
use Mollie\Api\Resources\Settlement; | ||
use Mollie\Api\Resources\SettlementCollection; | ||
|
||
class SettlementEndpointCollection extends EndpointCollection | ||
{ | ||
/** | ||
* Retrieve a single settlement from Mollie. | ||
* | ||
* Will throw an ApiException if the settlement id is invalid or the resource cannot be found. | ||
* | ||
* @param array|bool $testmode | ||
* @throws ApiException | ||
*/ | ||
public function get(string $settlementId, $testmode = []): Settlement | ||
{ | ||
$testmode = Helpers::extractBool($testmode, 'testmode', false); | ||
|
||
/** @var Settlement */ | ||
return $this->send((new GetSettlementRequest($settlementId))->test($testmode)); | ||
} | ||
|
||
/** | ||
* Retrieve the next settlement from Mollie. | ||
* | ||
* @param array|bool $testmode | ||
* @throws ApiException | ||
*/ | ||
public function next($testmode = []): ?Settlement | ||
{ | ||
return $this->get('next', $testmode); | ||
} | ||
|
||
/** | ||
* Retrieve the open balance from Mollie. | ||
* | ||
* @param array|bool $testmode | ||
* @throws ApiException | ||
*/ | ||
public function open($testmode = []): ?Settlement | ||
{ | ||
return $this->get('open', $testmode); | ||
} | ||
|
||
/** | ||
* Retrieve a collection of settlements from Mollie. | ||
* | ||
* @param string|null $from The first settlement ID you want to include in your list. | ||
* @throws ApiException | ||
*/ | ||
public function page(?string $from = null, ?int $limit = null, array $filters = []): SettlementCollection | ||
{ | ||
$testmode = Helpers::extractBool($filters, 'testmode', false); | ||
|
||
$query = PaginatedQueryFactory::new([ | ||
'from' => $from, | ||
'limit' => $limit, | ||
'filters' => $filters, | ||
])->create(); | ||
|
||
/** @var SettlementCollection */ | ||
return $this->send((new GetPaginatedSettlementRequest($query))->test($testmode)); | ||
} | ||
|
||
/** | ||
* Create an iterator for iterating over settlements retrieved from Mollie. | ||
* | ||
* @param string|null $from The first settlement ID you want to include in your list. | ||
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false). | ||
*/ | ||
public function iterator( | ||
?string $from = null, | ||
?int $limit = null, | ||
array $filters = [], | ||
bool $iterateBackwards = false | ||
): LazyCollection { | ||
$testmode = Helpers::extractBool($filters, 'testmode', false); | ||
|
||
$query = PaginatedQueryFactory::new([ | ||
'from' => $from, | ||
'limit' => $limit, | ||
'filters' => $filters, | ||
])->create(); | ||
|
||
return $this->send( | ||
(new GetPaginatedSettlementRequest($query)) | ||
->useIterator() | ||
->setIterationDirection($iterateBackwards) | ||
->test($testmode) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Mollie\Api\Factories; | ||
|
||
use Mollie\Api\Http\Query\GetAllMethodsQuery; | ||
use Mollie\Api\Types\MethodQuery; | ||
use Mollie\Api\Types\PaymentMethod; | ||
|
||
class GetAllPaymentMethodsQueryFactory extends Factory | ||
{ | ||
public function create(): GetAllMethodsQuery | ||
{ | ||
$includeIssuers = $this->includes('include', MethodQuery::INCLUDE_ISSUERS); | ||
$includePricing = $this->includes('include', MethodQuery::INCLUDE_PRICING); | ||
|
||
return new GetAllMethodsQuery( | ||
$this->get('locale'), | ||
$this->get('includeIssuers', $includeIssuers), | ||
$this->get('includePricing', $includePricing), | ||
$this->mapIfNotNull('amount', MoneyFactory::class) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Mollie\Api\Factories; | ||
|
||
use Mollie\Api\Http\Query\GetClientQuery; | ||
use Mollie\Api\Types\ClientQuery; | ||
|
||
class GetClientQueryFactory extends Factory | ||
{ | ||
public function create(): GetClientQuery | ||
{ | ||
$embedOrganization = $this->includes('embed', ClientQuery::EMBED_ORGANIZATION); | ||
$embedOnboarding = $this->includes('embed', ClientQuery::EMBED_ONBOARDING); | ||
|
||
return new GetClientQuery( | ||
$this->get('embedOrganization', $embedOrganization), | ||
$this->get('embedOnboarding', $embedOnboarding), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.