UNPKG

@basel_mn/qv-api-client

Version:

TypeScript/JavaScript client for QV API, providing easy access to invoices, payments, and Swish integration

38 lines (37 loc) 1.61 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ExtendApi = void 0; class ExtendApi { constructor(client) { this.client = client; } extendInvoice(extendData) { return __awaiter(this, void 0, void 0, function* () { try { const { id, hash } = extendData; if (!id || !hash) { throw new Error('Invoice ID and hash are required for extending invoice'); } const { data } = yield this.client.put(`/invoices/${id}/${hash}/extend`); return data; } catch (error) { const enhancedError = error; enhancedError.message = 'Failed to Extend invoice'; enhancedError.name = 'ExtendApiError'; throw enhancedError; } }); } } exports.ExtendApi = ExtendApi; ;