承接 up2date/flow-php-sdk 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

up2date/flow-php-sdk

最新稳定版本:0.4.0

Composer 安装命令:

composer require up2date/flow-php-sdk

包简介

README 文档

README

The Flow PHP library provides convenient access to the Flow API from applications written in the PHP language. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API responses which makes it compatible with a wide range of versions of the Flow API.

Requirements

PHP 8.0 and later.

Composer

You can install the sdk via Composer. Run the following command:

composer require up2date/flow-php-sdk

To use the bindings, use Composer's autoload:

require_once 'vendor/autoload.php';

Dependencies

The bindings require the following extensions in order to work properly:

  • curl, although you can use your own non-cURL client if you prefer
  • json
  • mbstring (Multibyte String)

If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available.

Getting Started

Create a Flow client with configuration:

Flow::setApiKey('10|x1lf89YRu4YVQEP7rHcnWA6YdHlGgl3nj7fAykGL');
Flow::setApiBase('https://flow.up2date.ro/api');
$flow = new \Up2date\FlowPhpSdk\FlowClient();

Customers

Create a customer

try {
    $customer = $flow->customers->create([
        'email' => 'john.doe@example.com',
        'firstName' => 'John',
        'lastName' => 'Doe',
        'countryCode' => 40,
        'phone' => '723534609'
    ]);
    echo $customer;
} catch (Up2date\FlowPhpSdk\Exception\ApiErrorException $exception) {
    echo $exception->getMessage();
}

Find a customer by email address

try {
    $customer = $flow->customers->findOne([
        'email' => 'john.doe@example.com'
    ]);
    echo $customer;
} catch (Up2date\FlowPhpSdk\Exception\ApiErrorException $exception) {
    echo $exception->getMessage();
}

Find a customer by phone number

try {
    $customer = $flow->customers->findOne([
        'phone' => '723512322'
    ]);
    echo $customer;
} catch (Up2date\FlowPhpSdk\Exception\ApiErrorException $exception) {
    echo $exception->getMessage();
}

Loyalty

Get the loyalty rules

try {
    $loyaltyRules = $flow->loyalty->getRules();
    echo $loyaltyRules;
} catch (Up2date\FlowPhpSdk\Exception\ApiErrorException $exception) {
    echo $exception->getMessage()."\n";
}

Add loyalty points from amount

try {
    $loyaltyParams = [
        'total' => 100, // Amount in the default currency
        'details' => 'Bonus points'
    ];

    $customer = $customer->addLoyaltyFromAmount($loyaltyParams);
    
} catch (Up2date\FlowPhpSdk\Exception\ApiErrorException $exception) {
    echo $exception->getMessage()."\n";
}

Remove loyalty points from amount

try {
    $loyaltyParams = [
        'total' => 100,
        'points' => 20,
        'details' => 'Spend points'
    ];

    $customer = $customer->removeLoyaltyFromAmount($loyaltyParams);
    
} catch (Up2date\FlowPhpSdk\Exception\ApiErrorException $exception) {
    echo $exception->getMessage()."\n";
}

Calculate loyalty points from amount

try {
    $params = [
        'total' => 100
    ];

    $points = $flow->loyalty->calculate($params);
    echo $points->data;
    
} catch (Up2date\FlowPhpSdk\Exception\ApiErrorException $exception) {
    echo $exception->getMessage()."\n";
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2023-08-03