@kma/escapia-wrap
v1.7.0
Published
Wrapper for the Home Away Rental Agency API to easily connect web-based applications and properties.
Downloads
2
Readme
Escapia-Wrap
Escapia wrap is a publicly published SDK wrapper for the Escapia Rentals HSAPI v10 (https://hsapi.escapia.com/dragomanadapter/docs). This package expects the properties to already be syndicated with a local database and does not contain methods for retrieving properties.
Installation
Install the dependencies and devDependencies and start the server.
$ npm install @kma/escapia-wrap --save
Usage
The methods are implemented in that the response will feed the following method. For HSAPI object specifications, please see the HSAPI Swagger documentation. The intended workflow is authenticate > create a renter > generate quote > make reservation
Authenticating and obtaining temporary API Token
/**
* @param {string} clientID
* @param {string} clientSecret
* @param {string} pmcid
* @returns {boolean}
*/
let esc = new Escapia.Escapia()
let connected = await esc.authenticate(client, secret, pmcid)
Fetch Non-Availability Dates
/**
* @param {string} unitId
* @returns {Promise<Array<object>>}
*/
let esc = new Escapia.Escapia()
let connected = await esc.authenticate(client, secret, pmcid)
if(connected) {
let response = await esc.UnitAvailability("123456")
if(Array.isArray(response) && response.length > 0)
//Move to creating a renter
}
Create a Renter
/**
* @param {Guest} guest
* @param {boolean} isPrimaryGuest
* @param {boolean} isVIP
* @param {boolean} isWarn
* @param {string} notes
* @returns {Promis<object>}
*/
let guest = {
firstName: "Fake",
lastName: "Account",
addresses: [{
street1: "161 Good Morning St",
city: "Port St Joe",
state: "FL",
zip: "32456",
pmcid: pmcid,
country: "US"
}],
phones: [{
areaCode: "850",
number: "807.4038",
phoneContactTypeId: 0
}],
emails: [{
address: "[email protected]",
emailContactTypeId: 0
}]
}
let esc = new Escapia.Escapia()
let connected = await esc.authenticate(client, secret, pmcid)
if(connected) {
let response = await esc.UnitAvailability("123456")
if(Array.isArray(response) && response.length > 0) {
let renter = await esc.AddGuest(guest, isPrimaryGuest, isVIP, isWARN, "FakeAccount")
if(guest.hasOwnProperty('nativePMSID'))
//Move to generating a quote
}
}
Generate a Quote
/**
* @param {string} startDate in YYYY-MM-DD format
* @param {string} endDate in YYYY-MM-DD format
* @param {number} numAdults > 0
* @param {number} numKids >= 0
* @param {string} pmsID property id in NNNNNN format
* @param {string} reservationType accepted values are renter,owner,guestofowner,travelagent,ownerreferral,complimentary,group,longterm
* @returns {Promise<object>}
*/
let esc = new Escapia.Escapia()
let connected = await esc.authenticate(client, secret, pmcid)
if(connected) {
let response = await esc.UnitAvailability("123456")
if(Array.isArray(response) && response.length > 0) {
let renter = await esc.AddGuest(guest, isPrimaryGuest, isVIP, isWARN, "FakeAccount")
if(guest.hasOwnProperty('nativePMSID')) {
quote = await esc.GenerateQuote(checkInDate, checkOutDate, numAdults, numKids, "123456", "renter")
if(quote.hasOwnProperty('quoteSpecification'))
//Move to making a reservation
}
}
}
Making a Reservation
/**
* @param {Guest} guest
* @param {QuoteRequest} quote
* @returns {Promise<object>}
*/
let esc = new Escapia.Escapia()
let connected = await esc.authenticate(client, secret, pmcid)
if(connected) {
let response = await esc.UnitAvailability("123456")
if(Array.isArray(response) && response.length > 0) {
let renter = await esc.AddGuest(guest, isPrimaryGuest, isVIP, isWARN, "FakeAccount")
if(guest.hasOwnProperty('nativePMSID')) {
quote = await esc.GenerateQuote(checkInDate, checkOutDate, numAdults, numKids, "123456", "renter")
if(quote.hasOwnProperty('quoteSpecification')) {
let reservation = await esc.MakeReservation(renter, quote.quoteSpecification)
if(reservation.hasOwnProperty('reservationNumber'))
//Success move to implementing your own payment solution
}
}
}
}
Development
Escapia-wrap is in the beginning stages of development with endpoints being added as needed.
License
ISC License
Copyright (c) 2019, Kerigan Marketing Associates
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.