1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created By: Henry Ejemuta |
4
|
|
|
* PC: Enrico Systems |
5
|
|
|
* Project: laravel-clubkonnect |
6
|
|
|
* Company: Stimolive Technologies Limited |
7
|
|
|
* Class Name: Transaction.php |
8
|
|
|
* Date Created: 5/14/21 |
9
|
|
|
* Time Created: 10:24 AM |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace HenryEjemuta\LaravelClubKonnect; |
13
|
|
|
|
14
|
|
|
use HenryEjemuta\LaravelClubKonnect\Classes\ClubKonnectResponse; |
15
|
|
|
use HenryEjemuta\LaravelClubKonnect\Enums\DiscoEnum; |
16
|
|
|
use HenryEjemuta\LaravelClubKonnect\Enums\MeterTypeEnum; |
17
|
|
|
|
18
|
|
View Code Duplication |
abstract class Electricity |
|
|
|
|
19
|
|
|
{ |
20
|
|
|
private $config; |
21
|
|
|
private $clubKonnect; |
22
|
|
|
|
23
|
|
|
public function __construct(ClubKonnect $clubKonnect, $config) |
24
|
|
|
{ |
25
|
|
|
$this->config = $config; |
26
|
|
|
$this->clubKonnect = $clubKonnect; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @return ClubKonnectResponse |
31
|
|
|
*/ |
32
|
|
|
public function getDiscosAndMinMax(): ClubKonnectResponse |
33
|
|
|
{ |
34
|
|
|
return $this->clubKonnect->withAuth('APIElectricityDiscosV1.asp', []); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param DiscoEnum $disco |
39
|
|
|
* @param $meterNumber |
40
|
|
|
* @return ClubKonnectResponse |
41
|
|
|
*/ |
42
|
|
|
public function verifyMeterNumber(DiscoEnum $disco, $meterNumber): ClubKonnectResponse |
43
|
|
|
{ |
44
|
|
|
return $this->clubKonnect->withAuth('APIVerifyElectricityV1.asp', [ |
45
|
|
|
'ElectricCompany' => $disco->getCode(), |
46
|
|
|
'MeterNo' => $meterNumber, |
47
|
|
|
]); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param DiscoEnum $disco |
52
|
|
|
* @param $meterNumber |
53
|
|
|
* @param $amount |
54
|
|
|
* @param MeterTypeEnum $meterType |
55
|
|
|
* @param $requestID |
56
|
|
|
* @param $callbackUrl |
57
|
|
|
* @return ClubKonnectResponse |
58
|
|
|
*/ |
59
|
|
|
public function buyElectricity(DiscoEnum $disco, $meterNumber, $amount, MeterTypeEnum $meterType, $requestID, $callbackUrl = null): ClubKonnectResponse |
60
|
|
|
{ |
61
|
|
|
$callbackUrl = is_null($callbackUrl) ? $this->config['default_redirect_url'] : $callbackUrl; |
62
|
|
|
return $this->clubKonnect->withAuth('APIElectricityV1.asp', [ |
63
|
|
|
'ElectricCompany' => $disco->getCode(), |
64
|
|
|
'MeterNo' => $meterNumber, |
65
|
|
|
'Amount' => $amount, |
66
|
|
|
'MeterType' => $meterType->getCode(), |
67
|
|
|
'RequestID' => $requestID, |
68
|
|
|
'CallBackURL' => $callbackUrl |
69
|
|
|
]); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
} |
73
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.