1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Application\Api\Field\Query; |
6
|
|
|
|
7
|
|
|
use Application\Model\User; |
8
|
|
|
use Ecodev\Felix\Api\Field\FieldInterface; |
9
|
|
|
use Ecodev\Felix\Service\Bvr; |
10
|
|
|
use GraphQL\Type\Definition\Type; |
11
|
|
|
|
12
|
|
|
abstract class BankingInfos implements FieldInterface |
13
|
|
|
{ |
14
|
1 |
|
public static function build(): array |
15
|
|
|
{ |
16
|
|
|
return |
17
|
|
|
[ |
18
|
1 |
|
'name' => 'bankingInfos', |
19
|
1 |
|
'type' => Type::nonNull(_types()->get('BankingInfos')), |
20
|
1 |
|
'description' => 'Represents currently logged-in user', |
21
|
|
|
'args' => [ |
22
|
1 |
|
'user' => Type::nonNull(_types()->getId(User::class)), |
23
|
1 |
|
'amount' => _types()->get('CHF'), |
24
|
|
|
], |
25
|
|
|
'resolve' => function ($root, array $args): array { |
26
|
|
|
global $container; |
27
|
|
|
$config = $container->get('config')['banking']; |
28
|
|
|
$bankAccount = $config['bankAccount']; |
29
|
|
|
$postAccount = $config['postAccount']; |
30
|
|
|
$paymentTo = $config['paymentTo']; |
31
|
|
|
$paymentFor = $config['paymentFor']; |
32
|
|
|
|
33
|
|
|
$userId = $args['user']->getId(); |
34
|
|
|
$amount = $args['amount'] ?? null; |
35
|
|
|
|
36
|
|
|
$referenceNumber = Bvr::getReferenceNumber($bankAccount, $userId); |
37
|
|
|
$encodingLine = Bvr::getEncodingLine($bankAccount, $userId, $postAccount, $amount); |
38
|
|
|
|
39
|
|
|
return [ |
40
|
|
|
'postAccount' => $postAccount, |
41
|
|
|
'paymentTo' => $paymentTo, |
42
|
|
|
'paymentFor' => $paymentFor, |
43
|
|
|
'referenceNumber' => $referenceNumber, |
44
|
|
|
'encodingLine' => $encodingLine, |
45
|
|
|
]; |
46
|
1 |
|
}, |
47
|
|
|
]; |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|