1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Yabacon\Paystack\Routes; |
4
|
|
|
|
5
|
|
|
use Yabacon\Paystack\Contracts\RouteInterface; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Customer |
9
|
|
|
* Insert description here |
10
|
|
|
* |
11
|
|
|
* @category |
12
|
|
|
* @package |
13
|
|
|
* @author |
14
|
|
|
* @copyright |
15
|
|
|
* @license |
16
|
|
|
* @version |
17
|
|
|
* @link |
18
|
|
|
* @see |
19
|
|
|
* @since |
20
|
|
|
*/ |
21
|
|
|
class Customer implements RouteInterface |
22
|
|
|
{ |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
Root |
26
|
|
|
* |
27
|
|
|
@param=> first_name, last_name, email, phone |
28
|
|
|
*/ |
29
|
3 |
|
public static function root() |
30
|
|
|
{ |
31
|
3 |
|
return '/customer'; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
Create customer |
36
|
|
|
* |
37
|
|
|
@param=> first_name, last_name, email, phone |
38
|
|
|
*/ |
39
|
2 |
|
public static function create() |
40
|
|
|
{ |
41
|
|
|
return [ |
42
|
2 |
|
RouteInterface::METHOD_KEY => RouteInterface::POST_METHOD, |
43
|
2 |
|
RouteInterface::ENDPOINT_KEY => Customer::root(), |
44
|
2 |
|
RouteInterface::PARAMS_KEY => ['first_name', |
45
|
2 |
|
'last_name', |
46
|
2 |
|
'email', |
47
|
2 |
|
'metadata', |
48
|
2 |
|
'phone' ], |
49
|
2 |
|
RouteInterface::REQUIRED_KEY => [ |
50
|
2 |
|
RouteInterface::PARAMS_KEY => ['first_name', |
51
|
2 |
|
'last_name', |
52
|
2 |
|
'email' ] |
53
|
2 |
|
] |
54
|
2 |
|
]; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
Get customer by ID or code |
59
|
|
|
*/ |
60
|
2 |
|
public static function fetch() |
61
|
|
|
{ |
62
|
|
|
return [ |
63
|
2 |
|
RouteInterface::METHOD_KEY => RouteInterface::GET_METHOD, |
64
|
2 |
|
RouteInterface::ENDPOINT_KEY => Customer::root() . '/{id}', |
65
|
2 |
|
RouteInterface::ARGS_KEY => ['id' ], |
66
|
2 |
|
RouteInterface::REQUIRED_KEY => [RouteInterface::ARGS_KEY => ['id' ] ] |
67
|
2 |
|
]; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
List customers |
72
|
|
|
*/ |
73
|
2 |
|
public static function getList() |
74
|
|
|
{ |
75
|
|
|
return [ |
76
|
2 |
|
RouteInterface::METHOD_KEY => RouteInterface::GET_METHOD, |
77
|
2 |
|
RouteInterface::ENDPOINT_KEY => Customer::root(), |
78
|
2 |
|
RouteInterface::PARAMS_KEY => ['perPage', |
79
|
2 |
|
'page' ] |
80
|
2 |
|
]; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
Update customer |
85
|
|
|
* |
86
|
|
|
@param=> first_name, last_name, email, phone |
87
|
|
|
*/ |
88
|
2 |
|
public static function update() |
89
|
|
|
{ |
90
|
|
|
return [ |
91
|
2 |
|
RouteInterface::METHOD_KEY => RouteInterface::PUT_METHOD, |
92
|
2 |
|
RouteInterface::ENDPOINT_KEY => Customer::root() . '/{id}', |
93
|
2 |
|
RouteInterface::PARAMS_KEY => ['first_name', |
94
|
2 |
|
'last_name', |
95
|
2 |
|
'email', |
96
|
2 |
|
'metadata', |
97
|
2 |
|
'phone' ], |
98
|
2 |
|
RouteInterface::ARGS_KEY => ['id' ] |
99
|
2 |
|
]; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|