OrderResponse
This commit is contained in:
parent
cda9803c08
commit
48c2758665
1 changed files with 28 additions and 0 deletions
|
|
@ -382,3 +382,31 @@ exports.isOrder = item => {
|
||||||
|
|
||||||
return typeof obj.timestamp === 'number'
|
return typeof obj.timestamp === 'number'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} OrderResponse
|
||||||
|
* @prop {'err'|'invoice'} type
|
||||||
|
* @prop {string} response
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {*} o
|
||||||
|
* @returns {o is OrderResponse}
|
||||||
|
*/
|
||||||
|
exports.isOrderResponse = o => {
|
||||||
|
if (typeof o !== 'object') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o === null) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
const obj = /** @type {OrderResponse} */ (o)
|
||||||
|
|
||||||
|
if (typeof obj.response !== 'string') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj.type === 'err' || obj.type === 'invoice'
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue