tipi-services
Version:
Node.js library to access wrapping REST API of tipi backend services
93 lines (69 loc) • 3.03 kB
JavaScript
const Service = require('../../../Service')
const Endpoints = require('./Endpoints')
class LocksService extends Service {
constructor (baseUrl) {
super()
this.endpoints = Endpoints(baseUrl)
}
async create (data) {
return this.sendRequest({ endpoint: this.endpoints.create, body: data })
}
async update (id, data) {
return this.sendRequest({ endpoint: this.endpoints.update, params: { id }, body: data })
}
async details (id, extend, join) {
return this.sendRequest({ endpoint: this.endpoints.details, params: { id }, query: { extend, join } })
}
async batchFind (data) {
return this.sendRequest({ endpoint: this.endpoints.batchFind, body: data })
}
async list (query) {
return this.sendRequest({ endpoint: this.endpoints.list, query })
}
async remove (id, data) {
return this.sendRequest({ endpoint: this.endpoints.remove, params: { id }, body: data })
}
async updateAdminPin (id, data) {
return this.sendRequest({ endpoint: this.endpoints.updateAdminPin, params: { id }, body: data })
}
async updateBattery (mac, data) {
return this.sendRequest({ endpoint: this.endpoints.updateBattery, params: { mac }, body: data })
}
async updateTimestamp (mac, data) {
return this.sendRequest({ endpoint: this.endpoints.updateTimestamp, params: { mac }, body: data })
}
async setBroken(mac, data) {
return this.sendRequest({ endpoint: this.endpoints.setBroken, params: { mac }, body: data })
}
async getLockKeyChain (id, data) {
return this.sendRequest({ endpoint: this.endpoints.getLockKeyChain, params: { id }, body: data })
}
async upgradeCheck (id, data) {
return this.sendRequest({ endpoint: this.endpoints.upgradeCheck, params: { id }, body: data })
}
async upgradeSuccess (id, data) {
return this.sendRequest({ endpoint: this.endpoints.upgradeSuccess, params: { id }, body: data })
}
async upgradeRecheck (id, data) {
return this.sendRequest({ endpoint: this.endpoints.upgradeRecheck, params: { id }, body: data })
}
async disconnectFromDoor (id, data) {
return this.sendRequest({ endpoint: this.endpoints.disconnectFromDoor, params: { id }, body: data })
}
async connectToDoor (id, data) {
return this.sendRequest({ endpoint: this.endpoints.connectToDoor, params: { id }, body: data })
}
async updateStatus (mac, data) {
return this.sendRequest({ endpoint: this.endpoints.updateStatus, params: { mac }, body: data })
}
async unlock (mac, data) {
return this.sendRequest({ endpoint: this.endpoints.unlock, params: { mac }, body: data })
}
async setPassageMode (id, data) {
return this.sendRequest({ endpoint: this.endpoints.setPassageMode, params: { id }, body: data })
}
async clearPassageMode (id, data) {
return this.sendRequest({ endpoint: this.endpoints.clearPassageMode, params: { id }, body: data })
}
}
module.exports = LocksService