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
|
|
|
public static function root() |
30
|
|
|
{ |
31
|
|
|
return '/customer'; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
Create customer |
36
|
|
|
* |
37
|
|
|
@param=> first_name, last_name, email, phone |
38
|
|
|
*/ |
39
|
|
|
public static function create() |
40
|
|
|
{ |
41
|
|
|
return [ |
42
|
|
|
RouteInterface::METHOD_KEY => RouteInterface::POST_METHOD, |
43
|
|
|
RouteInterface::ENDPOINT_KEY => Customer::root(), |
44
|
|
|
RouteInterface::PARAMS_KEY => ['first_name', |
45
|
|
|
'last_name', |
46
|
|
|
'email', |
47
|
|
|
'phone' ], |
48
|
|
|
RouteInterface::REQUIRED_KEY => [ |
49
|
|
|
RouteInterface::PARAMS_KEY => ['first_name', |
50
|
|
|
'last_name', |
51
|
|
|
'email' ] |
52
|
|
|
] |
53
|
|
|
]; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
Get customer by ID or code |
58
|
|
|
*/ |
59
|
|
|
public static function fetch() |
60
|
|
|
{ |
61
|
|
|
return [ |
62
|
|
|
RouteInterface::METHOD_KEY => RouteInterface::GET_METHOD, |
63
|
|
|
RouteInterface::ENDPOINT_KEY => Customer::root() . '/{id}', |
64
|
|
|
RouteInterface::ARGS_KEY => ['id' ], |
65
|
|
|
RouteInterface::REQUIRED_KEY => [RouteInterface::ARGS_KEY => ['id' ] ] |
66
|
|
|
]; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
List customers |
71
|
|
|
*/ |
72
|
|
|
public static function getList() |
73
|
|
|
{ |
74
|
|
|
return [ |
75
|
|
|
RouteInterface::METHOD_KEY => RouteInterface::GET_METHOD, |
76
|
|
|
RouteInterface::ENDPOINT_KEY => Customer::root(), |
77
|
|
|
RouteInterface::PARAMS_KEY => ['perPage', |
78
|
|
|
'page' ] |
79
|
|
|
]; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
Update customer |
84
|
|
|
* |
85
|
|
|
@param=> first_name, last_name, email, phone |
86
|
|
|
*/ |
87
|
|
|
public static function update() |
88
|
|
|
{ |
89
|
|
|
return [ |
90
|
|
|
RouteInterface::METHOD_KEY => RouteInterface::PUT_METHOD, |
91
|
|
|
RouteInterface::ENDPOINT_KEY => Customer::root() . '/{id}', |
92
|
|
|
RouteInterface::PARAMS_KEY => ['first_name', |
93
|
|
|
'last_name', |
94
|
|
|
'email', |
95
|
|
|
'phone' ], |
96
|
|
|
RouteInterface::ARGS_KEY => ['id' ], |
97
|
|
|
RouteInterface::REQUIRED_KEY => [ |
98
|
|
|
RouteInterface::ARGS_KEY => ['id' ], |
99
|
|
|
RouteInterface::PARAMS_KEY => ['first_name', |
100
|
|
|
'last_name' ] |
101
|
|
|
] |
102
|
|
|
]; |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|