Skip to content

Commit b0302cc

Browse files
committed
update contracts
1 parent d40bd77 commit b0302cc

File tree

13 files changed

+276
-114
lines changed

13 files changed

+276
-114
lines changed

src/Interfaces/Confirmable.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Bavix\Wallet\Exceptions\WalletOwnerInvalid;
1212
use Bavix\Wallet\Internal\Exceptions\ExceptionInterface;
1313
use Bavix\Wallet\Internal\Exceptions\LockProviderNotFoundException;
14+
use Bavix\Wallet\Internal\Exceptions\RecordNotFoundException;
1415
use Bavix\Wallet\Internal\Exceptions\TransactionFailedException;
1516
use Bavix\Wallet\Models\Transaction;
1617
use Illuminate\Database\RecordsNotFoundException;
@@ -23,6 +24,7 @@ interface Confirmable
2324
* @throws ConfirmedInvalid
2425
* @throws WalletOwnerInvalid
2526
* @throws LockProviderNotFoundException
27+
* @throws RecordNotFoundException
2628
* @throws RecordsNotFoundException
2729
* @throws TransactionFailedException
2830
* @throws ExceptionInterface
@@ -34,6 +36,7 @@ public function safeConfirm(Transaction $transaction): bool;
3436
/**
3537
* @throws UnconfirmedInvalid
3638
* @throws LockProviderNotFoundException
39+
* @throws RecordNotFoundException
3740
* @throws RecordsNotFoundException
3841
* @throws TransactionFailedException
3942
* @throws ExceptionInterface
@@ -46,6 +49,7 @@ public function safeResetConfirm(Transaction $transaction): bool;
4649
* @throws ConfirmedInvalid
4750
* @throws WalletOwnerInvalid
4851
* @throws LockProviderNotFoundException
52+
* @throws RecordNotFoundException
4953
* @throws RecordsNotFoundException
5054
* @throws TransactionFailedException
5155
* @throws ExceptionInterface

src/Interfaces/Customer.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
use Bavix\Wallet\Exceptions\InsufficientFunds;
99
use Bavix\Wallet\Exceptions\ProductEnded;
1010
use Bavix\Wallet\Internal\Exceptions\ExceptionInterface;
11+
use Bavix\Wallet\Internal\Exceptions\LockProviderNotFoundException;
1112
use Bavix\Wallet\Internal\Exceptions\ModelNotFoundException;
13+
use Bavix\Wallet\Internal\Exceptions\RecordNotFoundException;
1214
use Bavix\Wallet\Internal\Exceptions\TransactionFailedException;
1315
use Bavix\Wallet\Models\Transfer;
1416
use Illuminate\Database\RecordsNotFoundException;
@@ -19,6 +21,8 @@ interface Customer extends Wallet
1921
* @throws ProductEnded
2022
* @throws BalanceIsEmpty
2123
* @throws InsufficientFunds
24+
* @throws LockProviderNotFoundException
25+
* @throws RecordNotFoundException
2226
* @throws RecordsNotFoundException
2327
* @throws TransactionFailedException
2428
* @throws ExceptionInterface
@@ -31,6 +35,8 @@ public function safePay(Product $product, bool $force = false): ?Transfer;
3135
* @throws ProductEnded
3236
* @throws BalanceIsEmpty
3337
* @throws InsufficientFunds
38+
* @throws LockProviderNotFoundException
39+
* @throws RecordNotFoundException
3440
* @throws RecordsNotFoundException
3541
* @throws TransactionFailedException
3642
* @throws ExceptionInterface
@@ -39,6 +45,8 @@ public function pay(Product $product, bool $force = false): Transfer;
3945

4046
/**
4147
* @throws ProductEnded
48+
* @throws LockProviderNotFoundException
49+
* @throws RecordNotFoundException
4250
* @throws RecordsNotFoundException
4351
* @throws TransactionFailedException
4452
* @throws ExceptionInterface
@@ -50,6 +58,8 @@ public function safeRefund(Product $product, bool $force = false, bool $gifts =
5058
/**
5159
* @throws BalanceIsEmpty
5260
* @throws InsufficientFunds
61+
* @throws LockProviderNotFoundException
62+
* @throws RecordNotFoundException
5363
* @throws RecordsNotFoundException
5464
* @throws TransactionFailedException
5565
* @throws ModelNotFoundException
@@ -58,6 +68,8 @@ public function safeRefund(Product $product, bool $force = false, bool $gifts =
5868
public function refund(Product $product, bool $force = false, bool $gifts = false): bool;
5969

6070
/**
71+
* @throws LockProviderNotFoundException
72+
* @throws RecordNotFoundException
6173
* @throws RecordsNotFoundException
6274
* @throws TransactionFailedException
6375
* @throws ModelNotFoundException
@@ -70,6 +82,8 @@ public function safeRefundGift(Product $product, bool $force = false): bool;
7082
/**
7183
* @throws BalanceIsEmpty
7284
* @throws InsufficientFunds
85+
* @throws LockProviderNotFoundException
86+
* @throws RecordNotFoundException
7387
* @throws RecordsNotFoundException
7488
* @throws TransactionFailedException
7589
* @throws ModelNotFoundException
@@ -78,6 +92,8 @@ public function safeRefundGift(Product $product, bool $force = false): bool;
7892
public function refundGift(Product $product, bool $force = false): bool;
7993

8094
/**
95+
* @throws LockProviderNotFoundException
96+
* @throws RecordNotFoundException
8197
* @throws RecordsNotFoundException
8298
* @throws TransactionFailedException
8399
* @throws ModelNotFoundException
@@ -89,6 +105,8 @@ public function forceRefundGift(Product $product): bool;
89105
* @throws ProductEnded
90106
* @throws BalanceIsEmpty
91107
* @throws InsufficientFunds
108+
* @throws LockProviderNotFoundException
109+
* @throws RecordNotFoundException
92110
* @throws RecordsNotFoundException
93111
* @throws TransactionFailedException
94112
* @throws ExceptionInterface
@@ -104,6 +122,8 @@ public function safePayCart(CartInterface $cart, bool $force = false): array;
104122
* @throws ProductEnded
105123
* @throws BalanceIsEmpty
106124
* @throws InsufficientFunds
125+
* @throws LockProviderNotFoundException
126+
* @throws RecordNotFoundException
107127
* @throws RecordsNotFoundException
108128
* @throws TransactionFailedException
109129
* @throws ExceptionInterface
@@ -114,6 +134,8 @@ public function payCart(CartInterface $cart, bool $force = false): array;
114134

115135
/**
116136
* @throws ProductEnded
137+
* @throws LockProviderNotFoundException
138+
* @throws RecordNotFoundException
117139
* @throws RecordsNotFoundException
118140
* @throws TransactionFailedException
119141
* @throws ExceptionInterface
@@ -127,6 +149,8 @@ public function safeRefundCart(CartInterface $cart, bool $force = false, bool $g
127149
/**
128150
* @throws BalanceIsEmpty
129151
* @throws InsufficientFunds
152+
* @throws LockProviderNotFoundException
153+
* @throws RecordNotFoundException
130154
* @throws RecordsNotFoundException
131155
* @throws TransactionFailedException
132156
* @throws ModelNotFoundException
@@ -135,6 +159,8 @@ public function safeRefundCart(CartInterface $cart, bool $force = false, bool $g
135159
public function refundCart(CartInterface $cart, bool $force = false, bool $gifts = false): bool;
136160

137161
/**
162+
* @throws LockProviderNotFoundException
163+
* @throws RecordNotFoundException
138164
* @throws RecordsNotFoundException
139165
* @throws TransactionFailedException
140166
* @throws ModelNotFoundException
@@ -147,6 +173,8 @@ public function safeRefundGiftCart(CartInterface $cart, bool $force = false): bo
147173
/**
148174
* @throws BalanceIsEmpty
149175
* @throws InsufficientFunds
176+
* @throws LockProviderNotFoundException
177+
* @throws RecordNotFoundException
150178
* @throws RecordsNotFoundException
151179
* @throws TransactionFailedException
152180
* @throws ModelNotFoundException
@@ -155,6 +183,8 @@ public function safeRefundGiftCart(CartInterface $cart, bool $force = false): bo
155183
public function refundGiftCart(CartInterface $cart, bool $force = false): bool;
156184

157185
/**
186+
* @throws LockProviderNotFoundException
187+
* @throws RecordNotFoundException
158188
* @throws RecordsNotFoundException
159189
* @throws TransactionFailedException
160190
* @throws ModelNotFoundException

src/Interfaces/Exchangeable.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Bavix\Wallet\Exceptions\InsufficientFunds;
99
use Bavix\Wallet\Internal\Exceptions\ExceptionInterface;
1010
use Bavix\Wallet\Internal\Exceptions\LockProviderNotFoundException;
11+
use Bavix\Wallet\Internal\Exceptions\RecordNotFoundException;
1112
use Bavix\Wallet\Internal\Exceptions\TransactionFailedException;
1213
use Bavix\Wallet\Models\Transfer;
1314
use Illuminate\Database\RecordsNotFoundException;
@@ -20,6 +21,7 @@ interface Exchangeable
2021
* @throws BalanceIsEmpty
2122
* @throws InsufficientFunds
2223
* @throws LockProviderNotFoundException
24+
* @throws RecordNotFoundException
2325
* @throws RecordsNotFoundException
2426
* @throws TransactionFailedException
2527
* @throws ExceptionInterface
@@ -35,6 +37,7 @@ public function safeExchange(Wallet $to, $amount, ?array $meta = null): ?Transfe
3537
* @param int|string $amount
3638
*
3739
* @throws LockProviderNotFoundException
40+
* @throws RecordNotFoundException
3841
* @throws RecordsNotFoundException
3942
* @throws TransactionFailedException
4043
* @throws ExceptionInterface

src/Interfaces/Wallet.php

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,24 @@
77
use Bavix\Wallet\Exceptions\AmountInvalid;
88
use Bavix\Wallet\Exceptions\BalanceIsEmpty;
99
use Bavix\Wallet\Exceptions\InsufficientFunds;
10+
use Bavix\Wallet\Internal\Exceptions\ExceptionInterface;
11+
use Bavix\Wallet\Internal\Exceptions\LockProviderNotFoundException;
12+
use Bavix\Wallet\Internal\Exceptions\TransactionFailedException;
1013
use Bavix\Wallet\Models\Transaction;
1114
use Bavix\Wallet\Models\Transfer;
1215
use Illuminate\Database\Eloquent\Relations\MorphMany;
16+
use Illuminate\Database\RecordsNotFoundException;
1317

1418
interface Wallet
1519
{
1620
/**
1721
* @param int|string $amount
1822
*
1923
* @throws AmountInvalid
24+
* @throws LockProviderNotFoundException
25+
* @throws RecordsNotFoundException
26+
* @throws TransactionFailedException
27+
* @throws ExceptionInterface
2028
*/
2129
public function deposit($amount, ?array $meta = null, bool $confirmed = true): Transaction;
2230

