jreinke/mirakl-sdk-php-shop

Mirakl provides a PHP SDK that wraps the Mirakl REST APIs in a lightweight library. This enables you to develop a fast, flexible and custom integration for your existing e-commerce solution.

This package's canonical repository appears to be gone and the package has been frozen as a result.

1.9.1 2019-03-08 10:08 UTC

This package is not auto-updated.

Last update: 2024-04-14 18:09:53 UTC


README

mirakl-sdk-php is the official Mirakl PHP API client.

How to use

<?php
/**
 * This example is for the role Frontend. For any other role there is another client.
 * For the role Shop the appropriate client is \Mirakl\MMP\Shop\Client\ShopApiClient
 */
require 'vendor/autoload.php';

use Mirakl\MMP\Front\Client\FrontApiClient as MiraklApiClient;
use Mirakl\MMP\Front\Request\Offer\GetOfferRequest;

// Environment parameters
$url = 'https://your.env/api';
$apiKey = 'your_api_key';

try {
    // Building request
    $request = new GetOfferRequest('2000');

    // Instantiating the Mirakl API Client
    $api = new MiraklApiClient($url, $apiKey);

    // Calling the API
    $result = $api->getOffer($request);
    var_dump($result); // decorated response

    // You can also retrieve raw response by using run() method of API client:
    $result = $api->run($request); // or $api->raw()->getOffer($request)
    var_dump($result); // returns \Psr\Http\Message\ResponseInterface

} catch (\Exception $e) {
    // An exception is thrown if object requested is not found or if an error occurs
    var_dump($e);
}