tipi-services
Version:
Node.js library to access wrapping REST API of tipi backend services
153 lines (114 loc) • 5.04 kB
JavaScript
const Service = require('../../../Service')
const Endpoints = require('./Endpoints')
class ReservationsService extends Service {
constructor (baseUrl) {
super()
this.endpoints = Endpoints(baseUrl)
}
async createOrUpdate (data) {
return this.sendRequest({ endpoint: this.endpoints.createOrUpdate, body: data })
}
async batchCreateOrUpdate (data) {
return this.sendRequest({ endpoint: this.endpoints.batchCreateOrUpdate, body: data })
}
async details (id, extend) {
return this.sendRequest({ endpoint: this.endpoints.details, params: { id }, query: { extend } })
}
async batchDetails (ids, asObject = false, withMissedItems = false) {
return this.sendRequest({ endpoint: this.endpoints.batchDetails, query: { ids, asObject, withMissedItems } })
}
async downloadCheckInData (query) {
return this.sendRequest({ endpoint: this.endpoints.downloadCheckInData, query })
}
async batchGet (data) {
return this.sendRequest({ endpoint: this.endpoints.batchGet, body: data })
}
async claim (id, data) {
return this.sendRequest({ endpoint: this.endpoints.claim, body: data, params: { id } })
}
async checkIn (id, data) {
return this.sendRequest({ endpoint: this.endpoints.checkIn, body: data, params: { id } })
}
async checkOut (id, data) {
return this.sendRequest({ endpoint: this.endpoints.checkOut, body: data, params: { id } })
}
async acceptTerms (id, data) {
return this.sendRequest({ endpoint: this.endpoints.acceptTerms, body: data, params: { id } })
}
async update (id, data) {
return this.sendRequest({ endpoint: this.endpoints.update, body: data, params: { id } })
}
async create (data) {
return this.sendRequest({ endpoint: this.endpoints.create, body: data })
}
async extend (id, data) {
return this.sendRequest({ endpoint: this.endpoints.extend, body: data, params: { id } })
}
async acceptExtend (id, data) {
return this.sendRequest({ endpoint: this.endpoints.acceptExtend, body: data, params: { id } })
}
async declineExtend (id, data) {
return this.sendRequest({ endpoint: this.endpoints.declineExtend, body: data, params: { id } })
}
async list (query) {
return this.sendRequest({ endpoint: this.endpoints.list, query })
}
async listAll (query) {
return this.sendRequest({ endpoint: this.endpoints.listAll, query })
}
async getTodayCheckIns (query) {
return this.sendRequest({ endpoint: this.endpoints.getTodayCheckIns, query })
}
async getTodayCheckOuts (query) {
return this.sendRequest({ endpoint: this.endpoints.getTodayCheckOuts, query })
}
async initClaim (query) {
return this.sendRequest({ endpoint: this.endpoints.initClaim, query })
}
async sentiment (id, data) {
return this.sendRequest({ endpoint: this.endpoints.sentiment, body: data, params: { id } })
}
async notes (id, data) {
return this.sendRequest({ endpoint: this.endpoints.notes, body: data, params: { id } })
}
async removeSpace (id, data) {
return this.sendRequest({ endpoint: this.endpoints.removeSpace, body: data, params: { id } })
}
async setMainGuest (id, data) {
return this.sendRequest({ endpoint: this.endpoints.setMainGuest, body: data, params: { id } })
}
async replaceMainGuest (id, data) {
return this.sendRequest({ endpoint: this.endpoints.replaceMainGuest, body: data, params: { id } })
}
async addGuests (id, data) {
return this.sendRequest({ endpoint: this.endpoints.addGuests, body: data, params: { id } })
}
async removeGuests (id, data) {
return this.sendRequest({ endpoint: this.endpoints.removeGuests, body: data, params: { id } })
}
async latestReservations (guests, asObject = false) {
return this.sendRequest({ endpoint: this.endpoints.latestReservations, query : { guests, asObject } })
}
async setMainCustomer (id, data) {
return this.sendRequest({ endpoint: this.endpoints.setMainCustomer, params: { id }, body: data })
}
async setMainCustomerIdImage (id, data) {
return this.sendRequest({ endpoint: this.endpoints.setMainCustomerIdImage, params: { id }, formData: data })
}
async setCompanionIdImage (id, data) {
return this.sendRequest({ endpoint: this.endpoints.setCompanionIdImage, params: { id }, formData: data })
}
async setCompanions (id, data) {
return this.sendRequest({ endpoint: this.endpoints.setCompanions, params: { id }, body: data })
}
async acceptTerms (id, data) {
return this.sendRequest({ endpoint: this.endpoints.acceptTerms, params: { id }, body: data })
}
async lateCheckOut (id, data) {
return this.sendRequest({ endpoint: this.endpoints.lateCheckOut, params: { id }, body: data })
}
async batchExport (data) {
return this.sendRequest({ endpoint: this.endpoints.batchExport, body: data })
}
}
module.exports = ReservationsService