PHP code example of jacobdekeizer / ccvshop-client

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

    

jacobdekeizer / ccvshop-client example snippets


$client = new \JacobDeKeizer\Ccv\Client();
$client->setBaseUrl('https://demo.ccvshop.nl');
$client->setPublicKey('public_key');
$client->setPrivateKey('private_key');

$result = $client->root()->all();

foreach ($result->getItems() as $item) {
    var_dump($item);
}

$parameters = (new \JacobDeKeizer\Ccv\Parameters\Apps\AllFromAppstorecategory())
    ->setName('FooBar')
    ->expandCategories()
    ->orderByDateAsc();

$apps = $client->apps()->allFromAppstorecategory(11, $parameters);

foreach ($apps->getItems() as $app) {
    var_dump($app->getName());
}

$apps = $client->apps()->all();

foreach ($apps->getItems() as $app) {
    var_dump($app->getName());
}

$app = $client->apps()->get(123456);

var_dump($app->getName());

$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Apps\Patch\Patch())
    ->setIsInstalled(true);

$client->apps()->update(12345, $patch);

$client->attributes()->get(1234);

$client->attributes()->all();

$client->attributes()->allFromAttributecombination(1234);

$attribute = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Attributes\Input\Input())
    ->setName('Foo')
    ->setType('option_menu_

$attribute = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Attributes\Input\Input())
    ->setName('Foo')
    ->setType('option_menu_

$client->attributes()->delete(1234);

$client->attributevalues()->get(1234);

$client->attributevalues()->allFromAttribute(1234);

$client->attributevalues()->allFromAttributecombination(1234);

$create = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Attributevalues\Post\Post())
    ->setName('Bar')
    ->setDefaultPrice(0);

$client->attributevalues()->createForAttribute(1234, $create);

$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Attributevalues\Patch\Patch())
    ->setName('Bar')
    ->setDefaultPrice(0);

$client->attributevalues()->update(1234, $patch);

$client->attributevalues()->delete(1234);

$categories = $client->categories()->allFromCategory(1);

$parameter = (new \JacobDeKeizer\Ccv\Parameters\Categories\All)
    ->setSize(10); // optional

$categories = $client->categories()->all($parameter);

$nextParameter = \JacobDeKeizer\Ccv\Parameters\Categories\All::fromUrl($categories->getNext());

$category = $client->categories()->get(1);

$category->getId();
$category->getName();
$category->getDescription();

$client->categories()->create(
    (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Categories\Post\Post())
        ->setName('foo bar')
);

$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Categories\Patch\Patch())
    ->setName('foo bar');

$client->categories()->update(1, $patch);

$client->categories()->delete(12345);

// see the code and documentation for all available methods
$getInvoicesParameter = (new \JacobDeKeizer\Ccv\Parameters\Invoices\All)
    ->setMinCreateDate('2020-01-01')
    ->setMaxCreateDate('2020-01-31');

$invoices = $client->invoices()->all($getInvoicesParameter);

$invoice = $client->invoices()->get(123456);

$invoice = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Invoices\Input\Input())
    ->setStatus(1);
    // ->set...

$client->invoices()->update(123456, $invoice);

$invoice = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Invoices\Input\Input())
    ->setStatus(2);
    //->set..
   
$client->invoices()->createForOrder(123, $invoice);

$getOrdersParameter = (new \JacobDeKeizer\Ccv\Parameters\Orders\All)
    ->setStatus(1)
    ->setIsPaid(true)
    ->setIsCompleted(true);

do {
    $orders = $client->orders()->all($getOrdersParameter);

    foreach ($orders->getItems() as $order) {
        // see the code and documentation for all available methods
        var_dump($order);
        $order->getUser()->getId();
        $order->getCustomer()->getBillingaddress()->getStreet();
        $order->getCustomer()->getBillingaddress()->getHousenumber();
        $order->getCustomer()->getBillingaddress()->getHousenumberSuffix();
        $order->getCustomer()->getBillingaddress()->getZipcode();
        $order->getCustomer()->getBillingaddress()->getCity();
        $order->getCustomer()->getDeliveryaddress()->getStreet();
        $order->getCustomer()->getDeliveryaddress()->getHousenumber();
        $order->getCustomer()->getDeliveryaddress()->getHousenumberSuffix();
        $order->getCustomer()->getDeliveryaddress()->getZipcode();
        $order->getCustomer()->getDeliveryaddress()->getCity();
        $order->getCustomer()->getBillingaddress()->getFirstName();
        $order->getCustomer()->getBillingaddress()->getLastName();
        $order->getCustomer()->getBillingaddress()->getTelephone();
        $order->getCustomer()->getEmail();

        $orderRows = $client->orderrows()->allFromOrder($order->getId());
        
        var_dump($orderRows);
        
        foreach ($orderRows->getItems() as $orderRow) {
            var_dump($orderRow);

            $orderRow->getId();
            $orderRow->getCount();
            $orderRow->getPrice();
            $orderRow->getProductId();
            $orderRow->getProductName();
            $orderRow->getPriceWithoutDiscount();
            $orderRow->getDiscount();
            $orderRow->getStockLocation();
            $orderRow->getWeight();
            $orderRow->getSubEanNumber();
        }
    }

    $getOrdersParameter = \JacobDeKeizer\Ccv\Parameters\Orders\All::fromUrl($orders->getNext());
} while($getOrdersParameter !== null);

