Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@elbstack/lexoffice-client-js
Advanced tools
An universal client for the Lexoffice API written in Typescript
Javascript client library for the lexoffice Public API.
fully typed
promise based
❌ non throwing
npm install @elbstack/lexoffice-client-js
or
yarn add @elbstack/lexoffice-client-js
You can find the official lexoffice API documentation here.
To get your API Key, you must already be a lexoffice user. Get it here.
import { Client } from '@elbstack/lexoffice-client-js';
const client = new Client(YOUR_LEXOFFICE_API_KEY);
All functions are promise based. These promises are formatted by the ts-results package, for extended error handling see Error handling.
const invoiceResult = await client.retrieveInvoice('caf4e0c3-c3e8-4a06-bcfe-346bc7190b2');
if (invoiceResult.ok) {
const invoice = invoiceResult.val;
} else {
console.error('An error occured');
}
const invoice = {
voucherDate: '2017-02-22T00:00:00.000+01:00',
address: {
name: 'Bike & Ride GmbH & Co. KG',
supplement: 'Gebäude 10',
street: 'Musterstraße 42',
city: 'Freiburg',
zip: '79112',
countryCode: 'DE',
},
lineItems: [
{
type: 'custom',
name: 'Energieriegel Testpaket',
quantity: 1,
unitName: 'Stück',
unitPrice: {
currency: 'EUR',
netAmount: 5,
taxRatePercentage: 0,
},
discountPercentage: 0,
},
{
type: 'text',
name: 'Strukturieren Sie Ihre Belege durch Text-Elemente.',
description: 'Das hilft beim Verständnis',
},
],
totalPrice: {
currency: 'EUR',
},
taxConditions: {
taxType: 'net',
},
shippingConditions: {
shippingDate: '2017-04-22T00:00:00.000+02:00',
shippingType: 'delivery',
},
title: 'Rechnung',
introduction: 'Ihre bestellten Positionen stellen wir Ihnen hiermit in Rechnung',
remark: 'Vielen Dank für Ihren Einkauf',
};
const createdInvoiceResult = await client.createInvoice(invoice, { finalized: true });
if (createdInvoiceResult.ok) {
const invoice = createdInvoiceResult.val;
} else {
console.error('An error occured');
}
let fs = require('fs');
let FormData = require('form-data');
let data = new FormData();
data.append('file', fs.createReadStream(__dirname + '/yourFolder/yourFile'));
data.append('type', 'voucher');
const uploadedFileResult = await client.uploadFile(data);
if (uploadedFileResult.ok) {
const invoice = uploadedFileResult.val;
} else {
console.error('An error occured');
}
As mentioned above, the returned promises are formatted by ts-results which is a typescript implementation of Rust's Result and Option objects. It brings compile-time error checking and optional values to typescript. All errors are instances of type RequestError. If you want to use the advantages of ts-results, all client responses should be processed similar to the following:
if (YOUR_RESULT.ok) {
const YOUR_VARIABLE = YOUR_RESULT.val;
// Work with your result
} else {
// Your request returned an error
const error = YOUR_RESULT.val;
console.log('error:', error);
// Further error checking is possible by
if (error instanceof RequestError) {
console.log('Hello instance of RequestError!');
if (error instanceof RequestNotFoundError) {
console.log('Wow, it looks like you have many instances!');
}
if (error instanceof RequestMethodNotAcceptableLegacyError) {
console.log('Seems, that you take care of your legacy!');
}
}
}
Regular errors | |||
---|---|---|---|
❌ Error code | Error type | ❌ Server error code | Error type |
400 | RequestBadRequestError | 500 | RequestInternalServerError |
401 | RequestUnauthorizedError | 503 | RequestServiceUnavailableError |
402 | RequestPaymentRequiredError | 504 | RequestGatewayTimeoutError |
403 | RequestForbiddenError | ||
404 | RequestNotFoundError | ||
405 | RequestMethodNotAllowedError | ||
406 | RequestMethodNotAcceptableError | ||
409 | RequestConflictError | ||
415 | RequestUnsupportedMediaTypeError | ||
429 | RequestTooManyRequestsError | ||
Legacy errors (used by the endpoints files, profiles and contacts) | |||
400 | RequestBadRequestLegacyError | 500 | RequestInternalServerLegacyError |
406 | RequestMethodNotAcceptableLegacyError |
createContact(contact: ContactCreatePerson | ContactCreateCompany): Promise<Result<ContactCreateResponse, RequestError>>
retrieveContact(id: string): Promise<Result<ContactRetrieveResponse, RequestError>>
updateContact(id: string, contact: ContactUpdatePerson | ContactUpdateCompany): Promise<Result<ContactUpdateResponse, RequestError>>
filterContact(filter?: OptionalFilters & Partial<PagingParameters>): Promise<Result<ContactFilterRetrieveResponse, RequestError>>
retrieveListOfCountries(): Promise<Result<Country[], RequestError>>
createCreditNote(creditNote: CreditNoteCreate, optionalFinalized?: OptionalFinalized): Promise<Result<CreditNoteCreateResponse, RequestError>>
retrieveCreditNote(id: string): Promise<Result<CreditNoteRetrieveResponse, RequestError>>
renderCreditNoteDocumentFileId(id: string): Promise<Result<DocumentFileId, RequestError>>
retrieveDownPaymentInvoice(id: string): Promise<Result<DownPaymentInvoice, RequestError>>
createEventSubscription(eventSubscription: EventSubscriptionCreate): Promise<Result<EventSubscription, RequestError>>
retrieveEventSubscription(id: string): Promise<Result<EventSubscription, RequestError>>
retrieveAllEventSubscriptions(): Promise<Result<EventSubscriptions, RequestError>>
deleteEventSubscription(id: string): Promise<Result<unknown, RequestError>>
uploadFile(data: FormData): Promise<Result<FileResponse, RequestError>>
downloadFile(documentFileId: string, optionalParameter?: RenderType): Promise<Result<unknown, RequestError>>
createInvoice(invoice: InvoiceCreate | XRechnung, optionalFinalized?: OptionalFinalized): Promise<Result<InvoiceCreateResponse, RequestError>>
retrieveInvoice(id: string): Promise<Result<InvoiceRetrieveResponse, RequestError>>
renderInvoiceDocumentFileId(id: string): Promise<Result<DocumentFileId, RequestError>>
createOrderConfirmation(orderConfirmation: OrderConfirmation): Promise<Result<OrderConfirmationResponse, RequestError>>
retrieveOrderConfirmation(id: string): Promise<Result<OrderConfirmationRetrieveResponse, RequestError>>
renderOrderConfirmationDocumentFileId(id: string): Promise<Result<DocumentFileId, RequestError>>
retrievePayment(id: string): Promise<Result<Payment, RequestError>>
retrievePaymentConditionList(): Promise<Result<PaymentCondition, RequestError>>
retrieveListPostingCategories(): Promise<Result<PostingCategory[], RequestError>>
retrieveProfile(): Promise<Result<Profile, RequestError>>
createQuotation(quotation: QuotationCreate, optionalFilter?: OptionalFinalized): Promise<Result<QuotationCreate, RequestError>>
retrieveQuotation(id: string): Promise<Result<Partial<Quotation>, RequestError>>
renderQuotationDocumentFileId(id: string): Promise<Result<DocumentFileId, RequestError>>
retrieveRecurringTemplate(id: string): Promise<Result<Partial<RecurringTemplate>, RequestError>>
retrieveAllRecurringTemplates(optionalFilter?: PagingParameters): Promise<Result<RecurringTemplates, RequestError>>
createVoucher(voucher: CreateVoucher): Promise<Result<VoucherCreateResponse, RequestError>>
retrieveVoucher(id: string): Promise<Result<Partial<Voucher>, RequestError>>
updateVoucher(id: string, voucher: CreateVoucher): Promise<Result<VoucherCreateResponse, RequestError>>
filterVoucher(voucherNumber: VoucherNumber): Promise<Result<Partial<Vouchers>, RequestError>>
uploadFileToVoucher(data: FormData, id: string): Promise<Result<FileResponse, RequestError>>
retrieveVoucherlist(filterParameter: FilterParameter): Promise<Result<Voucherlist, RequestError>>
For updating any type of vouchers where the "version" property is required, you first need to retrieve it and use the current "version" value to properly update.
Only possible for any type of vouchers that are not in "draft" mode.
The required id is not the id itself, it is the documentFileId, which can be required with the matching method and the vouchers id:
renderCreditNoteDocumentFileId(id);
renderInvoiceDocumentFileId(id);
renderOrderConfirmationDocumentFileId(id);
renderQuotationDocumentFileId(id);
elbstack is a software engineering & design company. We question, we advise, and we're excited to help your next project to succeed.
We offer software development and design as service. That's how we support you with the realisation of your projects - with individual employees or with a whole team. We love to work remotely, but we will work at your place, too.
We are more than a classic software agency, rather like a highly self organized company with our own start-up incubator. You can choose how much, for whom and what you want to work for. Acquire your own customers and projects, simply make your sideproject become reality or even a proper start-up.
Sounds like a scam?
FAQs
An universal client for the Lexoffice API written in Typescript
The npm package @elbstack/lexoffice-client-js receives a total of 285 weekly downloads. As such, @elbstack/lexoffice-client-js popularity was classified as not popular.
We found that @elbstack/lexoffice-client-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.