@@ -26,34 +34,48 @@ public function deposit($amount, ?array $meta = null, bool $confirmed = true): T
2634
* @throws AmountInvalid
2735
* @throws BalanceIsEmpty
2836
* @throws InsufficientFunds
37+
* @throws LockProviderNotFoundException
38+
* @throws RecordsNotFoundException
39+
* @throws TransactionFailedException
40+
* @throws ExceptionInterface
2941
*/
3042
public function withdraw($amount, ?array $meta = null, bool $confirmed = true): Transaction;
3143

3244
/**
3345
* @param int|string $amount
3446
*
3547
* @throws AmountInvalid
48+
* @throws LockProviderNotFoundException
49+
* @throws RecordsNotFoundException
50+
* @throws TransactionFailedException
51+
* @throws ExceptionInterface
3652
*/
3753
public function forceWithdraw($amount, ?array $meta = null, bool $confirmed = true): Transaction;
3854

3955
/**
4056
* @param int|string $amount
4157
*
4258
* @throws AmountInvalid
59+
* @throws BalanceIsEmpty
60+
* @throws InsufficientFunds
61+
* @throws LockProviderNotFoundException
62+
* @throws RecordsNotFoundException
63+
* @throws TransactionFailedException
64+
* @throws ExceptionInterface
4365
*/
4466
public function transfer(self $wallet, $amount, ?array $meta = null): Transfer;
4567

