codeswholesale / codeswholesale-sdk-php

A PHP wrapper for CodesWholesale's API
Apache License 2.0
36 stars 21 forks source link

Product of the "image code" type doesn't return image (Sandbox). #3

Closed addinm closed 9 years ago

addinm commented 9 years ago

Hello,

It looks like there is an error with the product of the "image code" type in the sandbox mode. The ID of this product is "6313677f-5219-47e4-a067-7401f55c5a3a", however your SDK recognizes it as the product of the "preorder" type. Your API cannot dump the release date of this product (because initially the product is of the "image code" type) and cannot get the image information. I found this issue this morning, yesterday everything was well. Please see the code below:

use \CodesWholesale as Code;
use \fkooman as Fk;

$params = array(
    'cw.client_id' => 'ff72ce315d1259e822f47d87d02d261e',
    'cw.client_secret' => '$2a$10$E2jVWDADFA5gh6zlRVcrlOOX01Q/HJoT6hXuDMJxek.YEo.lkO2T6',
    'cw.endpoint_uri' => Code\CodesWholesale::SANDBOX_ENDPOINT,
    'cw.token_storage' => new Fk\OAuth\Client\SessionStorage()
);

$clientBuilder = new Code\ClientBuilder($params);
$client = $clientBuilder->build();

try{

    $url = "https://sandbox.codeswholesale.com/v1/products/6313677f-5219-47e4-a067-7401f55c5a3a";

    $product = Code\Resource\Product::get($url);
    $code = Code\Resource\Order::createOrder($product);

    if ($code->isPreOrder()) {
        echo 'preorder';
    }
    if ($code->isImage()) {
        $fullPath = \CodesWholesale\Util\CodeImageWriter::write($code, "F:\www");
        echo $fullPath;
    }
    if ($code->isText()) {
        echo $code->getCode() . " <br />";
    }

} catch (\CodesWholesale\Resource\ResourceError $e) {
    ......
}

The result is "preorder".

Best regards, Sergey