magentix/unopim-php-api-client

There is no license information available for the latest version (1.0.4) of this package.

Simple PHP UnoPim API Client

1.0.4 2025-02-26 13:16 UTC

This package is not auto-updated.

Last update: 2025-03-12 13:27:36 UTC


README

Installation

composer require magentix/unopim-php-api-client

Usage

$apiUrl = 'https://www.example.com';
$clientId = '1a1b1c1d-2e2f-3g3h-4i4j-5k5l5m5n5o5p';
$clientSecret = '1a3b5c7d9e2f4g6h8i1j3k5l7m9n2o4p6q8r1s3t';
$username = 'john.doe@example.com';
$password = 'Password';

$cache = new \Magentix\UnoPimApiClient\UnoPimApiCache(
    __DIR__ . DIRECTORY_SEPARATOR . 'api_cache', // The cache file directory path
    86400 // Request lifetime in seconds (GET requests in HTTP 200 are cached, 0 to disable)
);

$client = new \Magentix\UnoPimApiClient\UnoPimApiClient(
    $apiUrl,
    $clientId,
    $clientSecret,
    $username,
    $password,
    $cache,
    3000 // Authentication lifetime (need to be lower that the access token TTL, 0 to disable)
);

GET

$result = $client->get('/api/v1/rest/categories');
$params = [
    'filters' => [
        'categories' => [
            [
                'operator' => 'IN',
                'value' => ['beers']
            ]
        ]
    ],
    'limit' => 10,
];
$result = $client->get('/api/v1/rest/products', $params);

POST

$data = [
    'code' => 'beers',
    'parent' => 'root',
    'additional_data' => [
        'locale_specific' => [
            'en_US' => ['name' => 'Beers'],
            'fr_FR' => ['name' => 'Bières'],
        ]
    ]
];
$result = $client->post('/api/v1/rest/categories', $data);

PUT

$data = [
    'parent' => 'root',
    'additional_data' => [
        'locale_specific' => [
            'en_US' => ['name' => 'Beers'],
            'fr_FR' => ['name' => 'Bières'],
        ]
    ]
];
$result = $client->put('/api/v1/rest/categories/beers', $data);