46-
/**
47-
* @param int|string $amount
48-
*
49-
* @throws AmountInvalid
50-
*/
68+
/** @param int|string $amount */
5169
public function safeTransfer(self $wallet, $amount, ?array $meta = null): ?Transfer;
5270

5371
/**
5472
* @param int|string $amount
5573
*
5674
* @throws AmountInvalid
75+
* @throws LockProviderNotFoundException
76+
* @throws RecordsNotFoundException
77+
* @throws TransactionFailedException
78+
* @throws ExceptionInterface
5779
*/
5880
public function forceTransfer(self $wallet, $amount, ?array $meta = null): Transfer;
5981

src/Interfaces/WalletFloat.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,63 @@
44

55
namespace Bavix\Wallet\Interfaces;
66

7+
use Bavix\Wallet\Exceptions\AmountInvalid;
8+
use Bavix\Wallet\Exceptions\BalanceIsEmpty;
9+
use Bavix\Wallet\Exceptions\InsufficientFunds;
10+
use Bavix\Wallet\Internal\Exceptions\ExceptionInterface;
11+
use Bavix\Wallet\Internal\Exceptions\LockProviderNotFoundException;
12+
use Bavix\Wallet\Internal\Exceptions\TransactionFailedException;
713
use Bavix\Wallet\Models\Transaction;
814
use Bavix\Wallet\Models\Transfer;
15+
use Illuminate\Database\RecordsNotFoundException;
916

