WalletTransactionsRequest::getPathParams()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 10
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 WalletTransactionsRequest implements RequestInterface
19
{
20
    /**
21
     * Wallet ID
22
     *
23
     * @var string
24
     */
25
    public string $walletId;
26
27
    /**
28
     * Nonce used for HMAC signature
29
     *
30
     * @var float|null
31
     */
32
    public ?float $nonce;
33
34
    /**
35
     * HMAC signature
36
     *
37
     * @var string|null
38
     */
39
    public ?string $signature;
40
41
    /**
42
     * Beginning of range in unix timestamp
43
     *
44
     * @var int|null
45
     */
46
    private ?int $from;
47
48
    /**
49
     * Ending of range in unix timestamp
50
     *
51
     * @var int|null
52
     */
53
    private ?int $to;
54
55
    /**
56
     * Records on page
57
     *
58
     * @var int|null
59
     */
60
    private ?int $limit;
61
62
    /**
63
     * Page number
64
     *
65
     * @var int|null
66
     */
67
    private ?int $page;
68
69
    /**
70
     * @param string      $walletId
71
     * @param float|null  $nonce
72
     * @param string|null $signature
73
     * @param int|null    $from
74
     * @param int|null    $to
75
     * @param int|null    $limit
76
     * @param int|null    $page
77
     */
78
    public function __construct(
79
        string $walletId,
80
        float $nonce = null,
81
        string $signature = null,
82
        int $from = null,
83
        int $to = null,
84
        int $limit = null,
85
        int $page = null
86
    ) {
87
        $this->walletId  = $walletId;
88
        $this->nonce     = $nonce;
89
        $this->signature = $signature;
90
        $this->from      = $from;
91
        $this->to        = $to;
92
        $this->limit     = $limit;
93
        $this->page      = $page;
94
    }
95
96
    /**
97
     * @return string
98
     */
99
    public function getPathParams(): string
100
    {
101
        return sprintf(
102
            "/wallet/transactions/%s?from=%d&to=%d&limit=%d&page=%d",
103
            $this->walletId,
104
            $this->from,
105
            $this->to,
106
            $this->limit,
107
            $this->page
108
        );
109
    }
110
111
    /**
112
     * @return array
113
     */
114
    public function getHeaders(): array
115
    {
116
        return [
117
            'Access-Nonce' => $this->nonce,
118
            'Access-Signature' => $this->signature
119
        ];
120
    }
121
122
    /**
123
     * @return array
124
     */
125
    public function getBody(): array
126
    {
127
        return [];
128
    }
129
}
130