承接 blabs/fidelynet-sdk-php 相关项目开发

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

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

blabs/fidelynet-sdk-php

最新稳定版本:v2.7.7

Composer 安装命令:

composer require blabs/fidelynet-sdk-php

包简介

a wrapper for FidelyNET loyalty service API

README 文档

README

A PHP Wrapper for FidelyNET API.

Getting started

This SDK lets you interact with backoffice, customer and terminal services. The simplest way of creating an instance of a service is using the ServiceFactory::create() method. It requires 2 arguments, the first one is a string containing desired service, the second is an array containing the related authentication credentials provided by Data Loyalty along with some other optional parameters.

Example of using the factory to create a terminal service instance:

use Blabs\FidelyNet\ServiceFactory;

// Creates an instance of the Terminal service.
$terminal_service = ServiceFactory::create('terminal', [
    'username' => 'wsTerminal01',
    'password' => 'password',
    'terminal' => '000001'
]);

// Uses the instance to query the service to getting info on a campaign id
/** @var \Blabs\FidelyNet\Services\TerminalService $terminal_service */
$terminal_service->getCampaign('1001');

Supported keys for the ServiceFactory parameters array

Other than credentials, you can specify several options within the second argument of the create() method, many of them have already a default value, use following array keys if you need to override them.

  • username
  • password
  • terminal
  • campaign_id
  • demo_mode (boolean)
  • session_persists (boolean)
  • session_id_provider (implementation of \Blabs\FidelyNet\Contracts\SessionIdProviderContract interface)
  • session_type (can be public or private, available for customer service only)
  • http_client (an instance of GuzzleHttp\Client or implementation of GuzzleHttp\ClientInterface)
use Blabs\FidelyNet\ServiceFactory;

// Creates an instance of the Customer service, using a public session and with other customized options.
$customer_service = ServiceFactory::create('customer', [
    // required keys
    'username'          => 'myCustomerUserName',
    'password'          => 'myCustomerPassword',
    'campaign_id'       => '10000',
    // optional keys
    'demo_mode'         => true,
    'session_persists'  => false,
    'session_type'      => 'public',
]);

Required parameters for each service

Each service needs some specific parameters in the config array in order to be instanced.

  • BackofficeService

    • username
    • password
  • TerminalService

    • username
    • password
    • terminal
  • CustomerService

    • username
    • password
    • campaign_id

Session Persistence

FidelyNET APIs provides an authentication system that requires to open a session on the service before starting to make actual requests.

Usually you have to make a first request to authenticate passing your credentials, then you receive a session token that will be used to authorize all subsequent requests. The token is valid for about 15 minutes from the last request made.

The SDK implements this mechanism automatically when creating an instance of the service, and it is also possible to persist the session id through multiple requests (even in multiple instances of the same service). In case of failure of a request for an expired session, the client will automatically make a new login request, renewing the token and reiterating the failed request.

Session persistence is enabled by default when you use ServiceFactory class, you can override this option using session_persists array key in the second argument of the create() method. By default the SDK uses a session persistence "driver" that saves data in the temporary files system directory (typically tmp/ on a *nix system), however you can create your own implementation of the persistence mechanism by implementing the \Blabs\FidelyNet\Contracts\SessionIdProviderContract interface (i.e. using session or any other storage system).

Supported API Actions

So far the SDK supports fewer "actions" than those available on the service, our goal is to provide a library that simplify most common operations.

Service methods reference

A full documentation about every method available on every service will be available ASAP

Testing

composer test

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-07-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固