-
Notifications
You must be signed in to change notification settings - Fork 190
/
BalanceTransactionEndpoint.php
129 lines (112 loc) · 3.72 KB
/
BalanceTransactionEndpoint.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
declare(strict_types=1);
namespace Mollie\Api\Endpoints;
use Mollie\Api\Resources\Balance;
use Mollie\Api\Resources\BalanceTransaction;
use Mollie\Api\Resources\BalanceTransactionCollection;
use Mollie\Api\Resources\LazyCollection;
class BalanceTransactionEndpoint extends CollectionEndpointAbstract
{
/**
* @var string
*/
const RESOURCE_ID_PREFIX = 'baltr_';
/**
* @var string
*/
protected $resourcePath = "balances_transactions";
/**
* @inheritDoc
*/
protected function getResourceCollectionObject($count, $_links)
{
return new BalanceTransactionCollection($this->client, $count, $_links);
}
/**
* @inheritDoc
*/
protected function getResourceObject()
{
return new BalanceTransaction($this->client);
}
/**
* List the transactions for a specific Balance.
*
* @param Balance $balance
* @param array $parameters
* @return BalanceTransactionCollection|\Mollie\Api\Resources\BaseCollection
*
* @throws \Mollie\Api\Exceptions\ApiException
*/
public function listFor(Balance $balance, array $parameters = [])
{
return $this->listForId($balance->id, $parameters);
}
/**
* Create an iterator for iterating over balance transactions for the given balance retrieved from Mollie.
*
* @param Balance $balance
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return LazyCollection
*/
public function iteratorFor(Balance $balance, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->iteratorForId($balance->id, $parameters, $iterateBackwards);
}
/**
* List the transactions for a specific Balance ID.
*
* @param string $balanceId
* @param array $parameters
* @return BalanceTransactionCollection|\Mollie\Api\Resources\BaseCollection
*
* @throws \Mollie\Api\Exceptions\ApiException
*/
public function listForId(string $balanceId, array $parameters = [])
{
$this->parentId = $balanceId;
return parent::rest_list(null, null, $parameters);
}
/**
* Create an iterator for iterating over balance transactions for the given balance id retrieved from Mollie.
*
* @param string $balanceId
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return LazyCollection
*/
public function iteratorForId(string $balanceId, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
$this->parentId = $balanceId;
return $this->rest_iterator(null, null, $parameters, $iterateBackwards);
}
/**
* List the transactions for the primary Balance.
*
* @param array $parameters
* @return BalanceTransactionCollection|\Mollie\Api\Resources\BaseCollection
*
* @throws \Mollie\Api\Exceptions\ApiException
*/
public function listForPrimary(array $parameters = [])
{
$this->parentId = "primary";
return parent::rest_list(null, null, $parameters);
}
/**
* Create an iterator for iterating over transactions for the primary balance retrieved from Mollie.
*
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return LazyCollection
*/
public function iteratorForPrimary(array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
$this->parentId = "primary";
return $this->rest_iterator(null, null, $parameters, $iterateBackwards);
}
}