PHP code example of gpupo / netshoes-sdk

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

    

gpupo / netshoes-sdk example snippets




use Gpupo\NetshoesSdk\Factory;

$sdk = Factory::getInstance()->setup([
    'client_id'     => 'foo',
    'access_token'  => 'bar',
    'version'       => 'sandbox',
 ]);

$manager = $sdk->factoryManager('product');


//..
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
//..
$logger = new Logger('foo');
$logger->pushHandler(new StreamHandler('var/log/main.log', Logger::DEBUG));
$sdk->setLogger($logger);


$product = $sdk->createProduct($data);


//..
$sdk->factoryManager('product')->save($product);


//..
$order = $sdk->createOrder($data)->setOrderStatus('invoiced');
$invoice = $sdk->createInvoice([
	'number'    => 4003,
	'line'      => 1,
	'accessKey' => '1789616901235555001000004003000004003',
	'issueDate' => '2016-05-10T09:44:54.000-03:00',
]);
$order->getShipping()->setInvoice($invoice);
echo $sdk->factoryManager('order')->update($order)->getHttpStatusCode()); // 200


//..
$order = $sdk->createOrder($data)->setOrderStatus('shipped');
$transport = $sdk->createTransport([
	"carrier"               => "Correios",
	"trackingNumber"        => "PJ521644335BR",
	"shipDate"              => "2016-05-10T10:46:00.000-03:00",
	"estimatedDeliveryDate" => "2016-05-10T10:46:00.000-03:00",
]);
$order->getShipping()->setTransport($transport);
echo $sdk->factoryManager('order')->update($order)->getHttpStatusCode()); // 200


//..
$order = $sdk->createOrder($data)
	->setOrderStatus('delivered')
	->getShipping()->getTransport()
	->setDeliveryDate("2016-05-10T10:53:00.000-03:00");
echo $sdk->factoryManager('order')->update($order)->getHttpStatusCode()); // 200


//..
use Gpupo\NetshoesSdk\Entity\Order\Order;
use Gpupo\NetshoesSdk\Entity\Order\Manager;
//...
$manager = new Manager();
$tradeOrder = $manager->export($order);
 php

//..
$produtosCadastrados = $sdk->factoryManager('product')->fetch(); // Collection de Objetos Product

 php

//..
$produto = $sdk->factoryManager('product')->findById(9)); // Objeto Produto
echo $product->getName(); // Acesso ao nome do produto de Id 9
 php

//..
$status = $sdk->factoryManager('product')->fetchStatusById(9)); // Objeto Status
$status->isPending(); // boolean ou RuntimeException code 404 (inexistente)
 php

$manager = $sdk->factoryManager('product');
$previous = $sdk->createProduct($previousData);
$product = $sdk->createPrevious($data);
$manager->update($product, $previous);
 php

$manager = $sdk->factoryManager('sku');
$previous = $sdk->createSku($previousData);
$sku = $sdk->createSku($data);
$manager->update($sku, $previous);