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

jomweb / billplz / 4857766929

pending completion
4857766929

push

github

Mior Muhammad Zaki
wip

198 of 201 relevant lines covered (98.51%)

18.38 hits per line

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

88.89
/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
    ];
33

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

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

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

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

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

82
        return $this;
×
83
    }
84

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

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

102
        return $this;
26✔
103
    }
104

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

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

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

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

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

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

165
    /**
166
     * Get bank resource.
167
     *
168
     * @return \Billplz\Contracts\BankAccount
169
     */
170
    final public function bank(?string $version = null): Contracts\BankAccount
171
    {
172
        return $this->uses('BankAccount', $version);
5✔
173
    }
174

175
    /**
176
     * Get card resource.
177
     *
178
     * @return \Billplz\Contracts\Card
179
     */
180
    final public function card(): Contracts\Card
181
    {
182
        return $this->uses('Card', 'v4');
1✔
183
    }
184

185
    /**
186
     * Get resource default namespace.
187
     */
188
    final protected function getResourceNamespace(): string
189
    {
190
        return __NAMESPACE__;
119✔
191
    }
192
}
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