Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andrebraghini/hunit-js
Communication library for HUnit Channel Manager
https://github.com/andrebraghini/hunit-js
channel hsystem hunit manager
Last synced: 18 days ago
JSON representation
Communication library for HUnit Channel Manager
- Host: GitHub
- URL: https://github.com/andrebraghini/hunit-js
- Owner: andrebraghini
- License: mit
- Created: 2018-09-12T14:52:15.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T16:08:58.000Z (almost 2 years ago)
- Last Synced: 2024-10-12T08:09:40.563Z (about 1 month ago)
- Topics: channel, hsystem, hunit, manager
- Language: TypeScript
- Homepage:
- Size: 962 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Communication library for HUnit, HSystem Channel Manager
## Content
1. [Installation](#installation)
2. [Usage](#usage)
## Installation
```bash
npm install hunit-js --save
```## Usage
```ts
import { HUnitClient } from 'hunit-js';// Defines authentication credentials. Hotel id, user and password.
const credentials = {
hotelId: '20',
userName: 'hotel.user',
password: 'hotel.password'
};// Instantiate the client
const hunit = new HUnitClient(credentials);// Do request
hunit.portalRead()
.then(console.log)
.catch(console.error);
```### Example list
The examples below show the most diverse communications being made to a single hotel in a simple way.
```ts
import { HUnitClient } from 'hunit-js';const hunit = new HUnitClient({ hotelId: '20', userName: 'hotel.user', password: 'hotel.password' });
// Get OTAs list
hunit.portalRead()
.then(portalList => console.log({ portalList }))
.catch(console.error);// Get new, changed or canceled reservations
hunit.bookingRead()
.then(reservationList => console.log({ reservationList }))
.catch(console.error);// Get specific reservation by HUnit ID
hunit.bookingByIdRead({ locatorId: '21565' })
.then(reservation => console.log({ reservation }))
.catch(console.error);// Get specific reservation by Portal ID
hunit.bookingByIdRead({ portalId: '1', channelReservationId: '155511' })
.then(reservation => console.log({ reservation }))
.catch(console.error);// Confirm receipt of reservation
const confirmationList = [
{ reservationId: '12', pmsReservationIdentifier: 'my_id_1' },
{ reservationId: '52', pmsReservationIdentifier: 'my_id_2' },
{ reservationId: '589', pmsReservationIdentifier: 'my_id_5' }
];
hunit.confirmePost(confirmationList)
.then(confirmeResult => console.log({ confirmeResult }))
.catch(console.error);// Update inventory
const updates = [
// Remove availability from apartment 12, from December 25 to December 31
// if you do not enter the day of the week in the "dateRange" tag, all days will be considered
{
roomTypeId: '12',
availability: 0,
dateRange: { from: new Date('2021-12-25'), to: new Date('2021-12-31') }
},
// Remove availability from apartment 12, during the weekends of January
{
roomTypeId: '12',
availability: 0,
dateRange: { from: new Date('2021-01-01'), to: new Date('2021-01-31'), fri: true, sat: true }
},
// Close availability from apartment 222 sending a sell stop
{
roomTypeId: '222',
dateRange: { from: new Date('2021-12-25'), to: new Date('2021-12-31') },
stopSell: true
},
// Open availability from apartment 15 canceling a sell stop
{
roomTypeId: '15',
dateRange: { from: new Date('2021-12-25'), to: new Date('2021-12-31') },
stopSell: false
}
];
hunit.availabilityUpdate(updates)
.then(availabilityUpdateResult => console.log({ availabilityUpdateResult }))
.catch(console.error);// Get packages list
hunit.packageRead()
.then(packageList => console.log({ packageList }))
.catch(console.error);// Get room rate list
hunit.roomRateRead()
.then(roomRateList => console.log({ roomRateList }))
.catch(console.error);// Update occupancy rate
const occupancyRateList = [
{ date: new Date('2020-01-01'), occupancy: 15 },
{ date: new Date('2020-01-02'), occupancy: 21 },
{ date: new Date('2020-01-03'), occupancy: 13 }
];
hunit.occupancyRateUpdate(occupancyRateList)
.then(rateUpdateResult => console.log({ rateUpdateResult }))
.catch(console.error);
```The requests below are made to get reservations and confirm the receipt of several hotels at the same time in a single request.
```ts
import { HUnitClient } from 'hunit-js';const hunit = new HUnitClient({ userName: 'hotel.user', password: 'hotel.password' });
// Get new, changed or canceled reservations for all hotels
hunit.bookingReadOneCall()
.then(reservationList => console.log({ reservationList }))
.catch(console.error);// Confirm receipt of reservation for all hotels
const confirmationListOneCall = [
{ hotelId: '65', reservationId: '12', pmsReservationIdentifier: 'my_id_1' },
{ hotelId: '65', reservationId: '52', pmsReservationIdentifier: 'my_id_2' },
{ hotelId: '77', reservationId: '98', pmsReservationIdentifier: 'my_id_78' }
];
hunit.bookingConfirmationOneCall(confirmationListOneCall)
.then(confirmeResult => console.log({ confirmeResult }))
.catch(console.error);
```