housemates/connect-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

housemates/connect-api

最新稳定版本:0.8

Composer 安装命令:

composer require housemates/connect-api

包简介

Housemate connect API php client

README 文档

README

Latest Version on Packagist Total Downloads

The Housemates Connect API provides a set of endpoints to access and interact with the Housemates Connect platform. It enables developers to programmatically retrieve property and room information, manage bookings, create enquiries, and obtain various details related to cities and amenities.

Key Features

  • Property Management: Retrieve property listings and details, including amenities, location, and availability.
  • Room Management: Access room information, including pricing, availability, and booking periods.
  • Booking Operations: Start and complete the checkout process, including handling payment details and resident information.
  • Enquiry Management: Create and retrieve enquiries for specific rooms or properties.
  • City Information: Obtain university information about cities.
  • Amenity Details: Retrieve a list of available amenities and their descriptions.

Installation

You can install the package via composer:

Prerequisites

  • At least PHP 7.4 installed on your system.
  • Housemates Connect API credentials:
    • Access Token: b2fcrSRUV8OsN6Yn79UKGIiGDCLUJtGqEL3m2aO4
    • API Partner ID: 01H0N04529EXND84J5AN2ZH7CX
composer require housemates/connect-api

Getting Started

Configuration

In order to use the Housemates Connect API, you must first configure the package with your API credentials. You can do so as follows;

$configuration = new \Housemates\ConnectApi\Configuration();
$configuration
    ->setAccessToken('b2fcrSRUV8OsN6Yn79UKGIiGDCLUJtGqEL3m2aO4')
    ->setApiPartnerId('01H0N04529EXND84J5AN2ZH7CX');

$connectApi = new Housemates\ConnectApi\ApiClient($configuration);

You can now use the $connectApi instance to access the various endpoints provided by the API.

Get Properties

You can get properties by calling the getProperties method on the $connectApi instance. This method accepts an optional $query parameter, which can be used to filter the results. For example, to get properties in Manchester, you can do the following;

$filters = new \Housemates\ConnectApi\Filters\PropertyFilter();
$filters->setCityFilter('manchester')
try{
    $results = $connectApi->getProperties($filters);
    print_r($results->getData()->getItems());
} catch (\Exception $e) {
    // Handle exception
}

Please refer to the documentation for a full list of available filters.

Get Property

A single property can be retrieved by calling the getProperty method on the $connectApi instance. This method accepts a property ID as a parameter. For example, to get the property with ID 01H0N04529EXND84J5AN2ZH7CX, you can do the following;

try{
    $property = $connectApi->getProperty('01H0N04529EXND84J5AN2ZH7CX');
    print_r($property->getData()->getItem());
} catch (\Exception $e) {
    // Handle exception
}

Get Rooms

You can get rooms by calling the getRooms method on the $connectApi instance. This method accepts an optional $query parameter, which can be used to filter the results. For example, to get rooms in within a certain price range e.g. £100 to £400, you can do the following;

$filters = new \Housemates\ConnectApi\Filters\RoomFilter();
$filters->setPriceRangeFilter('[100,400]'); // Please note that the price range must be in the format [min,max]

try{
    $results = $connectApi->getRooms($filters);
    print_r($results->getData()->getItems());
} catch (\Exception $e) {
    // Handle exception
}

If you want to sort the results, you can do so by passing a Sort object to the getRooms method. For example, to sort the results by price in ascending order, you can do the following;

$filters = new \Housemates\ConnectApi\Filters\RoomFilter();
$filters->setPriceRangeFilter('[100,400]'); // Please note that the price range must be in the format [min,max]

$sort = new \Housemates\ConnectApi\Sort();
$sort->setSortBy('price', 'asc');

try{
    $results = $connectApi->getRooms($filters, $sort);
    print_r($results->getData()->getItems());
} catch (\Exception $e) {
    // Handle exception
}

Get Room

To get a single room, you can call the getRoom method on the $connectApi instance. This method accepts a room ID as a parameter. For example, to get the room with ID 01H0N04529EXND84J5AN2ZH7CX, you can do the following;

try{
    $room = $connectApi->getRoom('01H0N04529EXND84J5AN2ZH7CX');
    print_r($room->getData()->getItem());
} catch (\Exception $e) {
    // Handle exception
}

Get Booking periods for a room

To get booking periods for a room, you can call the getBookingPeriods method on the $connectApi instance. This method accepts a room ID as a parameter. For example, to get the booking periods for the room with ID 01H0N04529EXND84J5AN2ZH7CX, you can do the following;

try{
    $bookingPeriods = $connectApi->getBookingPeriods('01H0N04529EXND84J5AN2ZH7CX');
    print_r($bookingPeriods->getData()->getItems());
} catch (\Exception $e) {
    // Handle exception
}

Start Checkout

To start the checkout process, you can call the startCheckout method on the $connectApi instance. This method accepts a room ID, booking period ID and Operator ID as parameters. For example, to start the checkout process for the room with ID 01H0N7WS7ZN1DGEJFF2C14K8NJ, you can do the following;

$checkoutStartRequest = new \Housemates\ConnectApi\Requests\CheckoutStartRequest();
$checkoutStartRequest
    ->setRoomId('01H0N7WS7ZN1DGEJFF2C14K8NJ')
    ->setBookingPeriodId('01H1TQKHVCN2F00MP2D7ACX6S8')
    ->setOperatorId('9258a234-f90b-4871-b434-247087fec215');
try{
    $checkoutStartResponse = $connectApi->startCheckout($checkoutStartRequest);
    print_r($checkoutStartResponse->getData()));
} catch (\Exception $e) {
    // Handle exception
}

Please refer to the documentation for a full list of endpoints.

Changelog

Please see CHANGELOG for more information what has changed recently.

Security

If you discover any security related issues, please email muhammad@housemates.io instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固