dev-master
9999999-dev
MIT
The Requires
The Development Requires
by Agbitor Cosman
                         Wallogit.com
                    
                    2017 © Pedro Peláez
                    
                    
                    
                    
                
                
            
This package serves as a request mapper for BigCommerce products, orders, customers, and merchant end points., (*1)
composer require mavericks-lab/bigcommerce
use Maverickslab\BigCommerce\Http\Client\BigCommerceHttpClient;
use Maverickslab\BigCommerce\Http\Request\{
    ProductRequest, CategoryRequest, OrderRequest, MerchantRequest, CustomerRequest
};
$authToken = 'h5wm9usftmq7zkmn1bggaj6cr8h3ml3';
$clientId = 'nbioblf5th4u4y9iqhtbwbjyl6qb6jt';
$clientSecret = '';
$storeId = '9ma06';
$httpClient = new BigCommerceHttpClient($authToken, $clientId, $clientSecret, $storeId);
//Create an instance of a product request
$productRequest = new ProductRequest($httpClient);
//Create an instance of a category request
$categoryRequest = new CategoryRequest($httpClient);
//Create an instance of an order request
$orderRequest = new OrderRequest($httpClient);
//Create an instance of a merchant request
$merchantRequest = new MerchantRequest($httpClient);
//Create an instance of a customer request
$customerRequest = new CustomerRequest($httpClient);
You can also create an instance of Maverickslab\BigCommerce\BigCommerce, which combines all the above request into one object., (*2)
use Maverickslab\BigCommerce\BigCommerce; $bigCommerce = new BigCommerce($httpClient); //Get instance of a ProductRequest $bigCommerce->product(); //Get instance of a CategoryRequest $bigCommerce->category(); //Get instance of an OrderRequest $bigCommerce->order(); //Get instance of a CustomerRequest $bigCommerce->customer(); Get instance of a MerchantRequest $bigCommerce->merchant();
NOTE: All publicly accessible methods in these repositories return instances of Psr\Http\Message\ResponseInterface, so you must resolve them to get their actual return values., (*3)
$product = array( 'name' => 'Dell XPS 15', 'weight' => 10.5, 'price' => 1500, 'sku' => 'DELL-XPS-15' ); $promise = $productRequest->create($product);
$id = 1;
$productInfo = array(
    'name' => 'Dell XPS 13'
);
$promise = $productRequest->update($id, $productInfo);
$page = 1; $limit = 1000; $includes = ['images', 'variants']; $promise = $productRequest->fetch($page, $limit, $includes);
$id = 1; $promise = $productRequest->fetchById($id);
$id = 1; $promise = $productRequest->deleteById($id);
$productId = 1; $promise = $productRequest->fetchProductImages($productId);
$productId = 1; //External image $imageFile = 'http://www.somedomain.com/images/product1.jpeg'; //Or //Local image $imageFile = 'images/product1.png'; $promise = $productRequest->uploadProductImage($productId, $imageFile);
See Maverickslab\BigCommerce\Http\Request\ProductRequest for more information on how to perform other product related requests., (*4)
$category = array(
    'name' => 'Cars',
    'parent_id' => 0
);
$promise = $categoryRequest->create($category);
$categoryId = 1;
$categoryInfo = array(
    'name' => 'Bikes',
    'parent_id' => 1
);
$promise = $categoryRequest->update($categoryId, $categoryInfo);
$page = 1; $limit = 500; $promise = $categoryRequest->fetch($page, $limit);
See Maverickslab\BigCommerce\Http\Request\CategoryRequest for more on how to perform other category related requests., (*5)
$page = 1; $limit = 500; $filters = []; $promise = $orderRequest->fetch($page, $limit, $filters);
$orderId = 1;
$orderInfo = array(
    'status_id' => 10
);
$promise = $orderRequest->update($orderId, $orderInfo);
$orderId = 1; $page = 1; $limit = 250; $promise = $orderRequest->fetchOrderedProducts($orderId, $page, $limit);
See Maverickslab\BigCommerce\Http\Request\OrderRequest for more on how to perform other order related requests., (*6)
$page = 1; $limit = 250; $filters = []; $promise = $customerRequest->fetch($page, $limit, $filters);
$customerId = 2; $promise = $customerRequest->fetchById($customerId);
$customer = array(
    'first_name' => 'John',
    'last_name' => 'Smith',
    'email' => 'johnsmith@somedomain.com',
    'phone' => '+2335457487484'
);
$promise = $customerRequest->create($customer);
See Maverickslab\BigCommerce\Http\Request\CustomerRequest for more on how to perform other customer related requests., (*7)
$promise = $merchantRequest->fetchDetails();
use Psr\Http\Message\ResponseInterface;
use GuzzleHttp\Exception\RequestException;
$promise->then(function(ResponseInterface $response){
    //Do something wih the response
}, function(RequestException $e){
    echo $e->getMessage();
});
        
MIT