1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* SmartCall Restful API (v3) HTTP Client. |
4
|
|
|
* |
5
|
|
|
* PLEASE NOTE: The interface is very fluid while the intial integration |
6
|
|
|
* is taking place. It will be refactored in the near future. |
7
|
|
|
* |
8
|
|
|
* @author Jacques Marneweck <[email protected]> |
9
|
|
|
* @copyright 2017-2018 Jacques Marneweck. All rights strictly reserved. |
10
|
|
|
* @license MIT |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace Jacques\Smartcall\HttpClient\Traits; |
14
|
|
|
|
15
|
|
|
trait SmartRica |
16
|
|
|
{ |
17
|
|
|
public function changeownership() |
18
|
|
|
{ |
19
|
|
|
try { |
20
|
|
|
$response = $this->post( |
|
|
|
|
21
|
|
|
'/webservice/smartrica/changeownership', |
22
|
|
|
[ |
23
|
|
|
'headers' => [ |
24
|
|
|
'Authorization' => $this->bearerOrBasic(), |
|
|
|
|
25
|
|
|
], |
26
|
|
|
'json' => [ |
27
|
|
|
'agentId' => '27821234567', |
28
|
|
|
'firstName' => 'Jane', |
29
|
|
|
'surname' => 'Doe', |
30
|
|
|
'idDetails' => null, |
31
|
|
|
'registrationType' => null, |
32
|
|
|
'subscriberId' => '8911000000010240123456', |
33
|
|
|
'last4Iccid' => '3456', |
34
|
|
|
'residentialAddress' => null, |
35
|
|
|
'previousIdNumber' => null, |
36
|
|
|
'previousIdType' => null, |
37
|
|
|
'network' => null, |
38
|
|
|
'businessOwnerIdDetails' => null, |
39
|
|
|
], |
40
|
|
|
] |
41
|
|
|
); |
42
|
|
|
|
43
|
|
|
return [ |
44
|
|
|
'status' => 'ok', |
45
|
|
|
'http_code' => $response->getStatusCode(), |
46
|
|
|
'body' => (string) $response->getBody(), |
47
|
|
|
]; |
48
|
|
|
} catch (\GuzzleHttp\Exception\ClientException $e) { |
49
|
|
|
return $this->clientError($e); |
|
|
|
|
50
|
|
|
} catch (\GuzzleHttp\Exception\ServerException $e) { |
51
|
|
|
return $this->parseError($e); |
|
|
|
|
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
55
|
|
View Code Duplication |
public function registrations() |
|
|
|
|
56
|
|
|
{ |
57
|
|
|
try { |
58
|
|
|
$response = $this->post( |
|
|
|
|
59
|
|
|
'/webservice/smartrica/registrations', |
60
|
|
|
[ |
61
|
|
|
'headers' => [ |
62
|
|
|
'Authorization' => $this->bearerOrBasic(), |
|
|
|
|
63
|
|
|
], |
64
|
|
|
] |
65
|
|
|
); |
66
|
|
|
|
67
|
|
|
return [ |
68
|
|
|
'status' => 'ok', |
69
|
|
|
'http_code' => $response->getStatusCode(), |
70
|
|
|
'body' => (string) $response->getBody(), |
71
|
|
|
]; |
72
|
|
|
} catch (\GuzzleHttp\Exception\ClientException $e) { |
73
|
|
|
return $this->clientError($e); |
|
|
|
|
74
|
|
|
} catch (\GuzzleHttp\Exception\ServerException $e) { |
75
|
|
|
return $this->parseError($e); |
|
|
|
|
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.