UNPKG

tipi-services

Version:

Node.js library to access wrapping REST API of tipi backend services

61 lines (45 loc) 1.79 kB
const Service = require('../../../Service') const Endpoints = require('./Endpoints') class HostelsService extends Service { constructor (baseUrl) { super() this.endpoints = Endpoints(baseUrl) } async create (data) { return this.sendRequest({ endpoint: this.endpoints.create, body: data }) } async list (query) { return this.sendRequest({ endpoint: this.endpoints.list, query }) } async suggest (query) { return this.sendRequest({ endpoint: this.endpoints.suggest, query }) } async details (id, query) { return this.sendRequest({ endpoint: this.endpoints.details, params: { id }, query }) } async batchDetails (ids, asObject = false, withMissedItems = false) { return this.sendRequest({ endpoint: this.endpoints.batchDetails, query: { ids, asObject, withMissedItems } }) } async update (id, data) { return this.sendRequest({ endpoint: this.endpoints.update, params: { id }, body: data }) } async remove (id) { return this.sendRequest({ endpoint: this.endpoints.remove, params: { id } }) } async setGroup (id, data) { return this.sendRequest({ endpoint: this.endpoints.setGroup, params: { id }, body: data }) } async removeGroup (id) { return this.sendRequest({ endpoint: this.endpoints.removeGroup, params: { id } }) } async setLogo (id, data) { return this.sendRequest({ endpoint: this.endpoints.setLogo, params: { id }, formData: data }) } async findByUname (query) { return this.sendRequest({ endpoint: this.endpoints.findByUname, query }) } async batchFindByHostelworldId (data) { return this.sendRequest({ endpoint: this.endpoints.batchFindByHostelworldId, body: data }) } } module.exports = HostelsService