nicdev/webflow-sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nicdev/webflow-sdk

Composer 安装命令:

composer require nicdev/webflow-sdk

包简介

Use all the features offered by the Webflow API

README 文档

README

BEWARE! This is a super early version in active development. So please be careful if you decide to use it ✌️

This is open source software and not in any official way supported by Webflow.

This PHP SDK allows you to interact with the Webflow API easily.

There are two main ways to use this library. By accessing Sites and other entities and interacting with their respective classes or...

See the Entities documentation

...directly as an API wrapper through the underlying Webflow class.

See the API client wrapper documentation

Table of Contents

Installation

Install the SDK via Composer:

composer require nicdev/webflow-sdk

Usage

Client (API Wrapper)

To use this SDK, first create a new instance of the Webflow class with your API token.

use Nicdev\WebflowSdk\Webflow;

$token = 'your-webflow-api-token';
$webflow = new Webflow($token);

Get the current user's information

$user = $webflow->user();

Get the authenticated user's authorization information

$authInfo = $webflow->authInfo();

List all sites associated with the authenticated user

$sites = $webflow->listSites();

Fetch a specific site by its ID

$site = $webflow->getSite($siteId);

Publish a specific site by its ID

$webflow->publishSite($siteId);

List all domains associated with a specific site by its ID

$domains = $webflow->listDomains($siteId);

List all webhooks associated with a specific site by its ID

$webhooks = $webflow->listWebhooks($siteId);

Fetch a specific webhook associated with a specific site by their IDs

$webhook = $webflow->getWebhook($siteId, $webhookId);

Create a webhook for a specific site

use Nicdev\WebflowSdk\Enums\WebhookTypes;

$triggerType = WebhookTypes::SITE_PUBLISH;
$url = 'https://your-webhook-url.com';
$filter = []; // Optional filter array

$webflow->createWebhook($siteId, $triggerType, $url, $filter);

Delete a webhook for a specific site

$webflow->deleteWebhook($siteId, $webhookId);

List all collections for a specific site

$collections = $webflow->listCollections($siteId);

Fetch a specific collection by its ID

$collection = $webflow->fetchCollection($collectionId);

List items for a specific collection by its ID

$page = 1; // Optional page number

$items = $webflow->listItems($collectionId, $page);

Create an item in a specific collection by its ID

$fields = [
    'field-name' => 'field-value',
    // ...
];
$live = false; // Optional live mode

$item = $webflow->createItem($collectionId, $fields, $live);

Get an item by its ID

$item = $webflow->getItem($collectionId, $itemId)

Publish one or more items by their ID

$itemIds = ['your-item-id', 'your-other-item-id'];
    
$webflow->publishItems($collection, $itemIds);

Update an item by its ID

$fields = $fields = [
    'field-name' => 'field-value',
    // ...
];
$live = false; // Optional publish 

$webflow->updateItem($collectionId, $itemId, $fields, $live)

Patch an item by its ID

I don't see a real difference between the update and patch methods but they have been matched to their respective endpoints. For more information see the documentation.

$fields = $fields = [
    'field-name' => 'field-value',
    // ...
];
$live = false; // Optional publish 

$webflow->updateItem($collectionId, $itemId, $fields, $live)

Delete or un-publish an item by its ID

$live = true; // Optional. When set to true the item will be un-published but kept in the collection

$webflow->deleteItem($collectionId, $itemId, $live)

List products/SKUs for a specific site by its ID.

$page = 1; // Optional page number
$webflow->listProducts($siteId, $page);

Create a Product and SKU

$product = [
    'slug' = 'foo-bar',
    'name' => 'Foo Bar',
];
$sku = [
    'slug' => 'foo-bar-small',
    'name' => 'Foo Bar (S)',
    'price' => [
        'value' => 990,
        'unit' => 'USD'
    ]
]; // Optional
$webflow->createProductAndSku($siteId, $product, $sku)

