UNPKG

@basel_mn/qv-api-client

Version:

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

41 lines (40 loc) 1.75 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.ReturnApi = void 0; class ReturnApi { constructor(client) { this.client = client; } returnArticles(returnData) { return __awaiter(this, void 0, void 0, function* () { try { const { id, hash, articles } = returnData; if (!id || !hash) { throw new Error('Invoice ID and hash are required for returning articles'); } const { data } = yield this.client.put(`/invoices/${id}/${hash}/return`, { Articles: articles }); return data; } catch (error) { console.error('Error returning articles:', error); const enhancedError = error; enhancedError.message = 'Failed to return articles'; enhancedError.name = 'ReturnApiError'; throw enhancedError; } }); } } exports.ReturnApi = ReturnApi; ;