@magic.batua/recharge
Version:
The Recharge module manages all the mobile prepaid, datacard and DTH recharge functionalities of the Magic Batua platform.
29 lines (26 loc) • 956 B
text/typescript
/**
* @module RechargeError
* @overview Defines methods that parse Rocket in Pocket response and look for errors.
*
* @author Animesh Mishra <hello@animesh.ltd>
* @copyright © Animesh Ltd. All Rights Reserved.
*/
import { ExternalError } from "@magic.batua/error"
/** @exports RechargeError */
export var description = "Defines method that parse Rocket in Pocket response and look for errors."
/**
* Checks whether the given Rocket in Pocket API `response` has any errors. If not, returns
* `null`, otherwise returns an `ExternalError` describing the failure.
*
* @param {any} response Response sent by Rocket in Pocket API
*
* @returns {ExternalError | null}
*/
export function Check(response: any): ExternalError | null {
if(response.message) {
return new ExternalError(response.message, "Rocket in Pocket", "RIP error code: " + response.errorCode)
}
else {
return null
}
}