UNPKG

glide-nodejs-sdk

Version:

Glide NodeJS SDK

42 lines (34 loc) 981 B
const handleApiErrors = require("../errors/handleApiErrors"); const validateSchema = require("../utils/validator.schema"); const { customerUpdateSchema } = require("../validators/customer.schema"); class Bank { constructor(request) { this.request = request; } getAll = async () => { try { const { data } = await this.request.get("/transfer/banks"); if (data && data.status) { return data.banks; } else { throw new Error("Unable to get bank list"); } } catch (error) { handleApiErrors(error); } }; stubMethod = async (customerId, payload) => { try { const updatePayload = await validateSchema({ schema: customerUpdateSchema, payload }); const { data } = await this.request.put(`/customer/${customerId}`, updatePayload); if (data && data.status) { return data.customer; } else { throw new Error("Unable to update customer profile"); } } catch (error) { handleApiErrors(error); } }; } module.exports = Bank;