Completed
Push — master ( 690bad...4d799d )
by Rafael
14s queued 11s
created

BanklyCard::allowContactless()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace WeDevBr\Bankly;
4
5
use WeDevBr\Bankly\Auth\Auth;
6
use WeDevBr\Bankly\Traits\Rest;
7
use WeDevBr\Bankly\Types\Card\Duplicate;
8
use WeDevBr\Bankly\Types\Card\Password;
9
use WeDevBr\Bankly\Types\Card\ChangeStatus;
10
use WeDevBr\Bankly\Types\Card\Wallet;
11
12
/**
13
 * Class BanklyCard
14
 * @author Rafael Teixeira <[email protected]>
15
 * @package WeDevBr\Bankly
16
 */
17
class BanklyCard
18
{
19
    use Rest;
20
21
    /**
22
     * @param string $clientSecret
23
     * @param string $clientId
24
     */
25
    public function __construct($clientSecret = null, $clientId = null)
26
    {
27
        Auth::login()
28
            ->setClientId($clientId)
29
            ->setClientId($clientSecret);
30
    }
31
32
    /**
33
     * @param string $proxy
34
     * @param string $page
35
     * @param integer $pageSize
36
     * @param string $startDate
37
     * @param string $endDate
38
     * @return array
39
     */
40
    public function transactions(string $proxy, string $page, int $pageSize, string $startDate, string $endDate)
41
    {
42
        $query = [
43
            'page' => $page,
44
            'pageSize' => $pageSize,
45
            'startDate' => $startDate,
46
            'endDate' => $endDate
47
        ];
48
49
        return $this->get("/cards/{$proxy}/transactions", $query);
50
    }
51
52
    /**
53
     * @param string $proxy
54
     * @param Duplicate $duplicate
55
     * @return array
56
     */
57
    public function duplicate(string $proxy, Duplicate $duplicate)
58
    {
59
        return $this->post("/cards/{$proxy}/duplicate", $duplicate->toArray(), null, true);
60
    }
61
62
    /**
63
     * @param string $proxy
64
     * @param Password $password
65
     * @return array
66
     */
67
    public function pciData(string $proxy, Password $password)
68
    {
69
        return $this->post("/cards/{$proxy}/pci", $password->toArray(), null, true);
70
    }
71
72
    /**
73
     * @param string $proxy
74
     * @return array
75
     */
76
    public function getByProxy(string $proxy)
77
    {
78
        return $this->get("/cards/{$proxy}");
79
    }
80
81
    /**
82
     * @param string $proxy
83
     * @param ChangeStatus $changeStatus
84
     * @return array
85
     */
86
    public function changeStatus(string $proxy, ChangeStatus $changeStatus)
87
    {
88
        return $this->patch("/cards/{$proxy}/status", $changeStatus->toArray(), null, true);
89
    }
90
91
    /**
92
     * @param string $proxy
93
     * @param bool $allow
94
     * @return array
95
     */
96
    public function allowContactless(string $proxy, bool $allow)
97
    {
98
        $allowContactless = $allow ? 'true' : 'false';
99
        return $this->patch("/cards/{$proxy}/contactless?allowContactless={$allowContactless}", [], null, true);
100
    }
101
102
    /**
103
     * @param string $proxy
104
     * @return array
105
     */
106
    public function nextStatus(string $proxy)
107
    {
108
        return $this->get("/cards/{$proxy}/nextStatus");
109
    }
110
111
    /**
112
     * @param string $proxy
113
     * @param Password $password
114
     * @return array
115
     */
116
    public function changePassword(string $proxy, Password $password)
117
    {
118
        return $this->patch("/cards/{$proxy}/password", $password->toArray(), null, true);
119
    }
120
121
    /**
122
     * @param string $documentNumber
123
     * @return array
124
     */
125
    public function getByDocument(string $documentNumber)
126
    {
127
        return $this->get("/cards/document/{$documentNumber}");
128
    }
129
130
    /**
131
     * @param string $activateCode
132
     * @return array
133
     */
134
    public function getByActivateCode(string $activateCode)
135
    {
136
        return $this->get("/cards/activateCode/{$activateCode}");
137
    }
138
139
    /**
140
     * @param string $account
141
     * @return array
142
     */
143
    public function getByAccount(string $account)
144
    {
145
        return $this->get("/cards/account/{$account}");
146
    }
147
148
    /**
149
     * @param Wallet $wallet
150
     * @return array
151
     */
152
    public function digitalWallet(Wallet $wallet)
153
    {
154
        $pathData = $wallet->toArray();
155
        $endpoint = '/cards-pci/' . $pathData['proxy']
156
            . '/wallet/' . $pathData['wallet']
157
            . '/brand/' . $pathData['brand'];
158
159
        return $this->post($endpoint, [], null, true);
160
    }
161
}
162