wr2net/gateway-connect

一个项目,用于连接SEAPE(车辆)、Datawash(人员)、Unicheck(车辆)、ViaCEP(地址)和Fusion(短信)的通用网关实现。

v1.2.2 2021-03-09 18:06 UTC

This package is auto-updated.

Last update: 2024-09-14 06:07:09 UTC


README

此仓库包含一个网关模式,以库的形式实现,可在项目中使用。

当前可用的网关

  • 车辆
  • 人员
  • 位置
  • 短信

要求

  • PHP 7.3
  • Composer

否则,您可以使用Docker Compose文件进行开发

docker-compose up --build

这需要仅使用dockerdocker-compose

用法

SEAPE网关

构造函数要求

  • 缓存实现

方法

  • fetchVehicleRegisterByPlate(string $plate) :string

    接收车辆牌照并从SEAPE获取车辆注册信息,返回JSON。

  • fetchVehicleDecoderWithChassis(string $chassis) : string

    接收车辆底盘号并从SEAPE获取车辆精简器和解码器信息,返回JSON。

UNICHECK网关

构造函数要求

  • 缓存实现

方法

  • fetchVehicleInformation(string $plate) :string

    接收车辆牌照并从UNICHECK获取车辆信息,返回JSON。

DATAWASH网关

构造函数要求

  • 缓存实现

方法

  • fetchPersonInformation(string $cpf) : string

    使用提供的CPF在UNICHECK上获取人员信息,返回JSON。

VIACEP网关

方法

  • fetchLocation(string $cep) : string

    使用提供的CEP在VIACEP上获取公共位置信息,返回JSON。

FUSION网关

方法

  • fetchSmsSend(string $number, string $message, int $type) : string

    发送长短信(0)和短短信(2),并返回JSON。

缓存(磁盘缓存实现)

构造函数要求

  • 标识符前缀
  • 存储的文件系统路径

如何在项目中导入

  1. 将此仓库添加到Composer
    php composer config repositories.gateway-connect vcs https://github.com/wr2net/gateway-connect.git
  1. 需要所需的版本
    php composer require  wr2net/gateway-connect  master@dev
  1. 在您的代码中使用它
    <?php
        declare(strict_types=1);

        require __DIR__ . '/../vendor/autoload.php';

        use Gateway\Gateways\Vehicle\SEAPEGatewayImpl as SEAPE;
        use Gateway\Gateways\Vehicle\UNICHECKGatewayImpl as UNICHECK;
        use Gateway\Gateways\Person\DATAWASHGatewayImpl as DATAWASH;
        use Gateway\Gateways\Location\VIACEPGatewayImpl as VIACEP;
        use Gateway\Gateways\SMS\FUSIONGatewayImpl as FUSION;
        use Gateway\Integrations\CARE\CAREClientImpl as CAREClient;
        use Gateway\Integrations\Models\CARE;

        $seape = new SEAPE($key, $user, $auth);

        $unicheck = new UNICHECK($user, $auth);

        $datawash = new DATAWASH($client, $user, $auth);

        $viacep = new VIACEP();

        $fusion = new FUSION($user, $token);

        $care = new CAREClient();


        // VEHICLE
        print_r($unicheck->fetchVehicleInformation("PLATE"));
        print_r($seape->fetchVehicleRegisterByPlate("PLATE"));
        print_r($seape->fetchVehicleDecoderWithChassis("CHASSIS"));

        // PERSON
        print_r($datawash->fetchPersonInformation("CPF"));

        // LOCATION
        print_r($viacep->fetchLocation("CEP"));

        // SEND SMS
        print_r($fusion->fetchSmsSend("NUMBER_PHONE", "MESSAGE", "TYPE"));

        //CARE
        $associate = new CARE\Associate(1,"TESTE USER","098766543210");
        $associate->addProduct(new CARE\Product(10, ""));
        print_r($care->createAssociate($associate));
        print_r($care->removeAssociateProducts("098766543210",10));
        print_r($care->getAssociates());
        print_r($care->getProducts());
        print_r($care->getAssociateSituation("098766543210", 10));
        print_r($care->getAssociateProducts("098766543210"));