@accounter/green-invoice-graphql
Version:
Graphql proxy for Green Invoice API
25 lines (20 loc) • 674 B
text/typescript
import { getMeshSDK, Sdk } from './mesh-artifacts/index.js';
export const init = async (
id: string,
secret: string,
): Promise<{ sdk: Sdk; authToken: string }> => {
const authParams = {
id,
secret,
};
const greenInvoiceToken = await fetch('https://api.greeninvoice.co.il/api/v1/account/token', {
method: 'POST',
body: JSON.stringify(authParams),
headers: { 'Content-Type': 'application/json' },
})
.then(res => res.json())
.then((res: { token: string }) => res.token);
const sdk = await getMeshSDK({ authToken: greenInvoiceToken });
return { sdk, authToken: greenInvoiceToken };
};
export * from './mesh-artifacts/index.js';