88
99class ApiUsers {
1010
11- protected static function getApiV2Client () {
11+ protected static function getApiV2Client ($ domain ) {
12+
13+ $ apiDomain = 'https://login.auth0.com ' ;
14+ if (strpos ($ domain , 'eu.auth0.com ' ) !== false ) {
15+ $ apiDomain = 'https://login.eu.auth0.com ' ;
16+ }
17+
1218 return new ApiClient (array (
13- 'domain ' => ' https://login.auth0.com ' ,
19+ 'domain ' => $ apiDomain ,
1420 'basePath ' => '/api/v2 ' ,
1521 ));
1622 }
1723
18- public static function get ($ token , $ user_id ) {
24+ public static function get ($ domain , $ token , $ user_id ) {
1925
20- $ user_info = self ::getApiV2Client ()->get ()
26+ $ user_info = self ::getApiV2Client ($ domain )->get ()
2127 ->users ($ user_id )
2228 ->withHeader (new AuthorizationBearer ($ token ))
2329 ->call ();
2430
2531 return $ user_info ;
2632 }
2733
28- public static function update ($ token , $ user_id , $ data ) {
34+ public static function update ($ domain , $ token , $ user_id , $ data ) {
2935
30- $ user_info = self ::getApiV2Client ()->patch ()
36+ $ user_info = self ::getApiV2Client ($ domain )->patch ()
3137 ->users ($ user_id )
3238 ->withHeader (new AuthorizationBearer ($ token ))
3339 ->withHeader (new ContentType ('application/json ' ))
@@ -37,9 +43,9 @@ public static function update($token, $user_id, $data) {
3743 return $ user_info ;
3844 }
3945
40- public static function create ($ token , $ data ) {
46+ public static function create ($ domain , $ token , $ data ) {
4147
42- $ user_info = self ::getApiV2Client ()->post ()
48+ $ user_info = self ::getApiV2Client ($ domain )->post ()
4349 ->users ()
4450 ->withHeader (new AuthorizationBearer ($ token ))
4551 ->withHeader (new ContentType ('application/json ' ))
@@ -49,9 +55,9 @@ public static function create($token, $data) {
4955 return $ user_info ;
5056 }
5157
52- public static function search ($ token , $ params ) {
58+ public static function search ($ domain , $ token , $ params ) {
5359
54- $ client = self ::getApiV2Client ()->post ()
60+ $ client = self ::getApiV2Client ($ domain )->post ()
5561 ->users ()
5662 ->withHeader (new AuthorizationBearer ($ token ))
5763 ->withHeader (new ContentType ('application/json ' ))
@@ -64,34 +70,34 @@ public static function search($token, $params) {
6470 return $ client ->call ();
6571 }
6672
67- public static function deleteAll ($ token ) {
73+ public static function deleteAll ($ domain , $ token ) {
6874
69- self ::getApiV2Client ()->delete ()
75+ self ::getApiV2Client ($ domain )->delete ()
7076 ->users ()
7177 ->withHeader (new AuthorizationBearer ($ token ))
7278 ->call ();
7379 }
7480
75- public static function delete ($ token , $ user_id ) {
81+ public static function delete ($ domain , $ token , $ user_id ) {
7682
77- self ::getApiV2Client ()->delete ()
83+ self ::getApiV2Client ($ domain )->delete ()
7884 ->users ($ user_id )
7985 ->withHeader (new AuthorizationBearer ($ token ))
8086 ->call ();
8187 }
8288
83- public static function getDevices ($ token , $ user_id ) {
89+ public static function getDevices ($ domain , $ token , $ user_id ) {
8490
85- self ::getApiV2Client ()->get ()
91+ self ::getApiV2Client ($ domain )->get ()
8692 ->users ($ user_id )
8793 ->devices ()
8894 ->withHeader (new AuthorizationBearer ($ token ))
8995 ->call ();
9096 }
9197
92- public static function linkAccount ($ token , $ user_id , $ post_identities_body ) {
98+ public static function linkAccount ($ domain , $ token , $ user_id , $ post_identities_body ) {
9399
94- return self ::getApiV2Client ()->post ()
100+ return self ::getApiV2Client ($ domain )->post ()
95101 ->users ($ user_id )
96102 ->devices ()
97103 ->withHeader (new AuthorizationBearer ($ token ))
@@ -100,35 +106,35 @@ public static function linkAccount($token, $user_id, $post_identities_body) {
100106 ->call ();
101107 }
102108
103- public static function unlinkAccount ($ token , $ user_id , $ multifactor_provider , $ identity ) {
109+ public static function unlinkAccount ($ domain , $ token , $ user_id , $ multifactor_provider , $ identity ) {
104110
105- return self ::getApiV2Client ()->delete ()
111+ return self ::getApiV2Client ($ domain )->delete ()
106112 ->users ($ user_id )
107113 ->addPathVariable ($ identity )
108114 ->identities ($ multifactor_provider )
109115 ->withHeader (new AuthorizationBearer ($ token ))
110116 ->call ();
111117 }
112118
113- public static function unlinkDevice ($ token , $ user_id , $ device_id ) {
114- self ::getApiV2Client ()->delete ()
119+ public static function unlinkDevice ($ domain , $ token , $ user_id , $ device_id ) {
120+ self ::getApiV2Client ($ domain )->delete ()
115121 ->users ($ user_id )
116122 ->devices ($ device_id )
117123 ->withHeader (new AuthorizationBearer ($ token ))
118124 ->call ();
119125 }
120126
121- public static function deleteMultifactorProvider ($ token , $ user_id , $ multifactor_provider ) {
122- self ::getApiV2Client ()->delete ()
127+ public static function deleteMultifactorProvider ($ domain , $ token , $ user_id , $ multifactor_provider ) {
128+ self ::getApiV2Client ($ domain )->delete ()
123129 ->users ($ user_id )
124130 ->multifactor ($ multifactor_provider )
125131 ->withHeader (new AuthorizationBearer ($ token ))
126132 ->call ();
127133 }
128134
129- public static function createEmailVerificationTicket ($ token , $ user_id , $ result_url = null ) {
135+ public static function createEmailVerificationTicket ($ domain , $ token , $ user_id , $ result_url = null ) {
130136
131- $ request = self ::getApiV2Client ()->post ()
137+ $ request = self ::getApiV2Client ($ domain )->post ()
132138 ->users ($ user_id )
133139 ->tickets ()
134140 ->email_verification ()
@@ -145,7 +151,7 @@ public static function createEmailVerificationTicket($token, $user_id, $result_u
145151
146152 }
147153
148- public static function createPasswordChangeTicket ($ token , $ user_id , $ new_password , $ result_url = null ) {
154+ public static function createPasswordChangeTicket ($ domain , $ token , $ user_id , $ new_password , $ result_url = null ) {
149155
150156 $ body = array (
151157 'new_password ' => $ new_password
@@ -155,7 +161,7 @@ public static function createPasswordChangeTicket($token, $user_id, $new_passwor
155161 $ body ['result_url ' ] = $ result_url ;
156162 }
157163
158- return self ::getApiV2Client ()->post ()
164+ return self ::getApiV2Client ($ domain )->post ()
159165 ->users ($ user_id )
160166 ->tickets ()
161167 ->email_verification ()
0 commit comments