PHP code example of fulfillment / api-wrapper

1. Go to this page and download the library: Download fulfillment/api-wrapper 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/ */

    

fulfillment / api-wrapper example snippets


use Fulfillment\Api\Api;

$data = [
    'endpoint' => $endPoint,
    'clientId' => $clientId,
    'clientSecret' => $clientSecret,
    'accessToken' => $accessToken,
    'username' => $username,
    'password' => $password
];

$apiClient = new Api($data);

$newPostageClient = [
    'email' => '[email protected]',
    'clientId' => 2
];

$returnedUser = $apiClient->post('users', $newPostageClient); //POST request with body as json

$apiClient->get('users', ['clientId' => '2']); //GET request with query string ?clientId=2

$data = [
    'endpoint'     => $endPoint,
    'clientId'     => $clientId,
    'clientSecret' => $clientSecret,
    'accessToken'  => $accessToken,
    'username'     => $username,
    'password'     => $password,
    'scope'        => 'oms'
];

$apiClient = new Api($config)

$fileLocation = __DIR__ . DIRECTORY_SEPARATOR . '.env';

$apiClient = new Api($fileLocation);

$apiClient = new Api();

$apiClient = new Api($config, $logger);

$apiClient = new Api($config, $logger, $guzzle)

$apiClient->get($url, $queryString);
$apiClient->post($url, $body, $queryString);
$apiClient->patch($url, $body, $queryString);
$apiClient->delete($url, $queryString);

RequestParser::parseError($r)

RequestParser::getErrorCode($r)