Issues (9)

src/Helpers/Validation.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace HopekellDev\DanArewa\Helpers;
4
5
use Illuminate\Support\Facades\Http;
0 ignored issues
show
The type Illuminate\Support\Facades\Http was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
7
class Validation
8
{
9
    protected string $apiKey;
10
    protected string $baseUrl;
11
12
    public function __construct(string $apiKey, string $baseUrl)
13
    {
14
        $this->apiKey = $apiKey;
15
        $this->baseUrl = $baseUrl;
16
    }
17
18
    /**
19
     * Validate ID - Instantly
20
     *
21
     * @param string $nin
22
     * @return array|null
23
     */
24
    public function validate(string $nin): ?array
25
    {
26
        $response = Http::withHeaders([
27
            'Authorization' => "Bearer {$this->apiKey}",
28
            'Content-Type'  => 'application/json',
29
        ])->post("{$this->baseUrl}/val/", [
30
            'number' => $nin,
31
        ]);
32
33
        return $response->json() ?? null;
34
    }
35
36
    /**
37
     * Check validation status
38
     *
39
     * @param string $nin
40
     * @return array|null
41
     */
42
    public function validateStatus(string $nin): ?array
43
    {
44
        $response = Http::withHeaders([
45
            'Authorization' => "Bearer {$this->apiKey}",
46
            'Content-Type'  => 'application/json',
47
        ])->post("{$this->baseUrl}/val/status", [
48
            'number' => $nin,
49
        ]);
50
51
        return $response->json() ?? null;
52
    }
53
}
54