FAQ - Frequently asked questions

How can I activate the easyBox for my items via the API?

To use the easyBox, the mode must be set to BUY_BOX:

$priceSettings->setMode(RepricingItemPriceSettingsDTO::MODE_BUY_BOX);

Furthermore, the easyBox strategy must be set:

$strategyAPI = new eSagu\\Amzn\\RePricing\\V1\\Api\\RepricingItemStrategyApi();
$buyBoxAPI = new eSagu\\Amzn\\RePricing\\V1\\Api\\RepricingBuyBoxSettingsApi();

$itemId = 1337;
$buyBoxSettings = $buyBoxAPI->callList();

$itemStrategy = $strategyAPI->get($itemId);
$itemStrategy->getPriceSettings()->setMode(RepricingItemPriceSettingsDTO::MODE_BUY_BOX);
$itemStrategy->setBuyBoxSettingsId($buyBoxSettings[0]->getId());

$strategyAPI->put($itemId, $settings);

Server replies with 400 - I am using PHP and get a 400 error when adjusting price changes

This often occurs when prices are transmitted as a string rather than an int. A type cast as int usually solves this problem;

$priceSettings->setFixedPrice((int)$dPriceFix);
$priceSettings->setMaxPrice((int)($dPriceFix + 1));
$priceSettings->setMinPrice((int)($dPriceFix - 1));
$priceSettings->setMode(RepricingItemPriceSettingsDTO::MODE_FIXED_PRICE);

PHP API Client - The parameter order of individual methods has changed after an update

Unfortunately, when the API client is regenerated, the swagger codegen produces different parameter orders for individual methods. This can happen when new filter options are added.

But you can work around this, as in the following example, by determining the order based on the parameter names and "calling" the method with an associative array, where the keys in the associative array correspond to the names of the individual parameters.


setApiKey('Authorization', JWT_API_TOKEN);
eSagu\\EBay\\RePricing\\V1\\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Authorization', 'Bearer');

$itemApi = new eSagu\\EBay\\RePricing\\V1\\Api\\ItemApi();

$itemsPerPage = 5;
$page = 0;
try {
    do {
        $items = callWithOrderedParams($itemApi, 'callList', [
            'offset'   => $page++ * $itemsPerPage,
            'limit'    => $itemsPerPage,
            'by_title' => \"Turnschuhe\",
        ]);

        $hasMore = count($items) === $itemsPerPage;
        $ebayItemIds = implode(', ', array_map(function (RepricingItemDTO $item) { return $item->getItemId(); }, $items));

        echo \"Page: \\\"$page\\\", Item Ids: \\\"$ebayItemIds\\\"\", PHP_EOL;

    } while ($hasMore);
} catch (Exception $e) {
    echo $e->getMessage(), PHP_EOL;
}

\/**
 * @param mixed $apiInstance
 * @param string $methodName
 * @param array $paramsAssoc
 * @return mixed
 * @throws \\ReflectionException
 *\/
function callWithOrderedParams($apiInstance, $methodName, $paramsAssoc)
{
    $params = [];
    foreach ((new \\ReflectionMethod($apiInstance, $methodName))->getParameters() as $refParam) {
        $params[$refParam->name] = null;
    }

    foreach ($paramsAssoc as $key => $val) {
        if (array_key_exists($key, $params)) {
            $params[$key] = $val;
            continue;
        }

        $className = get_class($apiInstance);
        $methodParams = implode(', ', array_map(function ($p) { return \"\\$$p\"; }, array_keys($params)));

        throw new InvalidArgumentException(\"Param \\\"$key\\\" is not present in \\\"$className->$methodName($methodParams)\\\"!\");
    }

    return call_user_func_array([$apiInstance, $methodName], $params);
}

How can I check on the client side if my Token is expired?

In this short example in PHP the exp header of the token would be read and checked if its expiration date has passed.

$token = 'PLACE_YOUR_JWT_HERE';

$tokenPayload = json_decode(base64_decode(explode('.', $token)[1]), true);
if ($tokenPayload['exp'] < time()) {
 throw new RuntimeException("Token \"{$tokenPayload['sub']}\" is expired!");
}