UNPKG

@accounter/green-invoice-graphql

Version:
24 lines (23 loc) 910 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const dotenv_1 = require("dotenv"); const index_js_1 = require("../index.js"); (0, dotenv_1.config)({ path: [`.env`, `../../.env`] }); const testRun = async () => { const id = process.env['GREEN_INVOICE_ID']; const secret = process.env['GREEN_INVOICE_SECRET']; const app = await (0, index_js_1.init)(id, secret); /* search drafts */ const data = await app.sdk.searchExpenseDrafts_query(); if (!data.searchExpenseDrafts) { throw new Error('no response data'); } if (!('page' in data.searchExpenseDrafts)) { throw new Error(`Got error response: ${data.searchExpenseDrafts.errorMessage ?? undefined}`); } console.log(`Successfully searched, found ${data.searchExpenseDrafts.items?.length ?? 0} expenses.`); }; testRun().catch(e => { console.error(e); process.exit(1); });