tipi-services
Version:
Node.js library to access wrapping REST API of tipi backend services
44 lines (33 loc) • 1.27 kB
JavaScript
const Service = require('../../../Service')
const Endpoints = require('./Endpoints')
class TodosService extends Service {
constructor (baseUrl) {
super()
this.endpoints = Endpoints(baseUrl)
}
async create (data) {
return this.sendRequest({ endpoint: this.endpoints.create, body: data })
}
async details (id, query) {
return this.sendRequest({ endpoint: this.endpoints.details, params: { id }, query })
}
async list (query) {
return this.sendRequest({ endpoint: this.endpoints.list, query })
}
async update (id, data) {
return this.sendRequest({ endpoint: this.endpoints.update, body: data, params: { id } })
}
async remove (id, data) {
return this.sendRequest({ endpoint: this.endpoints.remove, body: data, params: { id } })
}
async addImage (id, data) {
return this.sendRequest({ endpoint: this.endpoints.addImage, formData: data, params: { id } })
}
async removeImage (id, data) {
return this.sendRequest({ endpoint: this.endpoints.removeImage, body: data, params: { id } })
}
async setMainImage (id, data) {
return this.sendRequest({ endpoint: this.endpoints.setMainImage, body: data, params: { id } })
}
}
module.exports = TodosService