astelbe/sdk-php

SDK used for a PHP Website to access Astel API and telecom data

Installs: 2 176

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 4

Forks: 1

Open Issues: 1

pkg:composer/astelbe/sdk-php


README

It is a lightweight, Astel API client library for PHP. The SDK is best suited for implementing some functionnalities on your own. For example: telecom product catalog listing, options, joint offer for comparing, ordering and sales reporting. The whole Astel.be website is written using this SDK and the API as source of data.

You can either implement your own website using this SDK or use easily integrable off-the-shelf tools - Web Integration Modules. These modules are injectable on any internet facing application or website by inserting some html tags in your own code.

Astel SDK Installation

Install via Composer.

$ composer require astelbe/sdk-php

And use in your PHP code:

require_once 'vendor/autoload.php';

or, simply, download an archive of our code and upload it on your application.

Usage

See our developer site for more examples.

Astel SDK Initialisation

// All methods require authentication. To get your Astel API Private Token credentials, contact us

require_once 'vendor/autoload.php';

use AstelSDK\Model\Partner;
use AstelSDK\Model\Brand;

$envParticle = ''; // '' for production, 'sta' for staging env
$apiToken = '12345abcde'; // API Private Token provided by Astel
$isDebug = false; // For more debug info
$logPath = null; // Null for no logs, a valid writable path for file logs
$isPrivate = true; // Default private / professionnal param (Optionnal)
$language = 'FR'; // Default language used by the page (Optionnal)

$AstelApiContext = new AstelSDK\AstelContext($envParticle, $apiToken, $isDebug, $logPath);
$AstelApiContext->setIsPrivate($isPrivate);
$AstelApiContext->setLanguage($language);

// Utils debug function registering
AstelSDK\AstelContext::registerUtilsFunctions();

Now you are ready to call the API and retrieve data.

Product Example

$Product = AstelSDK\Model\Product::getInstance();

$products = $Product->find('all', [
	'_embed' => 'play_description,commission,web',
	'brand_id' => 3 // VOO
]);

debug($products);

$productVOOOne = $Product->find('first', [
	'id' => '1999', // VOO One
	'_embed' => 'play_description,commission,web',
]);

debug($productVOOOne);

It retrieves all VOO Products and their full description, the commission and cashback associated and web links for product page, and the second example retrieves a single product : Voo One.

Discount Example:

$Discount = Discount::getInstance();

$discounts = $Discount->find('all', [
	'brand_id' => 3,
	'_embed' => 'subscription_periods/product/commission,subscription_periods/product/web',
	'order' => '-weight',
	'count' => 50,
]);

debug($discounts);

It retrieves the 50 first active VOO discounts, order them by weight and retrives the associated recursive models: subscription_periods/product/commission and subscription_periods/product/web.

Supported Platforms

  • PHP 7.0 or higher

How to contribute

All submissions are welcome. Fork the repository, read the rest of this README file and make some changes. Once you're done with your changes send a pull request. Thanks!

Need Help? Found a bug?

Just submit a issue if you need any help. And, of course, feel free to submit pull requests with bug fixes or changes.

Don't hesitate to contact Astel at direction@astel.be for more info or help for your integration.