SendPaymentRequest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 70
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getHeaders() 0 5 1
A __construct() 0 6 1
A getPathParams() 0 3 1
A getBody() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Package: PHP Bitaps API
7
 *
8
 * (c) Eldar Gazaliev <[email protected]>
9
 *
10
 *  Link: <https://github.com/MyZik>
11
 *
12
 * For the full copyright and license information, please view the LICENSE file
13
 * that was distributed with this source code.
14
 */
15
16
namespace Bitaps\WalletAPI\Request;
17
18
class SendPaymentRequest implements RequestInterface
19
{
20
    /**
21
     * Wallet ID
22
     *
23
     * @var string
24
     */
25
    private string $walletId;
26
27
    /**
28
     * Receivers list [{"address":{address}, "amount":{amount}, ...], maximum 100 recipients
29
     *
30
     * @var array
31
     */
32
    private array $receiversList;
33
34
    /**
35
     * Nonce used for HMAC signature
36
     *
37
     * @var float|null
38
     */
39
    public ?float $nonce;
40
41
    /**
42
     * HMAC signature
43
     *
44
     * @var string|null
45
     */
46
    public ?string $signature;
47
48
    /**
49
     * @param string      $walletId
50
     * @param array       $receiversList
51
     * @param float|null  $nonce
52
     * @param string|null $signature
53
     */
54
    public function __construct(string $walletId, array $receiversList, float $nonce = null, string $signature = null)
55
    {
56
        $this->walletId      = $walletId;
57
        $this->receiversList = $receiversList;
58
        $this->nonce         = $nonce;
59
        $this->signature     = $signature;
60
    }
61
62
    /**
63
     * @return string
64
     */
65
    public function getPathParams(): string
66
    {
67
        return sprintf('/wallet/send/payment/%s', $this->walletId);
68
    }
69
70
    /**
71
     * @return array
72
     */
73
    public function getHeaders(): array
74
    {
75
        return [
76
            'Access-Nonce' => $this->nonce,
77
            'Access-Signature' => $this->signature
78
        ];
79
    }
80
81
    /**
82
     * @return array
83
     */
84
    public function getBody(): array
85
    {
86
        return [
87
            'receivers_list' => $this->receiversList,
88
        ];
89
    }
90
}
91