// see the code and documentation for all available methods
$order = $client->orders()->get(123456);

$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Orders\Patch\Patch())
    ->setStatus(6)
    ->setCustomer(
        (new \JacobDeKeizer\Ccv\Models\Internal\Entity\Personalinfo\Input\Input())
            ->setEmail('[email protected]')
    );
    // ->set...

$client->orders()->update(123456, $patch);

$order = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Orders\Post\Post())
    ->setInvoicenumber(123456);
    //->set..
   
$client->orders()->create($order);

$orderId = 123456;

$parameter = (new \JacobDeKeizer\Ccv\Parameters\OrderRows\AllFromOrder()) // optional parameter
    ->setStart(10);

$orderRows = $client->orderrows()->allFromOrder($orderId, $parameter);

$nextParameter = \JacobDeKeizer\Ccv\Parameters\OrderRows\AllFromOrder::fromUrl($orderRows->getNext());

$orderRow = $client->orderrows()->get(336401521);

$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Orderrows\Patch\Patch())
    ->setCount(1)
    ->setDiscount(20)
    ->setPrice(100);

$client->orderrows()->update(123456, $patch);

$orderId = 123456;

$newOrderrows = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Orderrows\Put\Put())
    ->setOrderrows(
        (new \JacobDeKeizer\Ccv\Models\Internal\Entity\Orderrow\Input\Input)
            ->setProductId(12345)
            ->setCount(1)
            ->setPrice(100)
            ->setDiscount(20)
            // ->set..
    );

$client->orderrows()->updateForOrder($orderId, $newOrderrows);

$notes = $client->ordernotes()->allFromOrder(123);

$note = $client->ordernotes()->get(123456);

$ordernote = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Ordernotes\Post\Post())
    ->setNote('this note will not be seen by the customer');

$client->ordernotes()->createForOrder(123, $ordernote);

$client->ordernotes()->delete(123456);

$notifications = $client->ordernotifications()->allFromOrder(123);

$notification = $client->ordernotifications()->get(123456);

$ordernotification = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Ordernotifications\Input\Input())
    ->setType('customer_paymentlink');

$client->ordernotifications()->createForOrder(123, $ordernotification);

$packages = $client->packages()->all();

$package = $client->packages()->get(12345);

$client->packages()->create(
    (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Packages\Input\Input())
        ->setName('foobar')
);

$input = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Packages\Input\Input())
    ->setName('baz boo');

$client->packages()->update(12345, $input);

// parameter is optional
$getProductsParameter = (new \JacobDeKeizer\Ccv\Parameters\Products\All)
    ->setMinStock(5)
    ->expandProductPhotos()
    ->orderByIdAsc();

$products = $client->products()->all($getProductsParameter);

foreach ($products->getItems() as $product) {
    // see the code and documentation for all available methods
    var_dump($product);

    $product->getId();
    $product->getStock();
    $product->getDiscount();
    $product->getWeight();
    $product->getPrice();
    $product->getBrand()->getId();
    $product->getEannumber();
    $product->getVatrate();
    // ...
}

$nextRequest = \JacobDeKeizer\Ccv\Parameters\Products\All::fromUrl($products->getNext());

$products = $client->products()->allFromBrand(1234);

$products = $client->products()->allFromWebshop(1234);

$products = $client->products()->allFromCategory(1234);

$products = $client->products()->allFromCondition(1234);

$products = $client->products()->allFromSupplier(1234);

$product = $client->products()->get(1234);

// see the code and documentation for all available methods
$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Products\Patch\Patch())
        ->setDiscount(4.99)
        ->setPrice(100)
        ->setProductnumber('my_number')
        ->setActive(true)
        ->setDescription('This is a description')
        ->setEannumber('an ean number')
        ->setMetaKeywords('keyword')
        ->setStock(100)
        ->setUnit('piece')
        ->setWeight(5.5);

$client->products()->update(1234, $patch);

// or only update stock
$client->products()->update(
    1234,
    (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Products\Patch\Patch())
        ->setStock(99)
);

// see the code and documentation for all available methods
$product = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Products\Post\Post())
    ->setDiscount(4.99)
    ->setPrice(100)
    ->setProductnumber('my_number')
    ->setActive(true)
    ->setDescription('This is a description')
    ->setEannumber('an ean number')
    ->setMetaKeywords('keyword')
    ->setStock(100)
    ->setUnit('piece')
    ->setWeight(5.5);
    // ->set...

$client->products()->create($product);

$client->products()->delete(1234);

$client->productattributevalues()->get(1234);

$client->productattributevalues()->allFromProduct(1234);

$post = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Productattributevalues\Post\Post())
    ->setPrice(2);
    // ->set...

$client->productattributevalues()->createForProduct(1234, $post);

$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Productattributevalues\Patch\Patch())
    ->setPrice(2);
    // ->set...

$client->productattributevalues()->update(1234, $patch);

$client->productattributevalues()->delete(1234);

$client->productphotos()->get(1234);

$client->productphotos()->delete(1234);

$client->productphotos()->allFromProduct(1234);

$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Productphotos\Patch\Patch())
    ->setAlttext('text')
    ->setIsMainphoto(true);

$client->productphotos()->update(1234, $patch);


// see the code and documentation for all available methods
$post = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Productphotos\Post\Post())
    ->setSource(base64_encode(file_get_contents('photo.png')))
    ->setFileType('png');
    // ->set...

$client->productphotos()->createForProduct(1234, $post);

// see the code and documentation for all available methods
$productPhoto1 = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Productphotos\Post\Post())
    ->setSource(base64_encode(file_get_contents('photo1.png')))
    ->setFileType('png');
    // ->set...

$productPhoto2 = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Productphotos\Post\Post())
    ->setSource(base64_encode(file_get_contents('photo2.jpg')))
    ->setFileType('jpg');
    // ->set...

$put = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Productphotos\Put\Put)
    ->setProductphotos($productPhoto1, $productPhoto2);

$client->productphotos()->updateForProduct(1234, $put);

$post = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Producttocategories\Post\Post())
    ->setProductId(123)
    ->setCategoryId(456)
    ->setPosition(null);

$client->producttocategories()->create($post);

$client->producttocategories()->get(123);

$client->producttocategories()->allFromProduct(123);

$client->producttocategories()->allFromCategory(123);

$client->producttocategories()->delete(123);

$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Producttocategories\Patch\Patch())
    ->setPosition(1);

$client->producttocategories()->update(123, $patch);

$post = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Producttocategories\Post\Post())
    ->setProductId(123)
    ->setCategoryId(456)
    ->setPosition(null);

$client->producttocategories()->create($post);

$client->producttocategories()->get(123);

$client->producttocategories()->allFromProduct(123);

$client->producttocategories()->allFromCategory(123);

$client->producttocategories()->delete(123);

$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Producttocategories\Patch\Patch())
    ->setPosition(1);

$client->producttocategories()->update(123, $patch);

$suppliers = $client->suppliers()->all();

$supplier = $client->suppliers()->get(12345);

$client->suppliers()->create(
    (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Suppliers\Input\Input())
        ->setName('foobar')
);

$input = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Suppliers\Input\Input())
    ->setName('bazboo');

$client->suppliers()->update(12345, $input);

$client->suppliers()->delete(12345);

$parameter = (new \JacobDeKeizer\Ccv\Parameters\Webhooks\All())
                ->setSize(10); // optional
                
$webhooks = $client->webhooks()->all($parameter);

$nextParameter = \JacobDeKeizer\Ccv\Parameters\Webhooks\All::fromUrl($webhooks->getNext());

$webhook = $client->webhooks()->get(12345);

$webhook = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Webhooks\Post\Post())
    ->setEvent('foo.bar')
    ->setAddress('https://example.com/foo.bar')
    ->setIsActive(true);

$createdWebhook = $client->webhooks()->create($webhook);

var_dump($createdWebhook->getId());

$webhook = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Webhooks\Patch\Patch())
                ->setIsActive(false);

$client->webhooks()->update(12345, $webhook);

$client->webhooks()->delete(12345);