Download the PHP package monovm/airalo-sdk without Composer
On this page you can find all versions of the php package monovm/airalo-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package airalo-sdk
Airalo PHP SDK
Airalo's PHP SDK provides extremely simple integration with the RESTful API and adds extra layer of security on top.
The SDK supports:
- auto authentication and encryption
- auto caching and rate limit handling
- packages fetching of local, global, country and all combined
- packages auto pagination on endpoints
- package ordering
- package bulk order allowing different packages and quantities to be bought at once
- package topup ordering
- unified response format of type
EasyAccess
which allows key access as associative array and/or object at the same time without json_decode usage - compatible with Unix, macOS, Windows operating systems
Requisites
- PHP version >=
7.4
cURL
extension enabled in php.ini (enabled by default)sodium
extension enabled in php.ini (enabled by default)
Autoloading
We highly encourage to always use composer
as a dependency managed and simply require Airalo's SDK by simply running this CLI command:
Then in your codebase you will have access to the Airalo
class by having required autoload.php
file already.
For legacy projects or projects which still do not use composer, please make sure to require alo.php
custom autoloader from the SDK:
Initialization
-
Object usage:
- Static usage:
EasyAccess responses
The SDK provides simple and yet powerful way to interact with the response objects.
By default you will be able to access them as an associative array or object without the need to modify them.
Example:
Methods Interface
Packages
NOTE:
Passingtrue
to$flat
parameter makes the response significantly more compact and easy to handle. However it differes than the main one returned from the endpoints. Be mindful in which occassions you will need the original and in which the compact version. Happy coding!
public function getAllPackages(bool $flat = false, $limit = null, $page = null): ?EasyAccess
Fetching all of Airalo's packages. By default the response will be the same as the one from packages REST endpoint (more here: https://partners-doc.airalo.com/#d775be27-4c08-45d1-9faa-8ec2c4f97bf5). Passing $flat
as true will return package objects data in a single data object, example:
By default no limit number of packages will be applied if $limit
is empty
By default it will paginate all pages (multiple calls) or if $page
is provided it will be the starting pagination index.
public function getLocalPackages(bool $flat = false, $limit = null, $page = null): ?EasyAccess
Fetching local Airalo packages. By default the response will be the same as the one from packages REST endpoint (more here: https://partners-doc.airalo.com/#d775be27-4c08-45d1-9faa-8ec2c4f97bf5). Passing $flat
as true will return package objects data in a single data object.
By default no limit number of packages will be applied if $limit
is empty
By default it will paginate all pages (multiple calls) or if $page
is provided it will be the starting pagination index.
public function getGlobalPackages(bool $flat = false, $limit = null, $page = null): ?EasyAccess
Fetching global Airalo packages. By default the response will be the same as the one from packages REST endpoint (more here: https://partners-doc.airalo.com/#d775be27-4c08-45d1-9faa-8ec2c4f97bf5). Passing $flat
as true will return package objects data in a single data object.
By default no limit number of packages will be applied if $limit
is empty
By default it will paginate all pages (multiple calls) or if $page
is provided it will be the starting pagination index.
public function getCountryPackages(string $countryCode, bool $flat = false, $limit = null): ?EasyAccess
Fetching country specific Airalo packages. By default the response will be the same as the one from packages REST endpoint (more here: https://partners-doc.airalo.com/#d775be27-4c08-45d1-9faa-8ec2c4f97bf5). Passing $flat
as true will return package objects data in a single data object.
By default no limit number of packages will be applied if $limit
is empty
By default it will paginate all pages (multiple calls) or if $page
is provided it will be the starting pagination index.
public function getSimPackages(bool $flat = false, $limit = null, $page = null): ?EasyAccess
Fetching Sim only Airalo packages without top ups. By default the response will be the same as the one from packages REST endpoint (more here: https://partners-doc.airalo.com/#d775be27-4c08-45d1-9faa-8ec2c4f97bf5). Passing $flat
as true will return package objects data in a single data object.
By default no limit number of packages will be applied if $limit
is empty
By default it will paginate all pages (multiple calls) or if $page
is provided it will be the starting pagination index.
Orders
public function order(string $packageId, int $quantity, ?string $description = null): ?EasyAccess
Places an order for a given package id (fetched from any of the packages calls) and calls order
endpoint of the REST API.
Full response example can be found here: https://partners-doc.airalo.com/#768fbbc7-b649-4fb5-9755-be579333a2d9
public function orderBulk(array $packages, ?string $description = null): ?EasyAccess
Parameters: array $packages
where the key is the package name and the value represents the desired quantity.
Parallel ordering for multiple packages (up to 50 different package ids) within the same function call. Example usage:
Example response:
NOTE:
Each package id is a key in the returned response. The quantity ofsims
object represents the ordered quantity from the initial call.
If an error occurs in one of the parallel orders, the error REST response will be assigned to the package id key, so you must make sure to validate each response
Example:
Vouchers
public function voucher(int $usageLimit, int $amount, int $quantity, ?bool $isPaid = false, string $voucherCode = null): ?EasyAccess
calls voucher
endpoint of the REST API.
Full response example can be found here: https://partners-doc.airalo.com/#768fbbc7-b649-4fb5-9755-be579333a2d9
Example response:
Esim Vouchers
public function esimVouchers(array $vouchers): ?EasyAccess
calls voucher/esim
endpoint of the REST API.
Full response example can be found here: https://partners-doc.airalo.com/#5a48bb8d-70d1-4030-ad92-4a82eb979281
Example response:
Topups
public function topup(string $packageId, string $iccid, ?string $description = null): ?EasyAccess
Places a topup for a given package id and iccid of an eSIM and calls topups
endpoint of the REST API.
Full response example can be found here: https://partners-doc.airalo.com/#e411d932-2993-463f-a548-754c47ac7c00
Sim Usage
public function simUsage(string $iccid): ?EasyAccess
Places an $iccid with user iccid and calls simUsage
endpoint of the REST API.
Full response example can be found here: https://partners-doc.airalo.com/#e411d932-2993-463f-a548-754c47ac7c00
Example response can be found in the API documentation (link above).
Sim Instructions
public function getSimInstructions(string $iccid, string $language = "en"): ?EasyAccess
Places an $iccid with user iccid & $language with language like en,de. by default its en and calls getSimInstructions
endpoint of the REST API.
Full response example can be found here: https://partners-doc.airalo.com/#768fbbc7-b649-4fb5-9755-be579333a2d9
Example response:
Techincal notes
- Encrypted auth tokens are automatically cached in filesystem for 24h.
- Caching is automatically stored in filesystem for 1h.
- Utilize the
mock()
methods in Airalo and AiraloStatic for seamless stubbing with your own unit tests. - All exceptions thrown by the SDK are instance of
AiraloException
. - To clear all cache (not recommended to clear cache on production often) you can just do the following: