-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kalyan H
committed
Oct 26, 2021
1 parent
15f2b6d
commit 5193392
Showing
10 changed files
with
915 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,109 @@ or using helper | |
IdpUser()->create(array()); | ||
``` | ||
|
||
# Create you SDK | ||
Run this command to create your own sdk class. | ||
``` | ||
php artisan make:idpdriver YourSDKName | ||
``` | ||
Now add the class in config idpUser.php config file. | ||
|
||
# API references | ||
### Here all covered API references | ||
|
||
>1. Get Wso2 IDP User by ID | ||
``` | ||
IdpUser()->setPayload('userID')->userInfo()->get(); | ||
``` | ||
or to get only response body | ||
|
||
``` | ||
IdpUser() | ||
->use('wso2idp') | ||
->setPayload('userID') | ||
->userInfo() | ||
->onlyBody() | ||
->get(); | ||
``` | ||
Here - | ||
|
||
----- | ||
|
||
```use('yourSDK')``` `optional` set your custom SDK. | ||
|
||
```onlyBody()``` `optional` return only response from IDP server/end API | ||
|
||
---- | ||
|
||
|
||
```get()``` return response as `array` | ||
|
||
```asObject()``` return response as `object` | ||
|
||
```asJson()``` return response as `json` | ||
|
||
---- | ||
|
||
>2. Create IDP user and get created user info | ||
``` | ||
$response = IdpUser()->setPayload([ | ||
'first_name' => 'Kalyan', | ||
'last_name' => 'Kalyan', | ||
'username' => 'Kalyan4', | ||
'email' => '[email protected]', | ||
'mobile' => '01945602071', | ||
'user_type' => '2', | ||
'active' => true, | ||
'department' => 'Kalyan', | ||
])->create()->get(); | ||
``` | ||
|
||
>3. Update User By User ID | ||
_you can provide single field or multiple field at the same time_ | ||
|
||
``` | ||
$response = IdpUser()->setPayload([ | ||
'id' =>'UserID', | ||
'username' => 'Kalyan3', | ||
'account_status' => 1, | ||
'mobile' => '01945602071' | ||
])->update()->get(); | ||
``` | ||
here `id` and `username` is mendatory. You can provide following field to update & create - | ||
|
||
| Key | Details | | ||
| ------ | ------ | | ||
| first_name | Update `givenName` | | ||
| last_name | [Update `familyName` | | ||
| email | Update `emails` | | ||
| mobile | Update `phoneNumbers` | | ||
| user_type | Update `userType`| | ||
| account_status | Update `accountStatus` | | ||
| department | Update `department` | | ||
| organization | Update `organization` | | ||
| country | Update `country` | | ||
| password | Update `password` | | ||
|
||
|
||
>4. Delete single/bulk IDP User | ||
``` | ||
$userID = 'ID'; | ||
$response = IdpUser() | ||
->use('wso2idp') | ||
->setPayload($userID) | ||
->delete() | ||
->get(); | ||
``` | ||
here - `$userID` can be single user ID or array of user ID. | ||
|
||
|
||
|
||
|
||
## Adding new Gateway | ||
|
||
## .env Config | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,215 @@ | ||
<?php | ||
|
||
namespace DummyNamespace; | ||
|
||
use Khbd\LaravelWso2IdentityApiUser\Interfaces\IDPInterface; | ||
use Illuminate\Http\Request; | ||
|
||
class DummyClass implements IDPInterface | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
protected $settings; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $user_id; | ||
/** | ||
* @var bool | ||
*/ | ||
protected $is_success; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
protected $response_code; | ||
|
||
/** | ||
* @var mixed | ||
*/ | ||
protected $message; | ||
|
||
|
||
/** | ||
* @var mixed | ||
*/ | ||
protected $onlyBody; | ||
|
||
/** | ||
* @var object | ||
*/ | ||
protected $asObject; | ||
|
||
/** | ||
* @var json | ||
*/ | ||
protected $asJson; | ||
|
||
/** | ||
* @var object | ||
*/ | ||
protected $data; | ||
|
||
/** | ||
* @var object | array | ||
*/ | ||
protected $response; | ||
|
||
|
||
|
||
/** | ||
* @param $settings | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function __construct($settings) | ||
{ | ||
$this->settings = (object) $settings; | ||
} | ||
|
||
public function userInfo($userID) | ||
{ | ||
$AT = new Wso2IdpUsers($this->settings->base_url, $this->settings->username, $this->settings->password, $this->settings->idp_log ); | ||
$this->response = $AT->userInfo($userID); | ||
return $this; | ||
} | ||
|
||
public function findUsers($userID) | ||
{ | ||
$AT = new Wso2IdpUsers($this->settings->base_url, $this->settings->username, $this->settings->password, $this->settings->idp_log ); | ||
$this->response = $AT->findUsers($userID); | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param $recipient | ||
* @param $message | ||
* @param null $params | ||
* | ||
* @return object | ||
*/ | ||
public function create($userInfo) | ||
{ | ||
$AT = new Wso2IdpUsers($this->settings->base_url, $this->settings->username, $this->settings->password, $this->settings->idp_log ); | ||
$this->response = $AT->create($userInfo); | ||
return $this; | ||
} | ||
|
||
|
||
/** | ||
* Update user | ||
* @param array $userInformation | ||
* @return mixed|void | ||
*/ | ||
public function update(array $userInformation) | ||
{ | ||
$AT = new Wso2IdpUsers($this->settings->base_url, $this->settings->username, $this->settings->password, $this->settings->idp_log ); | ||
$this->response = $AT->update($userInformation); | ||
return $this; | ||
} | ||
|
||
|
||
public function delete( $userInformation = null) | ||
{ | ||
$AT = new Wso2IdpUsers($this->settings->base_url, $this->settings->username, $this->settings->password, $this->settings->idp_log ); | ||
$this->response = $AT->delete($userInformation); | ||
return $this; | ||
} | ||
|
||
|
||
/** | ||
* set response type | ||
* @return $this | ||
*/ | ||
public function get() | ||
{ | ||
if($this->onlyBody){ | ||
return $this->response['data']; | ||
} | ||
return $this->response; | ||
} | ||
/** | ||
* set response type | ||
* @return $this | ||
*/ | ||
public function asObject() | ||
{ | ||
if($this->onlyBody){ | ||
return (object) $this->response['data']; | ||
} | ||
return (object) $this->response; | ||
} | ||
|
||
/** | ||
* set response type | ||
* @return $this | ||
*/ | ||
public function asJson() | ||
{ | ||
if($this->onlyBody){ | ||
return json_encode ($this->response['data']); | ||
} | ||
return (object) $this->response; | ||
} | ||
|
||
/** | ||
* set pertial response | ||
* @return $this | ||
*/ | ||
public function onlyBody() | ||
{ | ||
$this->onlyBody = true; | ||
return $this; | ||
} | ||
|
||
/** | ||
* initialize the is_success parameter. | ||
* | ||
* @return bool | ||
*/ | ||
public function isSuccessful(): bool | ||
{ | ||
return $this->response['status']; | ||
} | ||
|
||
/** | ||
* assign the message ID as received on the response,auto generate if not available. | ||
* | ||
* @return string | ||
*/ | ||
public function getResponseMessage() | ||
{ | ||
return $this->response['message']; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getResponseCode() | ||
{ | ||
return $this->response['code']; | ||
} | ||
|
||
/** | ||
* @return mixed|string | ||
*/ | ||
public function getUserID() | ||
{ | ||
return $this->user_id; | ||
} | ||
|
||
public function fixNumber($number){ | ||
$validCheckPattern = "/^(?:\+88|01)?(?:\d{11}|\d{13})$/"; | ||
if(preg_match($validCheckPattern, $number)){ | ||
if(preg_match('/^(?:01)\d+$/', $number)){ | ||
$number = '+88' . $number; | ||
} | ||
|
||
return $number; | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.