PHP code example of bannerstop / helix-sdk

1. Go to this page and download the library: Download bannerstop/helix-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bannerstop / helix-sdk example snippets


use Helix\Sdk\Auth\CredentialsTokenProvider;
use Symfony\Component\HttpClient\HttpClient;

$httpClient = HttpClient::create();
$baseUrl = 'https://api.helix-converter.com';

$tokenProvider = new CredentialsTokenProvider(
    $httpClient, 
    $baseUrl, 
    'your-username', 
    'your-password'
);

use Helix\Sdk\Client\HelixClient;

$client = new HelixClient($httpClient, $tokenProvider, $baseUrl);

use Helix\Sdk\Dto\Request\MagentoOrderDto;
use Helix\Sdk\Dto\Request\MagentoProductDto;
use Helix\Sdk\Dto\Request\ProductOptionDto;

$items = [
    new MagentoProductDto('SKU-123', 'My Product', [
        new ProductOptionDto('Size', 'XL'),
        new ProductOptionDto('Color', 'Blue')
    ])
];

$order = new MagentoOrderDto($items);

try {
    $response = $client->convertMagentoOrder($order);
    if ($response->converted !== null) {
        foreach ($response->converted->items as $item) {
            // Processing results (e.g., converted product data)
            echo "Converted Product: " . $item->name . " (SKU: " . $item->sku . ")\n";
        }
    }
} catch (\Helix\Sdk\Exception\HelixApiException $e) {
    echo "API Error: " . $e->getMessage();
}