tipi-services
Version:
Node.js library to access wrapping REST API of tipi backend services
39 lines (30 loc) • 1.14 kB
JavaScript
const Service = require('../../../Service')
const Endpoints = require('./Endpoints')
class InvoicesService 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 details (id, query) {
return this.sendRequest({ endpoint: this.endpoints.details, params: { id }, query })
}
async pay (id, data) {
return this.sendRequest({ endpoint: this.endpoints.pay, params: { id }, body: data })
}
async void (id, data) {
return this.sendRequest({ endpoint: this.endpoints.void, params: { id }, body: data })
}
async tryAutoPay (id, data) {
return this.sendRequest({ endpoint: this.endpoints.tryAutoPay, params: { id }, body: data })
}
async tryCreateXeroInvoice (id, data) {
return this.sendRequest({ endpoint: this.endpoints.tryCreateXeroInvoice, params: { id }, body: data })
}
}
module.exports = InvoicesService