Skip to content

Commit

Permalink
style: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
UnderKoen committed Sep 6, 2023
1 parent a5dcfb6 commit 96b2822
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 27 deletions.
2 changes: 2 additions & 0 deletions .prettierignore
@@ -1,3 +1,5 @@
dist
lib
package-lock.json
CHANGELOG.md
README.md
4 changes: 2 additions & 2 deletions example/example.js
Expand Up @@ -13,9 +13,9 @@ moneybird.instance.setOptions({
if (invoice.data.id === "391346733960922236") {
console.log(invoice.data.payments);
await invoice.addPayment({
price: 1.60,
price: 1.6,
payment_date: "2023-09-06",
manual_payment_action: "balance_settlement"
manual_payment_action: "balance_settlement",
});
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/administration.ts
Expand Up @@ -56,7 +56,7 @@ export class Administration {
// company_name, attention, firstname, lastname, address1, address2, zipcode, city, country, email, phone, customer_id, tax_number, chamber_of_commerce, bank_account
query: string;
}
>
>,
): Promise<Contact[]> {
const contacts = await this.HTTP.GET<IContact[]>("contacts", {
params,
Expand All @@ -81,7 +81,7 @@ export class Administration {
// The date the contact was last updated
updated_after: string;
}>,
pagination: PaginatedOptions = {}
pagination: PaginatedOptions = {},
): Promise<Contact[]> {
const filterString = Object.entries(filter)
.map(([key, value]) => `${key}:${value}`)
Expand Down Expand Up @@ -133,11 +133,11 @@ export class Administration {
* @param contact The contact to create
*/
public async createContact(
contact: Partial<IContactCreate>
contact: Partial<IContactCreate>,
): Promise<Contact> {
if (!(contact.company_name || (contact.firstname && contact.lastname))) {
throw new Error(
"Either company_name or first_name and last_name must be set"
"Either company_name or first_name and last_name must be set",
);
}

Expand All @@ -155,7 +155,7 @@ export class Administration {
* Returns a list of all sales invoices in the administration
*/
public async salesInvoices(
params?: PaginatedOptions
params?: PaginatedOptions,
): Promise<SalesInvoice[]> {
const invoices = await this.HTTP.GET<ISalesInvoice[]>("sales_invoices", {
params,
Expand Down Expand Up @@ -199,7 +199,7 @@ export class Administration {
// Select invoices updated after the given time (exclusive). ISO 8601 formatted string. The time to compare with is in UTC timezone
updated_after: string;
}>,
pagination: PaginatedOptions = {}
pagination: PaginatedOptions = {},
): Promise<SalesInvoice[]> {
let filterParam = "";

Expand Down Expand Up @@ -244,7 +244,7 @@ export class Administration {
* @param invoice The invoice to create
*/
public async createSalesInvoice(
invoice: Partial<ISalesInvoiceCreate>
invoice: Partial<ISalesInvoiceCreate>,
): Promise<SalesInvoice> {
const data = await this.HTTP.POST<ISalesInvoice>("sales_invoices", {
sales_invoice: invoice,
Expand Down Expand Up @@ -291,7 +291,7 @@ export class Administration {
// Select taxes updated after the given time (exclusive). ISO 8601 formatted string. The time to compare with is in UTC timezone
updated_after: string;
}>,
pagination: PaginatedOptions = {}
pagination: PaginatedOptions = {},
): Promise<ITax[]> {
let filterParam = "";

Expand All @@ -318,7 +318,7 @@ export class Administration {
* Returns a list of all custom fields in the administration
*/
public async customFields(
params?: PaginatedOptions
params?: PaginatedOptions,
): Promise<ICustomField[]> {
return await this.HTTP.GET<ICustomField[]>("custom_fields", { params });
}
Expand All @@ -331,7 +331,7 @@ export class Administration {
* Returns a list of all ledger accounts in the administration
*/
public async ledgerAccounts(
params?: PaginatedOptions
params?: PaginatedOptions,
): Promise<ILedgerAccount[]> {
return await this.HTTP.GET<ILedgerAccount[]>("ledger_accounts", { params });
}
Expand Down
2 changes: 1 addition & 1 deletion src/common.ts
Expand Up @@ -276,7 +276,7 @@ export interface IPaymentCreate {
}

export type IManualPaymentAction =
"private_payment"
| "private_payment"
| "payment_without_proof"
| "cash_payment"
| "rounding_error"
Expand Down
4 changes: 2 additions & 2 deletions src/contact.ts
Expand Up @@ -12,15 +12,15 @@ export class Contact {
constructor(
moneybird: Moneybird,
administration: Administration,
data: IContact
data: IContact,
) {
this.moneybird = moneybird;
this.administration = administration;
this.id = data.id;
this.data = data;
this.HTTP = new HttpHandler(
this.administration.HTTP,
`contacts/${this.id}`
`contacts/${this.id}`,
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/httpHandler.ts
Expand Up @@ -23,15 +23,15 @@ export class HttpHandler implements HTTP {
public async POST<T>(
url: string,
data: unknown,
options: GaxiosOptions = {}
options: GaxiosOptions = {},
): Promise<T> {
return await this.parent.POST<T>(`${this.url}/${url}`, data, options);
}

public async PATCH<T>(
url: string,
data: unknown,
options: GaxiosOptions = {}
options: GaxiosOptions = {},
): Promise<T> {
return await this.parent.PATCH<T>(`${this.url}/${url}`, data, options);
}
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Expand Up @@ -8,5 +8,5 @@ export { MoneybirdOptions } from "./common";

export const instance: Moneybird = new Moneybird(
"https://moneybird.com/api/",
"v2"
"v2",
);
4 changes: 2 additions & 2 deletions src/moneybird.ts
Expand Up @@ -84,7 +84,7 @@ export class Moneybird implements HTTP {
public async POST<T>(
url: string,
data: unknown,
options: GaxiosOptions = {}
options: GaxiosOptions = {},
): Promise<T> {
debug("moneybird")(`POST ${url}`);

Expand All @@ -109,7 +109,7 @@ export class Moneybird implements HTTP {
public async PATCH<T>(
url: string,
data: unknown,
options: GaxiosOptions = {}
options: GaxiosOptions = {},
): Promise<T> {
debug("moneybird")(`PATCH ${url}`);

Expand Down
14 changes: 7 additions & 7 deletions src/salesInvoice.ts
@@ -1,7 +1,7 @@
import { HttpHandler } from "./httpHandler";
import { Moneybird } from "./moneybird";
import { Administration } from "./administration";
import {IPayment, IPaymentCreate, ISalesInvoice} from "./common";
import { IPayment, IPaymentCreate, ISalesInvoice } from "./common";

export class SalesInvoice {
private readonly moneybird: Moneybird;
Expand All @@ -13,15 +13,15 @@ export class SalesInvoice {
constructor(
moneybird: Moneybird,
administration: Administration,
data: ISalesInvoice
data: ISalesInvoice,
) {
this.moneybird = moneybird;
this.administration = administration;
this.id = data.id;
this.data = data;
this.HTTP = new HttpHandler(
this.administration.HTTP,
`sales_invoices/${this.id}`
`sales_invoices/${this.id}`,
);
}

Expand Down Expand Up @@ -63,14 +63,14 @@ export class SalesInvoice {
* Delete a payment from the sales invoice
* @param payment The payment to delete
*/
public async deletePayment(payment: IPayment): Promise<void>
public async deletePayment(payment: IPayment): Promise<void>;
/**
* Delete a payment from the sales invoice
* @param paymentId The ID of the payment to delete
*/
public async deletePayment(paymentId: string): Promise<void>
public async deletePayment(payment: IPayment | string): Promise<void>{
let id = (typeof payment === "string") ? payment : payment.id;
public async deletePayment(paymentId: string): Promise<void>;
public async deletePayment(payment: IPayment | string): Promise<void> {
const id = typeof payment === "string" ? payment : payment.id;
await this.HTTP.DELETE<void>(`payments/${id}`);
}
}

0 comments on commit 96b2822

Please sign in to comment.