• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jomweb / billplz / 5582297249

pending completion
5582297249

push

github

crynobone
wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

198 of 203 relevant lines covered (97.54%)

19.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.0
/src/Client.php
1
<?php
2

3
namespace Billplz;
4

5
use Http\Client\Common\HttpMethodsClient as HttpClient;
6
use Laravie\Codex\Discovery;
7

8
class Client extends \Laravie\Codex\Client
9
{
10
    /**
11
     * Billplz API endpoint.
12
     *
13
     * @var string
14
     */
15
    protected $apiEndpoint = 'https://www.billplz.com/api';
16

17
    /**
18
     * Default API version.
19
     *
20
     * @var string
21
     */
22
    protected $defaultVersion = 'v4';
23

24
    /**
25
     * List of supported API versions.
26
     *
27
     * @var array<string, string>
28
     */
29
    protected $supportedVersions = [
30
        'v3' => 'Three',
31
        'v4' => 'Four',
32
        'v5' => 'Five',
33
    ];
34

35
    /**
36
     * Construct a new Billplz Client.
37
     */
38
    public function __construct(
39
        HttpClient $http,
40
        protected string $apiKey,
41
        protected ?string $signatureKey = null
42
    ) {
43
        $this->http = $http;
133✔
44
    }
45

46
    /**
47
     * Make a client.
48
     *
49
     * @return static
50
     */
51
    public static function make(string $apiKey, ?string $signatureKey = null)
52
    {
53
        return new static(Discovery::client(), $apiKey, $signatureKey);
1✔
54
    }
55

56
    /**
57
     * Use sandbox environment.
58
     *
59
     * @return $this
60
     */
61
    final public function useSandbox(): self
62
    {
63
        return $this->useCustomApiEndpoint('https://www.billplz-sandbox.com/api');
1✔
64
    }
65

66
    /**
67
     * Get API Key.
68
     */
69
    final public function getApiKey(): string
70
    {
71
        return $this->apiKey;
64✔
72
    }
73

74
    /**
75
     * Set API Key.
76
     *
77
     * @return $this
78
     */
79
    final public function setApiKey(string $apiKey): self
80
    {
81
        $this->apiKey = $apiKey;
×
82

83
        return $this;
×
84
    }
85

86
    /**
87
     * Get X-Signature Key.
88
     */
89
    final public function getSignatureKey(): ?string
90
    {
91
        return $this->signatureKey;
26✔
92
    }
93

94
    /**
95
     * Set X-Signature Key.
96
     *
97
     * @return $this
98
     */
99
    final public function setSignatureKey(?string $signatureKey = null): self
100
    {
101
        $this->signatureKey = $signatureKey;
26✔
102

103
        return $this;
26✔
104
    }
105

106
    /**
107
     * Get Collection resource.
108
     *
109
     * @return \Billplz\Contracts\Collection
110
     */
111
    final public function collection(?string $version = null): Contracts\Collection
112
    {
113
        return $this->uses('Collection', $version);
6✔
114
    }
115

116
    /**
117
     * Get Open Collection resource.
118
     *
119
     * @return \Billplz\Contracts\OpenCollection
120
     */
121
    final public function openCollection(?string $version = null): Contracts\OpenCollection
122
    {
123
        return $this->uses('OpenCollection', $version);
5✔
124
    }
125

126
    /**
127
     * Get bill resource.
128
     *
129
     * @return \Billplz\Contracts\Bill
130
     */
131
    final public function bill(?string $version = null): Contracts\Bill
132
    {
133
        return $this->uses('Bill', $version);
5✔
134
    }
135

136
    /**
137
     * Get transaction resource.
138
     *
139
     * @return \Billplz\Contracts\Bill\Transaction
140
     */
141
    final public function transaction(?string $version = null): Contracts\Bill\Transaction
142
    {
143
        return $this->uses('Bill.Transaction', $version);
5✔
144
    }
145

146
    /**
147
     * Get payout instruction collection resource.
148
     *
149
     * @return \Billplz\Contracts\Collection\Payout
150
     */
151
    final public function payoutCollection(): Contracts\Collection\Payout
152
    {
153
        return $this->uses('Collection.Payout', 'v4');
1✔
154
    }
155

156
    /**
157
     * Get payout instruction resource.
158
     *
159
     * @return \Billplz\Contracts\Payout
160
     */
161
    final public function payout(): Contracts\Payout
162
    {
163
        return $this->uses('Payout', 'v4');
1✔
164
    }
165

166
    /**
167
     * Get payout instruction resource.
168
     *
169
     * @return \Billplz\Contracts\PaymentOrder
170
     */
171
    final public function paymentOrder(): Contracts\PaymentOrder
172
    {
173
        return $this->uses('PaymentOrder', 'v5');
×
174
    }
175

176
    /**
177
     * Get payout instruction collection resource.
178
     *
179
     * @return \Billplz\Contracts\PaymentOrderCollection
180
     */
181
    final public function paymentOrderCollection(): Contracts\PaymentOrderCollection
182
    {
183
        return $this->uses('PaymentOrderCollection', 'v5');
×
184
    }
185

186
    /**
187
     * Get bank resource.
188
     *
189
     * @return \Billplz\Contracts\BankAccount
190
     */
191
    final public function bank(?string $version = null): Contracts\BankAccount
192
    {
193
        return $this->uses('BankAccount', $version);
7✔
194
    }
195

196
    /**
197
     * Get card resource.
198
     *
199
     * @return \Billplz\Contracts\Card
200
     */
201
    final public function card(): Contracts\Card
202
    {
203
        return $this->uses('Card', 'v4');
1✔
204
    }
205

206
    /**
207
     * Get resource default namespace.
208
     */
209
    final protected function getResourceNamespace(): string
210
    {
211
        return __NAMESPACE__;
130✔
212
    }
213
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc