jacobdekeizer/ccvshop-client
Composer 安装命令:
composer require jacobdekeizer/ccvshop-client
包简介
CCV shop API client for PHP
README 文档
README
An object oriented PHP client for the CCV Shop API. See here for the CCV Shop API documentation.
Contributing
Any help is appreciated, see contributing for more information. The models and endpoints are automatically generated.
Installation
You can install this package via composer:
composer require jacobdekeizer/ccvshop-client
Usage
This readme shows basic usage of this package, for all available options see the class definitions and the api documentation.
Create the client
$client = new \JacobDeKeizer\Ccv\Client(); $client->setBaseUrl('https://demo.ccvshop.nl'); $client->setPublicKey('public_key'); $client->setPrivateKey('private_key');
Documented endpoints
| Endpoint | Main usage |
|---|---|
| root | List supported endpoints |
| apps | Manage apps |
| attributes | Manage attributes |
| attributevalues | Manage attribute values |
| categories | Manage categories |
| invoices | Manage invoices |
| orders | Manage orders |
| orderrows | Manage order rows |
| ordernotes | Manage internal order notes |
| ordernotifications | Manage order notifications |
| packages | Manage packages |
| products | Manage products |
| productattributevalues | Manage product attribute values |
| productphotos | Manage product photos |
| producttocategories | Manage categories of a product |
| suppliers | Manage suppliers |
| webhooks | Manage webhooks |
Root endpoint
This endpoint returns the supported endpoints for your CCV Shop API keys.
$result = $client->root()->all(); foreach ($result->getItems() as $item) { var_dump($item); }
Apps
Get all apps in a certain store category
You can optionally filter, expand or sort.
In the example below, we're filtering by name, expanding categories and sorting by date.
$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()); }
Get all apps
This will get all apps associated with the current public and private key.
You can use the \JacobDeKeizer\Ccv\Parameters\Apps\All parameter to filter the results, like above.
$apps = $client->apps()->all(); foreach ($apps->getItems() as $app) { var_dump($app->getName()); }
Get an app
$app = $client->apps()->get(123456); var_dump($app->getName());
Update an app
For example set the app to installed
$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Apps\Patch\Patch()) ->setIsInstalled(true); $client->apps()->update(12345, $patch);
Attributes
Get attribute
$client->attributes()->get(1234);
Get all attributes
$client->attributes()->all();
Get all attribute combinations
$client->attributes()->allFromAttributecombination(1234);
Create attribute
$attribute = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Attributes\Input\Input()) ->setName('Foo') ->setType('option_menu_required'); $client->attributes()->create($attribute);
Update attribute
$attribute = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Attributes\Input\Input()) ->setName('Foo') ->setType('option_menu_required'); $client->attributes()->update(1234, $attribute);
Delete attribute
$client->attributes()->delete(1234);
Attribute values
Get attribute values
$client->attributevalues()->get(1234);
Get all attribute values for attribute
$client->attributevalues()->allFromAttribute(1234);
Get all attribute values for combination
$client->attributevalues()->allFromAttributecombination(1234);
Create attribute value
$create = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Attributevalues\Post\Post()) ->setName('Bar') ->setDefaultPrice(0); $client->attributevalues()->createForAttribute(1234, $create);
Update attribute value
$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Attributevalues\Patch\Patch()) ->setName('Bar') ->setDefaultPrice(0); $client->attributevalues()->update(1234, $patch);
Delete attribute values
$client->attributevalues()->delete(1234);
Categories
Get all child categories of a category
$categories = $client->categories()->allFromCategory(1);
Get all categories
$parameter = (new \JacobDeKeizer\Ccv\Parameters\Categories\All) ->setSize(10); // optional $categories = $client->categories()->all($parameter); $nextParameter = \JacobDeKeizer\Ccv\Parameters\Categories\All::fromUrl($categories->getNext());
Get category
$category = $client->categories()->get(1); $category->getId(); $category->getName(); $category->getDescription();
Create category
$client->categories()->create( (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Categories\Post\Post()) ->setName('foo bar') );
Update category
$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Categories\Patch\Patch()) ->setName('foo bar'); $client->categories()->update(1, $patch);
Delete category
$client->categories()->delete(12345);
Invoices
Get all invoices
Get all invoices between 2020-01-01 and 2020-01-31
// 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);
Get invoice
$invoice = $client->invoices()->get(123456);
Update invoice
$invoice = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Invoices\Input\Input()) ->setStatus(1); // ->set... $client->invoices()->update(123456, $invoice);
Create invoice
$invoice = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Invoices\Input\Input()) ->setStatus(2); //->set.. $client->invoices()->createForOrder(123, $invoice);
Orders
Get all orders with order rows
Get all open orders which are paid and completed
$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);
Get order
// see the code and documentation for all available methods $order = $client->orders()->get(123456);
Update order
For example update the order status and the customer email
$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Orders\Patch\Patch()) ->setStatus(6) ->setCustomer( (new \JacobDeKeizer\Ccv\Models\Internal\Entity\Personalinfo\Input\Input()) ->setEmail('example@example.com') ); // ->set... $client->orders()->update(123456, $patch);
Create order
$order = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Orders\Post\Post()) ->setInvoicenumber(123456); //->set.. $client->orders()->create($order);
Order rows
Get all order rows of an 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());
Get order row
$orderRow = $client->orderrows()->get(336401521);
Update order row
Order must not be completed to update orderrows
$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Orderrows\Patch\Patch()) ->setCount(1) ->setDiscount(20) ->setPrice(100); $client->orderrows()->update(123456, $patch);
Replace order rows of order
$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);
Order notes
Order notes are for internal use only; they will not be seen by customers.
Get all order notes for order
$notes = $client->ordernotes()->allFromOrder(123);
Get order note
$note = $client->ordernotes()->get(123456);
Create order note
$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);
Delete order note
$client->ordernotes()->delete(123456);
Order notifications
Get all order notifications for order
$notifications = $client->ordernotifications()->allFromOrder(123);
Get order notification
$notification = $client->ordernotifications()->get(123456);
Create order notification
$ordernotification = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Ordernotifications\Input\Input()) ->setType('customer_paymentlink'); $client->ordernotifications()->createForOrder(123, $ordernotification);
Packages
Get all packages
$packages = $client->packages()->all();
Get package
$package = $client->packages()->get(12345);
Create package
$client->packages()->create( (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Packages\Input\Input()) ->setName('foobar') );
Update package
$input = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Packages\Input\Input()) ->setName('baz boo'); $client->packages()->update(12345, $input);
Products
All products
// 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());
All products from brand
$products = $client->products()->allFromBrand(1234);
All products from webshop
$products = $client->products()->allFromWebshop(1234);
All products from category
$products = $client->products()->allFromCategory(1234);
All products from condition
$products = $client->products()->allFromCondition(1234);
All products from supplier
$products = $client->products()->allFromSupplier(1234);
Get product
$product = $client->products()->get(1234);
Update product
// 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) );
Create product
// 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);
Delete product
$client->products()->delete(1234);
Product attribute values
Get product attribute value
$client->productattributevalues()->get(1234);
Get all product attribute values from a product
$client->productattributevalues()->allFromProduct(1234);
Create product attribute values
$post = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Productattributevalues\Post\Post()) ->setPrice(2); // ->set... $client->productattributevalues()->createForProduct(1234, $post);
Update product attribute values
$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Productattributevalues\Patch\Patch()) ->setPrice(2); // ->set... $client->productattributevalues()->update(1234, $patch);
Delete product attribute value
$client->productattributevalues()->delete(1234);
Product photos
Get product photo
$client->productphotos()->get(1234);
Delete product photo
$client->productphotos()->delete(1234);
Get all photos for product
$client->productphotos()->allFromProduct(1234);
Update product photo
$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Productphotos\Patch\Patch()) ->setAlttext('text') ->setIsMainphoto(true); $client->productphotos()->update(1234, $patch);
Create product photo
// 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);
Replace all product photos
// 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);
Product categories
Create product to category reference
$post = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Producttocategories\Post\Post()) ->setProductId(123) ->setCategoryId(456) ->setPosition(null); $client->producttocategories()->create($post);
Get product to category reference
$client->producttocategories()->get(123);
Get product to category references by product
$client->producttocategories()->allFromProduct(123);
Get product to category references by category
$client->producttocategories()->allFromCategory(123);
Delete product to category by reference
$client->producttocategories()->delete(123);
Update product to category reference
$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Producttocategories\Patch\Patch()) ->setPosition(1); $client->producttocategories()->update(123, $patch);
Create product to category reference
$post = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Producttocategories\Post\Post()) ->setProductId(123) ->setCategoryId(456) ->setPosition(null); $client->producttocategories()->create($post);
Get product to category reference
$client->producttocategories()->get(123);
Get product to category references by product
$client->producttocategories()->allFromProduct(123);
Get product to category references by category
$client->producttocategories()->allFromCategory(123);
Delete product to category by reference
$client->producttocategories()->delete(123);
Update product to category reference
$patch = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Producttocategories\Patch\Patch()) ->setPosition(1); $client->producttocategories()->update(123, $patch);
Suppliers
Get all suppliers
$suppliers = $client->suppliers()->all();
Get supplier
$supplier = $client->suppliers()->get(12345);
Create supplier
$client->suppliers()->create( (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Suppliers\Input\Input()) ->setName('foobar') );
Update supplier
$input = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Suppliers\Input\Input()) ->setName('bazboo'); $client->suppliers()->update(12345, $input);
Delete supplier
$client->suppliers()->delete(12345);
Webhooks
Get all webhooks
$parameter = (new \JacobDeKeizer\Ccv\Parameters\Webhooks\All()) ->setSize(10); // optional $webhooks = $client->webhooks()->all($parameter); $nextParameter = \JacobDeKeizer\Ccv\Parameters\Webhooks\All::fromUrl($webhooks->getNext());
Get a webhook
$webhook = $client->webhooks()->get(12345);
Create a webhook
$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());
Update a webhook
In this example, the webhook will be disabled.
$webhook = (new \JacobDeKeizer\Ccv\Models\Internal\Resource\Webhooks\Patch\Patch()) ->setIsActive(false); $client->webhooks()->update(12345, $webhook);
Delete a webhook
$client->webhooks()->delete(12345);
jacobdekeizer/ccvshop-client 适用场景与选型建议
jacobdekeizer/ccvshop-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 64.26k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2020 年 05 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「api」 「client」 「ccvshop」 「ccv shop」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jacobdekeizer/ccvshop-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jacobdekeizer/ccvshop-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jacobdekeizer/ccvshop-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Mock PSR-18 HTTP client
Asynchronous MQTT client built on React
Client for Google Directions API to add interpolated points to a route consisting of given coordinates.
Alfabank REST API integration
A Flickr wrapper to allow you to call the Flickr api with Guzzle as the backend.Goal is to have 100% Flickr api coverage rather than just upload/display photos (currently at 23%).
统计信息
- 总下载量: 64.26k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-05-17