forked from nemiah/phpFinTS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSendInternationalCreditTransfer.php
More file actions
88 lines (77 loc) · 2.83 KB
/
SendInternationalCreditTransfer.php
File metadata and controls
88 lines (77 loc) · 2.83 KB
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
<?php
namespace Fhp\Action;
use Fhp\BaseAction;
use Fhp\Model\SEPAAccount;
use Fhp\Protocol\BPD;
use Fhp\Protocol\UPD;
use Fhp\Segment\AUB\HIAUBSv9;
use Fhp\Segment\AUB\HKAUBv9;
use Fhp\Segment\Common\Kti;
use Fhp\Syntax\Bin;
class SendInternationalCreditTransfer extends BaseAction
{
// Request (if you add a field here, update __serialize() and __unserialize() as well).
/** @var SEPAAccount */
protected $account;
/** @var string */
protected $dtavzData;
/** @var string|null */
protected $dtavzVersion;
/**
* @param SEPAAccount $account The account of the creditor (the sender of the money)
* @param string $dtavzData The details of the transfer(s) in DTAZV Format (Datenträgeraustauschverfahren Auslandszahlungsverkehr)
* @param string|null $dtavzVersion If null the value the bank expects is used.
*/
public static function create(SEPAAccount $account, string $dtavzData, ?string $dtavzVersion = null): SendInternationalCreditTransfer
{
$result = new SendInternationalCreditTransfer();
$result->account = $account;
$result->dtavzVersion = $dtavzVersion;
$result->dtavzData = $dtavzData;
return $result;
}
/**
* @deprecated Beginning from PHP7.4 __unserialize is used for new generated strings, then this method is only used for previously generated strings - remove after May 2023
*/
public function serialize(): string
{
return serialize($this->__serialize());
}
public function __serialize(): array
{
return [
parent::__serialize(),
$this->account, $this->dtavzData, $this->dtavzVersion,
];
}
/**
* @deprecated Beginning from PHP7.4 __unserialize is used for new generated strings, then this method is only used for previously generated strings - remove after May 2023
*
* @param string $serialized
* @return void
*/
public function unserialize($serialized)
{
self::__unserialize(unserialize($serialized));
}
public function __unserialize(array $serialized): void
{
list(
$parentSerialized,
$this->account, $this->dtavzData, $this->dtavzVersion,
) = $serialized;
is_array($parentSerialized) ?
parent::__unserialize($parentSerialized) :
parent::unserialize($parentSerialized);
}
protected function createRequest(BPD $bpd, ?UPD $upd)
{
/** @var HIAUBSv9 $hiaubs */
$hiaubs = $bpd->requireLatestSupportedParameters('HIAUBS');
$hkaub = HKAUBv9::createEmpty();
$hkaub->kontoverbindungInternational = Kti::fromAccount($this->account);
$hkaub->DTAZVHandbuch = $this->dtavzVersion ?? $hiaubs->parameter->DTAZVHandbuch;
$hkaub->DTAZVDatensatz = new Bin($this->dtavzData);
return $hkaub;
}
}