Issues (9)

src/Helpers/Verifications.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
/**
8
 * DanArewa's Identity Verification Laravel Package
9
 * 
10
 * @author Hope Ezenwa
11
 * @version 1.0.0
12
 */
13
14
class Verifications
15
{
16
    protected string $apiKey;
17
    protected string $baseUrl;
18
19
    public function __construct(string $apiKey, string $baseUrl)
20
    {
21
        $this->apiKey = $apiKey;
22
        $this->baseUrl = rtrim($baseUrl, '/'); // Ensure no trailing slash
23
    }
24
25
    /**
26
     * Verify NIN number
27
     *
28
     * @param string $nin
29
     * @return array|null
30
     */
31
    public function ninVerification(string $nin): ?array
32
    {
33
        $response = Http::withHeaders([
34
            'Authorization' => "Bearer {$this->apiKey}",
35
            'Content-Type'  => 'application/json',
36
        ])->post("{$this->baseUrl}/nin/", [
37
            'number' => $nin,
38
        ]);
39
40
        return $response->json() ?? null;
41
    }
42
43
    /**
44
     * Verify NIN by phone number
45
     *
46
     * @param string $phone
47
     * @return array|null
48
     */
49
    public function phoneVerification(string $phone): ?array
50
    {
51
        $response = Http::withHeaders([
52
            'Authorization' => "Bearer {$this->apiKey}",
53
            'Content-Type'  => 'application/json',
54
        ])->post("{$this->baseUrl}/phone/", [
55
            'number' => $phone,
56
        ]);
57
58
        return $response->json() ?? null;
59
    }
60
61
    /**
62
     * Verify BVN by number
63
     *
64
     * @param string $bvn
65
     * @return array|null
66
     */
67
    public function bvnVerification(string $bvn): ?array
68
    {
69
        $response = Http::withHeaders([
70
            'Authorization' => "Bearer {$this->apiKey}",
71
            'Content-Type'  => 'application/json',
72
        ])->post("{$this->baseUrl}/bvn/", [
73
            'number' => $bvn,
74
        ]);
75
76
        return $response->json() ?? null;
77
    }
78
79
    /**
80
     * Verify NIN by Tracking ID
81
     *
82
     * @param string $trackingId
83
     * @return array|null
84
     */
85
    public function trackingIdVerification(string $trackingId): ?array
86
    {
87
        $response = Http::withHeaders([
88
            'Authorization' => "Bearer {$this->apiKey}",
89
            'Content-Type'  => 'application/json',
90
        ])->post("{$this->baseUrl}/tracking-id/", [
91
            'number' => $trackingId,
92
        ]);
93
94
        return $response->json() ?? null;
95
    }
96
}
97