tobexkee / reloadly
A simple php library to interact with the reloadly api
Requires
- php: ^8.0
- guzzlehttp/guzzle: ^7.0
- illuminate/collections: ^8.1
- illuminate/container: ^8.1
- illuminate/http: ^8.1
- illuminate/support: ^8.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.18
- mockery/mockery: ^1.4
- phpunit/phpunit: ^9.4
This package is auto-updated.
Last update: 2025-02-26 23:41:25 UTC
README
this package is still in development. breaking changes can still be made! This package allows you to integrate the Reloadly airtime/data API into your application without breaking a sweat.
Installation
composer require tobexkee/reloadly-php
Demo
You test see the demo on PHPSandbox
<iframe src="https://phpsandbox.io/e/x/96yon?&layout=EditorPreview&iframeId=0p92l0kt4b&theme=dark&defaultPath=/&showExplorer=yes" style="display: block" loading="lazy" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" height="100%" width="100%"></iframe>Usage
First instantiate an object of the class.
<?php require "vendor/autoload.php"; use Tobexkee\Reloadly\Reloadly; $client = new Reloadly($client_id, $client_secret, $audience);
The audience argument has a default value of sandbox. Set it to live to go live
available methods
The package covers all the available reloadly API.
Countries
To access the countries API, use the country method. This returns an instance of the Country API class hence you can call the fetch method to retrieve the countries.
<?php
$countries = $reloadly->countries()->fetch();
you can also retrieve a single country by ISO
<?php $country = $reloadly->countries()->fetch('NG');
Transactions
You can retrieve the transactions by calling the transactions method on the client. This returns an instance of the transactions API class hence you can call the fetch method to retrieve the transactions
$transactions = $reloadly->transactions()->fetch();
You can also retrieve a single transaction using it ID
$transactions = $reloadly->transactions()->fetch($transaction_id);
Topup
The topup method returns an instance of the Topup API class where you can call the send method to transfer airtime or data to a user.
$sendTopup = $reloadly->topup()->send($data);
The $data argument are the expected parameters from the relaodly API
FXrate
The fxrate method returns and instance of the Fxrate API class . Calling the fetch method on it fetches the fxrates of an expected transaction.
$rate = $reloadly->fxrate()->fetch($operatorId, $amount);
Promotions
The promotions method on the client returns an instance of the Promotions API class that allows you to fetch the available promotions based on different parameters
$promotions = $reloadly->promotions()->fetchById($id);
$promotions = $reloadly->promotions()->fetchByCountry($country_code);
$promotions = $reloadly->promotions()->fetchByOperator($operator);
$promotions = $reloadly->promotions()->fetch($data); //returns all promotions based all filters set in the $data array
###Operators The operators method on the client returns an instance of the Operators API class that provides you with different methods to fetch operators details
$operators = $reloadly->operators()->fetch(); //fetch all operators. $operators = $reloadly->operators()->fetchById($id); //fetch operator by ID $operators = $reloadly->operators()->fetchByIso($iso); //fetch operator by ISO $operators = $reloadly->operators()->fetchByPhone($phone, $country_iso); //fetch operator by phone number
Each of the methods can take an optional $data associative array argument to add additional filters to the search.
Discount
The discount method on the client returns an instance of the Discount API class with two methods that allows you to fetch data from the discount API
$discounts = $reloadly->discount()->fetch(); //fetch all discounts $discount = $reloadly->discount()->fetchById($id); //fetch discount by ID
Account
The account method on the client returns an instance of the Account API class which contains a single balance method to retrieve your account balance
$balance = $reloadly->account()->balance();
Contribution
if you want to contribute to this project, dont wait for another second, fork and start sending in your PR's