wedesignit/hotelprofessionals-api-client 问题修复 & 功能扩展

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

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

wedesignit/hotelprofessionals-api-client

Composer 安装命令:

composer require wedesignit/hotelprofessionals-api-client

包简介

PHP Api wrapper for the Hotelprofessionals Api V1

README 文档

README

Requirements

PHP 7.4 or higher.

Installation

compose require wedesignit/hotelprofessionals-api-client

Usage

use WeDesignIt\HotelprofessionalsApiClient\Client;
use WeDesignIt\HotelprofessionalsApiClient\Hotelprofessionals;

// Can be obtained through HP.
$apiKey = "2|xyzthisapikeywontwork";
// Establish the connection.
$client = Client::init($apiKey);
$hp = Hotelprofessionals::init($client);

// Quick check if everything is properly setup.
$hp->authenticate();

Extra options

Custom URL

In case you want to use a custom URL (e.g. to target a testing environment), you can pass the base URL for the API as second parameter to the client:

$client = Client::init($apiKey, 'https://integratie.hotelprofessionals.nl/api/v1/')

Caution

It is important to end the base URL with a forward slash (/), otherwise you may receive weird results.

Properties

As third parameter, you can pass an array with properties. The benefit of using an array is that it can be infinitely expanded while remaining backwards compatible. It also keeps the __constructor from becoming bloated.

Basic auth

Sometimes a website might use basic auth. Simply add basicAuth to the $properties array:

$client = Client::init($apiKey, 'https://integratie.hotelprofessionals.nl/api/v1/', [
    'basicAuth' => 'yourBasicAuthSecret',
])

If you're curious about how this works, you can read more about it here.

Debug mode

If you're curious about the calls made, you can enable debug mode. On each request, it will perform the following code:

var_dump(urldecode($request->getRequestTarget()))

Simply set debugMode to true in the $properties array.

$client = Client::init($apiKey, 'https://integratie.hotelprofessionals.nl/api/v1/', [
    'debugMode' => true,
])

Read the docs

We highly suggest you to read the official API docs, this will give you more information on what the API expects. This can be found at: https://www.hotelprofessionals.nl/api/documentation.

Resources

There's lots of resources available to fetch data from Hotelprofessionals directly.

Department categories

// list all available department categories
$hp->departmentCategory()->list();
// get a specific department category
$hp->departmentCategory()->show(1449);

Departments

// list all available Departments
$hp->department()->list();
// get a specific department
$hp->department()->show(56);

Occupation

// list all available occupations
$hp->occupation()->list();
// get a specific occupation
$hp->occupation()->show(739);

Experiences

// list all available experiences
$hp->experience()->list();
// get a specific experiences
$hp->experience()->show(1449);

Languages

// list all available languages
$hp->language()->list();
// get a specific languages
$hp->language()->show(1449);

Educations

// list all available education
$hp->education()->list();
// get a specific education
$hp->education()->show(1449);

Employment types

// list all available employment types
$hp->employmentType()->list();
// get a specific employment type
$hp->employmentType()->show(1449);

Function features

// list all available function features
$hp->functionFeature()->list();
// get a specific function feature
$hp->functionFeature()->show(1449);

Countries

// list all available countries
$hp->country()->list();
// get a specific country
$hp->country()->show(149);

Employers

Note: only a parent account (which can have sub accounts) can access this endpoint. This endpoint lists all sub accounts for the employer associated with the used API key.

// list all available Employers
$hp->employer()->list();
// get a specific Employer
$hp->employer()->show(432);

JobListings

// list all job listings (including for sub account(s) if current account is a parent)
$hp->jobListing()->list();

// get a specific job listing
$jobListingResource = $hp->jobListing()->show(10552);

// store a job listing (see documentation for full structure)
$attributes = [
    'job_listings' => [
        'title' => [
            'nl' => 'Nieuwe vacature', 
            'en' => 'New job listing', 
        ]    
    ],
];
$newJobListingResource = $hp->jobListing()->store($attributes);
$newId = $newJobListingResource['data']['id'];

// update a job listing
$attributes['title']['en'] = 'New job listing title, in the English locale';
$updatedJobListingResource = $hp->jobListing()->update($newId, $attributes);

// publish a job listing (if not already published)
$hp->jobListing()->publish(10552);

// delete a job listing (generally not recommended)
$hp->jobListing()->delete($newId);

Pagination

Every list method will return a paginated response, the page can be changed by using the page method:

// return page 3 of the department list.
$hp->department()->page(3)->list();

Filtering

Some endpoints support filtering. Be sure to read the documentation to know which endpoints support which filters. The documentation will also state which column(s) and which delimiter(s) are supported. Note that if a delimiter isn't supported, the default will be used.

The structure for filters is as follows:

// Main array holds sub-arrays:
$filters = [
    [
        // The column to filter on. Required.
        'column' => $columnToFilter, 
        // The value to apply. Required.
        'value' => $valueToFilter,
        // The delimiter for filtering. Optional, defaults to '='.
        'delimiter' => '=',  
    ],
];

Filters can be applied like so:

$filters = [
    [
        'column' => 'status',
        'value' => 'published',
        'delimiter' => '=',
    ],
];

$hp->jobListing()->filter($filters)->list();

Note that duplicate filters will be processed and might caught unexpected results.

wedesignit/hotelprofessionals-api-client 适用场景与选型建议

wedesignit/hotelprofessionals-api-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 04 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「Hotelprofessionals」 「api wrapper Hotelprofessionals」 「php client Hotelprofessionals」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 wedesignit/hotelprofessionals-api-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 wedesignit/hotelprofessionals-api-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 wedesignit/hotelprofessionals-api-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-04-07