sightseeingtech/passhub-api

v1.0.0 2018-06-21 17:22 UTC

This package is not auto-updated.

Last update: 2024-09-29 05:42:02 UTC


README

PassHub API 文档

使用 PHP 访问 PassHub。此模块提供了对 API 的高层和底层调用。

要求

PHP 5.5 及以上版本

安装与使用

Composer

要通过 Composer 安装绑定,请将以下内容添加到 composer.json

{
  "require": {
      "sightseeingtech/passhub-api": "1.0"
   }
}

然后运行 composer install

手动安装

下载文件并包含 autoload.php

    require_once('/path/to///vendor/autoload.php');

测试

要运行单元测试

composer install
./vendor/bin/phpunit

入门指南

请按照安装过程进行操作,然后运行以下命令

<?php
require_once(__DIR__ . '/vendor/autoload.php');

try {
    $config = passhub\client\Configuration::getDefaultConfiguration();

    $config->setApiKey('X-Api-Key', 'YOUR_API_KEY');
    $config->setHost('YOUR_HOST');

    $orderRecordResource = new passhub\client\api\OrderRecordResourceApi(
        new GuzzleHttp\Client(['verify' => false]),
        $config
    );

    $item = new passhub\client\model\OrderItem([
        'customer_name' => 'My Name',
        'customer_type' => 'ADULT',
        'sku' => '1GL5_Child',
        'quantity' => 1,
        'price_paid' => 55.2,
        'tour_date' => new DateTime('2018-06-10')
    ]);

    $group = new passhub\client\model\GroupEntryDTO([
        'group_name' => 'TESTSDK_GROUP_NAME',
        'voucher_per_person' => true,
        'items' => [$item],
    ]);

    $order = new passhub\client\model\OrderRecordDTO([
        'amount' => 110.4,
        'customer_email' => 'test@test.com',
        'vendor_order_id' => 'TESTSDK_ORDER_1',
        'originiator' => 'TESTSDK_ORIGINATOR',
        'groups' => [$group],
    ]);

    $createdOrder = $orderRecordResource->createOrderRecord($order);

    echo $createdOrder->getId();
} catch (Exception $e) {
    print_r($e->getMessage());
}

?>

API 端点文档

模型文档

授权文档

X-Api-Key

  • 类型: API 密钥
  • API 密钥参数名: X-Api-Key
  • 位置: HTTP 头部