General PHP SDK to interact with the API of the Prosecutor General's Office's criminal justice sector database.
Use Composer to install the package
composer require javaabu/pgodb-sdk
- PHP 7.4
The API key is taken as a single, mandatory parameter.
$apiKey = "iK4YfZe2i1RAe22tKP4xejGKDZP ....";
$baseUri = "http://pgodb.test/api/v1/"
$pgoDb = new PgoDB($apiKey, $baseUri);
Note
- Check the SOP to understand how to get an API token (you may use either a personal access token or a password token). Use this as the
API_TOKEN
. - Use the
host
parameter, defined in the API documentation, as theBASE_URI
.
$pgoDb->criminalCase()->get();
We do not use database ids, but rather administrative identification strings such as an individual's national identity card number, passport number, registration number (for judges and lawyers), incident reference numbers, gaziyyah numbers and the like.
$pgoDb->criminalCase()->find($idString);
This is a wrapper for the filter
functionality built into this package.
An alternate way of doing this is as follows:
$pgoDb->criminalCase()->addFilter("search", $idString)->get();
The search term would change depending on the model being retrieved. The find
function
abstracts this complexity away for the user.
// Sample data
$data = [
"incident_reference_number": "2123756022",
"institution_reg_no": "pgo",
"incident_at": "1996-12-30T09:11:26.000000Z",
"lodged_at": "1998-03-13T19:00:00.000000Z"
];
$pgoDb->criminalCase()->store($data);
// Sample data
$data = [
"individual": [
"nid": "A169993",
"name": "Dr. Larissa Stokes",
"name_en": "Mr. Benedict Lockman I",
"gender": "female",
"mobile_number": "860.660.2765",
"nationality_code": "MV",
"permanent_address_country_code": "MV",
"permanent_address_city_code": "LD0894",
"permanent_address": "67353 Rebeka Road\nEast Opal, PA 94709",
"individual_type": "local",
"dob": "1995-07-14T19:00:00.000000Z",
"email": "pemmerich@example.net"
]
];
$pgoDb->criminalCase()
->whereId("7/2022")
->complainant()
->store($data);
// Sample data
$data = [
"institution_reg_no": "javaabu",
];
$pgoDb->criminalCase()
->whereId("2123756022")
->update($data);
// Sample data
$data = [
"individual": [
"permanent_address_country_code": "MV",
]
];
$pgoDb->criminalCase()
->whereId("7/2022")
->complainant()
->whereId("A169993")
->update($data);
$pgoDb->criminalCase()
->addSort("created_at")
->addSortByDesc("updated_at")
->get()
The ending functions of each of these chained functions are defined as follows. The actual API request will be sent once these ending functions are called at the end of the chain.
get()
Should return a list of items,find($id)
Should return a single item,delete($id)
Sends a delete request and returns true or false,store($data)
Returns the newly stored record,update($data)
Returns the updated record.
Please see CHANGELOG for more information on what has changed recently.
If you discover any security related issues, please email info@javaabu.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.