1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the PayBreak/paybreak-sdk-php package. |
4
|
|
|
* |
5
|
|
|
* (c) PayBreak <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace PayBreak\Sdk\Gateways; |
12
|
|
|
|
13
|
|
|
use PayBreak\Sdk\Entities\Profile\AddressEntity; |
14
|
|
|
use PayBreak\Sdk\Entities\Profile\EmploymentEntity; |
15
|
|
|
use PayBreak\Sdk\Entities\Profile\FinancialEntity; |
16
|
|
|
use PayBreak\Sdk\Entities\Profile\PersonalEntity; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Class ProfileGateway |
20
|
|
|
* |
21
|
|
|
* @author EB |
22
|
|
|
* @package PayBreak\Sdk\Gateways |
23
|
|
|
*/ |
24
|
|
|
class ProfileGateway extends AbstractGateway |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @author EB |
28
|
|
|
* @param $application |
29
|
|
|
* @param array $personal |
30
|
|
|
* @param $token |
31
|
|
|
* @return array |
32
|
|
|
*/ |
33
|
|
|
public function createPersonal($application, array $personal, $token) |
34
|
|
|
{ |
35
|
|
|
$entity = PersonalEntity::make($personal); |
36
|
|
|
|
37
|
|
|
return $this->postDocument( |
38
|
|
|
'/v4/applications/' . $application . '/user', |
39
|
|
|
$entity->toArray(), |
40
|
|
|
$token, |
41
|
|
|
'Personal' |
42
|
|
|
); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @author EA |
47
|
|
|
* @param int $user |
48
|
|
|
* @param array $personal |
49
|
|
|
* @param $token |
50
|
|
|
* @return array |
51
|
|
|
*/ |
52
|
|
|
public function setPersonal($user, array $personal, $token) |
53
|
|
|
{ |
54
|
|
|
$entity = PersonalEntity::make($personal); |
55
|
|
|
|
56
|
|
|
return $this->postDocument( |
57
|
|
|
'/v4/users/' . $user . '/personal', |
58
|
|
|
$entity->toArray(), |
59
|
|
|
$token, |
60
|
|
|
'Set Personal' |
61
|
|
|
); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @author EB |
66
|
|
|
* @param int $user |
67
|
|
|
* @param array $financial |
68
|
|
|
* @param $token |
69
|
|
|
* @return array |
70
|
|
|
*/ |
71
|
|
|
public function setFinancial($user, array $financial, $token) |
72
|
|
|
{ |
73
|
|
|
$entity = FinancialEntity::make($financial); |
74
|
|
|
|
75
|
|
|
return $this->postDocument( |
76
|
|
|
'/v4/users/' . $user . '/financial', |
77
|
|
|
$entity->toArray(), |
78
|
|
|
$token, |
79
|
|
|
'Set Financial' |
80
|
|
|
); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @author EA |
85
|
|
|
* @param int $user |
86
|
|
|
* @param array $employment |
87
|
|
|
* @param $token |
88
|
|
|
* @return array |
89
|
|
|
*/ |
90
|
|
|
public function setEmployment($user, array $employment, $token) |
91
|
|
|
{ |
92
|
|
|
$entity = EmploymentEntity::make($employment); |
93
|
|
|
|
94
|
|
|
return $this->postDocument( |
95
|
|
|
'/v4/users/' . $user . '/employment', |
96
|
|
|
$entity->toArray(), |
97
|
|
|
$token, |
98
|
|
|
'Set Employment' |
99
|
|
|
); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @author EB |
104
|
|
|
* @param $user |
105
|
|
|
* @param string $token |
106
|
|
|
* @return array |
107
|
|
|
*/ |
108
|
|
|
public function getAddresses($user, $token) |
109
|
|
|
{ |
110
|
|
|
return $this->fetchDocument('/v4/users/' . $user . '/addresses', $token, 'Fetch Addresses'); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @author EB |
115
|
|
|
* @param $user |
116
|
|
|
* @param array $address |
117
|
|
|
* @param string $token |
118
|
|
|
* @return array |
119
|
|
|
*/ |
120
|
|
|
public function addAddress($user, array $address, $token) |
121
|
|
|
{ |
122
|
|
|
return $this->postDocument( |
123
|
|
|
'/v4/users/' . $user . '/address', |
124
|
|
|
AddressEntity::make($address)->toArray(), |
125
|
|
|
$token, |
126
|
|
|
'Add Address' |
127
|
|
|
); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @author EB |
132
|
|
|
* @param $user |
133
|
|
|
* @param $address |
134
|
|
|
* @param string $token |
135
|
|
|
* @return array |
136
|
|
|
*/ |
137
|
|
|
public function removeAddress($user, $address, $token) |
138
|
|
|
{ |
139
|
|
|
return $this->deleteDocument( |
140
|
|
|
'/v4/users/' . $user . '/address/' . $address, |
141
|
|
|
$token, |
142
|
|
|
'Remove Address' |
143
|
|
|
); |
144
|
|
|
} |
145
|
|
|
} |
146
|
|
|
|