ampahkwabena/ghanapostgps

PHP package for connecting with GhanaPostGPS

v0.1.0 2022-02-10 13:06 UTC

This package is not auto-updated.

Last update: 2024-11-16 02:16:39 UTC


README

PHP package for GhanaPostGPS

This package connects with the GhanaPostGPS to look for digital addresses in Ghana.

Installation

You can install the package via composer using

composer require ampahkwabena/ghanapostgps

What you will need

Before connecting to GhanaPostGPS, you'll need the following:

  1. AsaaseUser ID This is given to you during on-boarding with the GhanaPostGPS team and can be found under your profile from the GPSAdmin Portal
  2. DeviceID You'll need to create a device on the GPSAdmin Portal and use the ID. Note that you can create multiple devices on the portal.
  3. AES Key The GhanaPostGPS server uses AES encryption to communicate with with clients. You can access your AES key for each device you create in the portal.

Data APIs

Use the GhanaPostGPS\GhanaPostGPS object to get data.

$asaaseUser = 'ASAASE-USER-ID'
$deviceId = 'DEVICE-ID'
$aesKey = 'AES-KEY-FOR-DEVICE'

$gps = new GhanaPostGPS\GhanaPostGPS($asaaseUser, $deviceId, $aesKey);

Get Location for a GPS Name (Ghana Code)

// Ghana Code
$gpsName = 'GA-585-7449';
 
// Location contains center latitude and longitude as well as
// a box around the center. You also get postcode, region,
// area, street, etc.
$location = $gps->getLocation($gpsName);

Get GPS Name (Ghana Code) for a location

$location = [
    'lat' => 5.7525573723,
    'lng' => -2.873287368
];

// The GPS info contains postcode, region, area and street info
// for the provided location.
$gpsInfo = $gps->getGps($location);

Tests

Tests are setup in a way that actually connect with GhanaPostGPS to make sure everything works.

To run tests, supply your credentials in tests/Unit/GhanaPostGPSTest and run vendor/bin/phpunit

Prerequisites

Contributing

Contributions are welcome! Please do a PR with any bug-fixes or email me at ampahkwabena5@gmail.com for a long term commitment.

License

This open-source project is licensed under the MIT LICENSE