Get Products and SKUs

$webflow->getProduct($site, $product);

Update a Product

$fields = [
    'name' => 'New Foo Bar',
    '_archived' => true
];

$webflow->updateProduct($siteId, $productId, $fields);

Create a SKU

$sku = [
    'slug' => 'foo-bar-Medium',
    'name' => 'Foo Bar (M)',
    'price' => [
        'value' => 1190,
        'unit' => 'USD'
    ]
];
$webflow->createSku($siteId, $product, $sku);

Update a SKU

$sku = [
    'slug' => 'foo-bar-Medium',
    'name' => 'Foo Bar (M) Discounted!!',
    'price' => [
        'value' => 1290,
        'unit' => 'USD'
    ]
];

$webflow->updateSku($siteId, $productId, $skuId, $sku);

Inventory for a specific item

$collectionId = 'your-collection-id'; //likely to be the SKUs collection.
$webflow->getInventory($collectionId, $skuId)

Update Inventory

$fields = [
    'inventory_type' => 'infinite'
];

$webflow->updateInventory($collectionId, $skuId, $fields);

List orders

$page = 1; // Optional page number

$items = $webflow->listOrders($collectionId, $page);

Get an Order

$webflow->getOrdr($siteId, $orderId)

Update an Order

$fields = [
    'comment' => 'Adding a comment to this order'
];

$webflow->updateOrder$siteId, $orderId, $fields);

Fulfill an Order

$notifyCustomer = true; // Optional, defaults to false

$webflow->fullfillOrder($siteId, $orderId, $notifyCustomer);

Un-fulfill an Order

$webflow->unfulfillOrder($siteId, $orderId);

Refund an Order

$webflow->refundOrder($siteId, $orderId);

Get Ecommerce settings for a Site

$webflow->getEcommerceSettings($siteId);

Entities

To use this SDK, first create a new instance of the Webflow class with your API token.

use Nicdev\WebflowSdk\Webflow;

$token = 'your-webflow-api-token';
$webflow = new Webflow($token);

Get sites

$sites = $webflow->sites; // [Site $site1, Site $site2...]
// or
$sites = $webflow->sites()->list(); // [Site $site1, Site $site2...]

Fetch a specific site by its ID

$site = $webflow->sites($siteId) // Site $site;
// or
$site = $webflow->sites()->get($siteId) // Site $site;

Publish a domain

$site->publish();

Get a site's domains

$webflow->sites($siteId)->domains();
// or
$webflow->sites($siteId)->domains;

Get site's collections

$site->collections; // [Collection $collection1, Collection $collection2, ...]
// or
$site->collections(); // [Collection $collection1, Collection $collection2, ...]

Fetch a specific collection by its ID

$site->collections($collectionId) // Collection $collection;

Fetch a collection's items

$site->collections($collectionId)->items(); // [Item $item1, Item $item2, ...]
// or
$site->collections($collectionId)->items; // [Item $item1, Item $item2, ...]

Fetch a site's webhooks

$site->webhooks(); // [Webhook $webhook1, Webhook $webhook2, ...]
// or
$site->webhooks; // [Webhook $webhook1, Webhook $webhook2, ...]

Fetch a site's products

$site->products(); // [Product $product1, Product $product2, ...]
// or
$site->products; // [Product $product1, Product $product2, ...]

Fetch a site's orders

$site->webhooks(); // [Order $order1, Order $order2, ...]
// or
$site->webhooks; // [Order $order1, Order $order2, ...]

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

This SDK is licensed under the MIT License. See LICENSE for more information.

nicdev/webflow-sdk 适用场景与选型建议

nicdev/webflow-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 68 次下载、GitHub Stars 达 5, 最近一次更新时间为 2023 年 04 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 nicdev/webflow-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nicdev/webflow-sdk 我们能提供哪些服务?
定制开发 / 二次开发

基于 nicdev/webflow-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 68
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-19