1. Go to this page and download the library: Download ipaas/gapp-laravel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ipaas / gapp-laravel example snippets
ipaas/gapp-laravel: ~1.1.0
artisan vendor:publish --tag=gapp
artisan migrate
artisan create-partner-app {provider}
/* ------ Class A ------- */
function validateUser(Request $request){
// validate request
$request->validate(['user_id'=>'integer| // add user details to context
->setClientId($user->id) // client id to context
->setClientKey($user->key); // client key to context
// add request details context
iLog()->setType('Validate user name');
// Calling other class to resolve request
return ClassB::validateUserName($user);
}
}
/* ------ Class B ------- */
// all set context still exist
function validateUserName(User $user){
// log event info
// will be logged with context
Log::info('Validating user name')
// validate user name
$name = $user->name;
if(empty($name) || is_null($name))
{
// log warning that name is not valid
// will be logged all context
Log::warning('Name is null or empty');
return false;
}
}
$request->header('Authorization') // Authorization value from header
$request->header('X-Api-Key') // Client ID from header
$request->header('Gapp-Request-ID') // Gapp Request ID from header
$request->uuid // request uuid
$request->dateFrom // date from
$request->dateTo // date to
use Ipaas\Gapp\Request;
use Ipass\Response;
class Accounts extends Response;
{
public function index(Request $request)
{
$rules = ['name' => '
// $rules is laravel validation rule set
Func: validate(array $rules)
Return: REQUEST if all sucessfull
Throw: Unprocessable Entity (422) if validation fails