1017
interface WalletFloat
1118
{
1219
/**
1320
* @param float|string $amount
21+
*
22+
* @throws AmountInvalid
23+
* @throws LockProviderNotFoundException
24+
* @throws RecordsNotFoundException
25+
* @throws TransactionFailedException
26+
* @throws ExceptionInterface
1427
*/
1528
public function depositFloat($amount, ?array $meta = null, bool $confirmed = true): Transaction;
1629

1730
/**
1831
* @param float|string $amount
32+
*
33+
* @throws AmountInvalid
34+
* @throws BalanceIsEmpty
35+
* @throws InsufficientFunds
36+
* @throws LockProviderNotFoundException
37+
* @throws RecordsNotFoundException
38+
* @throws TransactionFailedException
39+
* @throws ExceptionInterface
1940
*/
2041
public function withdrawFloat($amount, ?array $meta = null, bool $confirmed = true): Transaction;
2142

2243
/**
2344
* @param float|string $amount
45+
*
46+
* @throws AmountInvalid
47+
* @throws LockProviderNotFoundException
48+
* @throws RecordsNotFoundException
49+
* @throws TransactionFailedException
50+
* @throws ExceptionInterface
2451
*/
2552
public function forceWithdrawFloat($amount, ?array $meta = null, bool $confirmed = true): Transaction;
2653

2754
/**
2855
* @param float|string $amount
56+
*
57+
* @throws AmountInvalid
58+
* @throws BalanceIsEmpty
59+
* @throws InsufficientFunds
60+
* @throws LockProviderNotFoundException
61+
* @throws RecordsNotFoundException
62+
* @throws TransactionFailedException
63+
* @throws ExceptionInterface
2964
*/
3065
public function transferFloat(Wallet $wallet, $amount, ?array $meta = null): Transfer;
3166

@@ -36,6 +71,12 @@ public function safeTransferFloat(Wallet $wallet, $amount, ?array $meta = null):
3671

3772
/**
3873
* @param float|string $amount
74+
*
75+
* @throws AmountInvalid
76+
* @throws LockProviderNotFoundException
77+
* @throws RecordsNotFoundException
78+
* @throws TransactionFailedException
79+
* @throws ExceptionInterface
3980
*/
4081
public function forceTransferFloat(Wallet $wallet, $amount, ?array $meta = null): Transfer;
4182

src/Services/CommonServiceLegacy.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Bavix\Wallet\Services;
66

7-
use Bavix\Wallet\Exceptions\AmountInvalid;
87
use Bavix\Wallet\Interfaces\Wallet;
98
use Bavix\Wallet\Internal\Assembler\TransferDtoAssemblerInterface;
109
use Bavix\Wallet\Internal\Dto\TransactionDtoInterface;
@@ -18,7 +17,6 @@
1817
use Bavix\Wallet\Models\Transfer;
1918
use Bavix\Wallet\Models\Wallet as WalletModel;
2019
use Illuminate\Database\RecordsNotFoundException;
21-
use Throwable;
2220

2321
final class CommonServiceLegacy
2422
{
@@ -51,8 +49,11 @@ public function __construct(
5149
/**
5250
* @param int|string $amount
5351
*
54-
* @throws AmountInvalid
55-
* @throws Throwable
52+
* @throws LockProviderNotFoundException
53+
* @throws RecordNotFoundException
54+
* @throws RecordsNotFoundException
55+
* @throws TransactionFailedException
56+
* @throws ExceptionInterface
5657
*/
5758
public function forceTransfer(Wallet $from, Wallet $to, $amount, ?array $meta = null, string $status = Transfer::STATUS_TRANSFER): Transfer
5859
{
@@ -65,6 +66,8 @@ public function forceTransfer(Wallet $from, Wallet $to, $amount, ?array $meta =
6566
/**
6667
* @param non-empty-array<TransferLazyDtoInterface> $objects
6768
*
69+
* @throws LockProviderNotFoundException
70+
* @throws RecordNotFoundException
6871
* @throws RecordsNotFoundException
6972
* @throws TransactionFailedException
7073
* @throws ExceptionInterface
@@ -149,6 +152,9 @@ public function addBalance(Wallet $wallet, $amount): bool
149152

150153
/**
151154
* @param float|int|string $amount
155+
*
156+
* @throws LockProviderNotFoundException
157+
* @throws RecordNotFoundException
152158
*/
153159
public function makeTransaction(Wallet $wallet, string $type, $amount, ?array $meta, bool $confirmed = true): Transaction
154160
{

0 commit comments

Comments
 (0)