承接 wedesignit/hotelprofessionals-api-client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱: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.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固