1.4.0 • Published 3 years ago

@rpallas/impala-js v1.4.0

Weekly downloads
5
License
ISC
Repository
github
Last release
3 years ago

Impala API Javascript SDK

Actions Status

A port of https://github.com/GetImpala/impala-php

Installation

It's as simple as:

$ npm i @rpallas/impala-js

Tests

To run the tests you can run the following commands:

$ npm i
$ npm test

Obtaining an API key

To use this library, you will need an Impala API key. More information can be found in the 'Getting Started' section of the Impala developer documentation.

Getting Started

After installation, you can create an impala client like this:

const ImpalaSDK = require('@rpallas/impala-js')

const impala = ImpalaSDK.create('api-key');

Working with a single hotel

If your application will only be dealing with a single hotel at a time, you can instantiate the Impala API like this:

const hotel = ImpalaSDK.create('api-key', { hotelId: 'hotelId' });

Working with multiple hotels

If your application will be dealing with multiple hotels, you can omit the hotelId config parameter, like so:

const impala = ImpalaSDK.create('api-key');

// You can then pass the hotelId directly to the method
await impala.getBookings({ hotelId: 'hotelId' });

// Or with extra parameters
await impala.getBookings({
  hotelId: 'hotelId',
  startDate: '2018-02-03',
  endDate: '2018-02-05'
});

// Or, you can call getHotel to return a single-hotel API instance
const hotel = impala.getHotel('hotelId')

// You can then call the API methods like normal
await hotel.getBookings();

Making API calls

API methods accept an object as their first argument, containing the parameters for the API call. This can be omitted if there are no arguments to set.

API methods that take an ID have the ID as the first argument.

API methods that update a resource take the object representation of a JSON merge patch as their second argument.

For example:

const ImpalaSDK = require('@rpallas/impala-js')
const impala = impalaSDK.create('api-key');
const hotel = impala.getHotel('hotelId')

await hotel.updateBookingById('bookingId', { start: 123456, roomIds: ['abc', 'cde']})

Config

A config object containing the following properties can be passed to the create function.

  • hotelId - The hotelId of the hotel to return when working with a single hotel.
  • useragent - A useragent string which is appended to the User-Agent header in requests. Can also be set to false to disable the useragent header.

Example

const config = {
  hotelId: 'hotelId',
  useragent: `${myAppName}/${myAppVersion}`
}
const impala = ImpalaSDK.create('api-key', config);

API methods

NameHTTP API endpoint
getAllocationByIdGET /v2/hotel/:hotelId/allocation/:allocationId
getAllocationsGET /v2/hotel/:hotelId/allocation
getAreaByIdGET /v2/hotel/:hotelId/area/:areaId
getAreasGET /v2/hotel/:hotelId/area
getAreaTypeByIdGET /v2/hotel/:hotelId/area-type/:areaTypeId
getAreaTypesGET /v2/hotel/:hotelId/area-type
getBillByIdGET /v2/hotel/:hotelId/bill/:billId
getChargeByIdForBillGET /v2/hotel/:hotelId/bill/:billId/charge/:chargeId
getChargesForBillGET /v2/hotel/:hotelId/bill/:billId/charge
createChargeForBillPOST /v2/hotel/:hotelId/bill/:billId/charge
refundChargeByIdForBillPOST /v2/hotel/:hotelId/bill/:billId/charge/:chargeId/refund
getPaymentByIdForBillGET /v2/hotel/:hotelId/bill/:billId/payment/:paymentId
getPaymentsForBillGET /v2/hotel/:hotelId/bill/:billId/payment
createPaymentForBillPOST /v2/hotel/:hotelId/bill/:billId/payment
refundPaymentByIdForBillPOST /v2/hotel/:hotelId/bill/:billId/payment/:paymentId/refund
getBookingByIdGET /v2/hotel/:hotelId/booking/:bookingId
getBookingsGET /v2/hotel/:hotelId/booking
createBookingPOST /v2/hotel/:hotelId/booking
updateBookingByIdPATCH /v2/hotel/:hotelId/booking/:bookingId
checkInBookingByIdPOST /v2/hotel/:hotelId/booking/:bookingId/check-in
checkOutBookingByIdPOST /v2/hotel/:hotelId/booking/:bookingId/check-out
cancelBookingByIdPOST /v2/hotel/:hotelId/booking/:bookingId/cancel
getGuestsForBookingGET /v2/hotel/:hotelId/booking/:bookingId/guest
getBillsForBookingGET /v2/hotel/:hotelId/booking/:bookingId/bill
getBookingSetsGET /v2/hotel/:hotelId/booking-set
getBookingSetByIdGET /v2/hotel/:hotelId/booking-set/:bookingSetId
createBookingSetPOST /v2/hotel/:hotelId/booking-set
updateBookingSetPATCH /v2/hotel/:hotelId/booking-set/:bookingSetId
getExtraByIdGET /v2/hotel/:hotelId/extra/:extraId
getExtrasGET /v2/hotel/:hotelId/extra
getGuestByIdGET /v2/hotel/:hotelId/guest/:guestId
getGuestsGET /v2/hotel/:hotelId/guest
createGuestPOST /v2/hotel/:hotelId/guest
updateGuestPATCH /v2/hotel/:hotelId/guest/:guestId
getBillsForGuestGET /v2/hotel/:hotelId/guest/:guestId/bill
getRatePlanByIdGET /v2/hotel/:hotelId/rate-plan/:ratePlanId
getRatePlansGET /v2/hotel/:hotelId/rate-plan
getPriceForRatePlanGET /v2/hotel/:hotelId/rate-plan/:ratePlanId/price
updatePriceForRatePlanPUT /v2/hotel/:hotelId/rate-plan/:ratePlanId/price
getRateSetsGET /v2/hotel/:hotelId/rate-set
1.4.0

3 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago