serkancelik17/hotel_content_api_sdk
Composer 安装命令:
composer require serkancelik17/hotel_content_api_sdk
包简介
Hotelbeds Hotel-API SDK for PHP
README 文档
README
Introduction
Hotelbeds SDK for PHP is a set of utilities whose main goal is to help in the development of PHP applications that use APItude, the Hotelbeds API. This is a composer library available on packagist.org repository.
https://packagist.org/packages/hotelbeds/hotel-api-sdk-php
License
This softwared is licensed under the LGPL v2.1 license. Please refer to the file LICENSE for specific details and more license and copyright information.
Install
Install from console with Composer utility:
composer require hotelbeds/hotel-api-sdk-php
Using Composer Dependency Manager with PHPStorm: http://blog.jetbrains.com/webide/2013/03/composer-support-in-phpstorm/
Testing
In the directory unit tests can find different tests that can be run with phpunit. There are different sets of tests: Availability and bookings.
.\vendor\bin\phpunit --testsuite availability
This testsuite execute: status of API, make availability on PMI destination, select one room and do checkrate and booking.
Using SDK
Overview
The HotelApiClient class has different methods that implement the various calls HotelAPI:
- Availability
- CheckRate
- BookingConfirm
- BookingCancellation
- BookingList
- Status
Each method has a parameter that is ApiHelper type, there are four possible types:
- Availability
- CheckRate
- Booking
- BookingList
All responses each call can either iterate using PHP with objects or arrays. Internally converts the JSON response structure PHP associative arrays.
Include library using autoload PSR-0
<?php require __DIR__ .'/vendor/autoload.php'; use hotelbeds\hotel_api_sdk\HotelApiClient; use hotelbeds\hotel_api_sdk\model\Destination; use hotelbeds\hotel_api_sdk\model\Occupancy; use hotelbeds\hotel_api_sdk\model\Pax; use hotelbeds\hotel_api_sdk\model\Rate; use hotelbeds\hotel_api_sdk\model\Stay; use hotelbeds\hotel_api_sdk\types\ApiVersion; use hotelbeds\hotel_api_sdk\types\ApiVersions; use hotelbeds\hotel_api_sdk\messages\AvailabilityRS; $reader = new Zend\Config\Reader\Ini(); $config = $reader->fromFile(__DIR__.'/HotelApiClient.ini'); $cfgApi = $config["apiclient"]; $apiClient = new HotelApiClient($cfgApi["url"], $cfgApi["apikey"], $cfgApi["sharedsecret"], new ApiVersion(ApiVersions::V1_0), $cfgApi["timeout"]); $rqData = new \hotelbeds\hotel_api_sdk\helpers\Availability(); $rqData->stay = new Stay(DateTime::createFromFormat("Y-m-d", "2016-02-01"), DateTime::createFromFormat("Y-m-d", "2016-02-10")); $rqData->destination = new Destination("PMI"); $occupancy = new Occupancy(); $occupancy->adults = 2; $occupancy->children = 1; $occupancy->rooms = 1; $occupancy->paxes = [ new Pax(Pax::AD, 30, "Mike", "Doe"), new Pax(Pax::AD, 27, "Jane", "Doe"), new Pax(Pax::CH, 8, "Mack", "Doe") ]; $rqData->occupancies = [ $occupancy ]; $availRS = $apiClient->availability($rqData);
Iterate availability results
After availability method call can iterate results with iterator or can read with array form.
// Iterate all returned hotels with an Hotel object foreach ($availRS->hotels->iterator() as $hotelCode => $hotelData) { // Get all hotel data (from Hotel object $hotelData) // Iterate all rooms of each hotel foreach ($hotelData->iterator() as $roomCode => $roomData) { // Iterate all rate of each room foreach($roomData->rateIterator() as $rateKey => $rateData) { } } }
serkancelik17/hotel_content_api_sdk 适用场景与选型建议
serkancelik17/hotel_content_api_sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 05 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 serkancelik17/hotel_content_api_sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 serkancelik17/hotel_content_api_sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL-2.1
- 更新时间: 2022-05-25