Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xero-node

Package Overview
Dependencies
Maintainers
4
Versions
176
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xero-node - npm Package Compare versions

Comparing version 3.0.0-alpha.6 to 3.0.0-alpha.7

docs_theme/assets/css/style.css

27

lib/AccountingAPI-types.d.ts

@@ -20,2 +20,5 @@ export interface AccountingResponse {

}
export interface AllocationsResponse extends AccountingResponse {
BankTransactions: Allocation[];
}
export interface InvoicesResponse extends AccountingResponse {

@@ -51,2 +54,5 @@ Invoices: Invoice[];

}
export interface CreditNotesResponse extends AccountingResponse {
CreditNotes: CreditNote[];
}
export interface BrandingThemesResponse extends AccountingResponse {

@@ -94,2 +100,17 @@ BrandingThemes: BrandingTheme[];

}
export interface LinkedTransactionsResponse {
LinkedTransactions: LinkedTransaction[];
}
export interface LinkedTransaction {
LinkedTransactionID?: string;
SourceTransactionID?: string;
SourceLineItemID?: string;
ContactID?: string;
TargetTransactionID?: string;
TargetLineItemID?: string;
Status?: string;
Type?: string;
UpdatedDateUTC?: string;
SourceTransactionTypeCode?: string;
}
export interface BankTransaction {

@@ -205,5 +226,5 @@ Contact?: Contact;

export interface Allocation {
AppliedAmount: string;
Date: string;
Invoice: Invoice;
AppliedAmount?: number;
Date?: string;
Invoice?: Invoice;
}

@@ -210,0 +231,0 @@ export interface CreditNote {

477

lib/AccountingAPIClient.d.ts
import { IXeroClientConfiguration, BaseAPIClient } from './internals/BaseAPIClient';
import { IOAuth1HttpClient, IOAuth1State } from './internals/OAuth1HttpClient';
import { AccountsResponse, BankTransaction, BankTransactionsResponse, InvoicesResponse, Invoice, ContactGroupsResponse, ContactGroup, CurrenciesResponse, Currency, EmployeesResponse, Employee, ContactsResponse, Contact, ReportsResponse, AttachmentsResponse, OrganisationResponse, UsersResponse, BrandingThemesResponse, BankTransfersResponse, BankTransfer, TrackingCategoriesResponse, TrackingCategory, TrackingOption, TaxRatesResponse, TaxRate, ExpenseClaimsResponse, ExpenseClaim, ItemsResponse, Item, InvoiceRemindersResponse, JournalsResponse, PaymentsResponse, Payment, PrepaymentsResponse, Allocation, OverpaymentsResponse } from './AccountingAPI-types';
import { AccountsResponse, BankTransactionsResponse, InvoicesResponse, CreditNotesResponse, AllocationsResponse, ContactGroupsResponse, CurrenciesResponse, EmployeesResponse, ContactsResponse, ReportsResponse, AttachmentsResponse, OrganisationResponse, UsersResponse, BrandingThemesResponse, BankTransfersResponse, TrackingCategoriesResponse, TaxRatesResponse, ExpenseClaimsResponse, ItemsResponse, InvoiceRemindersResponse, JournalsResponse, PaymentsResponse, PrepaymentsResponse, OverpaymentsResponse, LinkedTransactionsResponse, ReceiptsResponse, ManualJournalsResponse, RepeatingInvoicesResponse, PurchaseOrdersResponse } from './AccountingAPI-responses';
import { BankTransaction, BankTransfer, ContactGroup, Contact, CreditNote, Allocation, Currency, Employee, ExpenseClaim, Invoice, Item, LinkedTransaction, Payment, TaxRate, TrackingCategory, TrackingOption, Receipt, ManualJournal, PurchaseOrder } from './AccountingAPI-models';
export interface QueryArgs {

@@ -11,2 +12,5 @@ where?: string;

}
export interface UnitDecimalPlacesArgs {
unitdp?: number;
}
export interface HeaderArgs {

@@ -17,2 +21,3 @@ 'If-Modified-Since'?: string;

constructor(options: IXeroClientConfiguration, authState?: IOAuth1State, _oAuth1HttpClient?: IOAuth1HttpClient);
private generateAttachmentsEndpoint(path);
private generateHeader(args);

@@ -31,7 +36,7 @@ accounts: {

attachments: {
get: (args?: {
EntityID: string;
get: (args: {
entityId: string;
}) => Promise<AttachmentsResponse>;
downloadAttachment: (args?: {
entityID: string;
downloadAttachment: (args: {
entityId: string;
mimeType: string;

@@ -41,7 +46,8 @@ fileName: string;

}) => Promise<void>;
uploadAttachment: (args?: {
entityID: string;
uploadAttachment: (args: {
entityId: string;
mimeType: string;
fileName: string;
pathToUpload: string;
includeOnline?: boolean;
}) => Promise<AttachmentsResponse>;

@@ -53,6 +59,8 @@ };

BankTransactionID?: string;
} & QueryArgs & HeaderArgs) => Promise<BankTransactionsResponse>;
} & QueryArgs & PagingArgs & UnitDecimalPlacesArgs & HeaderArgs) => Promise<BankTransactionsResponse>;
create: (bankTransaction: BankTransaction | {
BankTransactions: BankTransaction[];
}) => Promise<BankTransactionsResponse>;
}, args?: {
summarizeErrors?: boolean;
} & UnitDecimalPlacesArgs) => Promise<BankTransactionsResponse>;
update: (bankTransaction: BankTransaction | {

@@ -62,9 +70,9 @@ BankTransactions: BankTransaction[];

summarizeErrors?: boolean;
}) => Promise<BankTransactionsResponse>;
} & UnitDecimalPlacesArgs) => Promise<BankTransactionsResponse>;
attachments: {
get: (args?: {
EntityID: string;
get: (args: {
entityId: string;
}) => Promise<AttachmentsResponse>;
downloadAttachment: (args?: {
entityID: string;
downloadAttachment: (args: {
entityId: string;
mimeType: string;

@@ -74,46 +82,26 @@ fileName: string;

}) => Promise<void>;
uploadAttachment: (args?: {
entityID: string;
uploadAttachment: (args: {
entityId: string;
mimeType: string;
fileName: string;
pathToUpload: string;
includeOnline?: boolean;
}) => Promise<AttachmentsResponse>;
};
};
invoices: {
bankTransfers: {
get: (args?: {
InvoiceID?: string;
InvoiceNumber?: string;
page?: number;
createdByMyApp?: boolean;
} & HeaderArgs & QueryArgs) => Promise<InvoicesResponse>;
savePDF: (args?: {
InvoiceID: string;
InvoiceNumber?: string;
savePath: string;
}) => Promise<void>;
create: (invoice: Invoice | {
Invoices: Invoice[];
BankTransferID?: string;
} & HeaderArgs & QueryArgs) => Promise<BankTransfersResponse>;
create: (bankTransfers: BankTransfer | {
BankTransfers: BankTransfer[];
}, args?: {
summarizeErrors?: boolean;
}) => Promise<InvoicesResponse>;
update: (invoices: Invoice | {
Invoices: Invoice[];
}, args?: {
InvoiceID?: string;
InvoiceNumber?: string;
where?: string;
summarizeErrors?: boolean;
}) => Promise<InvoicesResponse>;
onlineInvoice: {
get: (args?: {
InvoiceID: string;
}) => Promise<string>;
};
summarizeErrors: boolean;
}) => Promise<BankTransfersResponse>;
attachments: {
get: (args?: {
EntityID: string;
get: (args: {
entityId: string;
}) => Promise<AttachmentsResponse>;
downloadAttachment: (args?: {
entityID: string;
downloadAttachment: (args: {
entityId: string;
mimeType: string;

@@ -123,34 +111,16 @@ fileName: string;

}) => Promise<void>;
uploadAttachment: (args?: {
entityID: string;
uploadAttachment: (args: {
entityId: string;
mimeType: string;
fileName: string;
pathToUpload: string;
includeOnline?: boolean;
}) => Promise<AttachmentsResponse>;
};
};
invoiceReminders: {
get: () => Promise<InvoiceRemindersResponse>;
brandingThemes: {
get: (args?: {
BrandingThemeID?: string;
}) => Promise<BrandingThemesResponse>;
};
private generateAttachmentsEndpoint(path);
banktransactions: {
create: (bankTransactions: any) => Promise<any>;
attachments: {
get: (args?: {
EntityID: string;
}) => Promise<AttachmentsResponse>;
downloadAttachment: (args?: {
entityID: string;
mimeType: string;
fileName: string;
pathToSave: string;
}) => Promise<void>;
uploadAttachment: (args?: {
entityID: string;
mimeType: string;
fileName: string;
pathToUpload: string;
}) => Promise<AttachmentsResponse>;
};
};
contactgroups: {

@@ -186,3 +156,3 @@ get: (args?: {

IDs?: string;
} & HeaderArgs & QueryArgs) => Promise<ContactsResponse>;
} & HeaderArgs & PagingArgs & QueryArgs) => Promise<ContactsResponse>;
create: (body: Contact | {

@@ -205,7 +175,7 @@ Contacts: Contact[];

attachments: {
get: (args?: {
EntityID: string;
get: (args: {
entityId: string;
}) => Promise<AttachmentsResponse>;
downloadAttachment: (args?: {
entityID: string;
downloadAttachment: (args: {
entityId: string;
mimeType: string;

@@ -215,7 +185,8 @@ fileName: string;

}) => Promise<void>;
uploadAttachment: (args?: {
entityID: string;
uploadAttachment: (args: {
entityId: string;
mimeType: string;
fileName: string;
pathToUpload: string;
includeOnline?: boolean;
}) => Promise<AttachmentsResponse>;

@@ -225,8 +196,30 @@ };

creditNotes: {
get: (args?: {
CreditNoteID?: string;
} & QueryArgs & PagingArgs & UnitDecimalPlacesArgs & HeaderArgs) => Promise<CreditNotesResponse>;
savePDF: (args?: {
CreditNoteID: string;
savePath: string;
}) => Promise<void>;
create: (creditNote: CreditNote | {
CreditNotes: CreditNote[];
}, args?: {
summarizeErrors?: boolean;
} & UnitDecimalPlacesArgs) => Promise<CreditNotesResponse>;
update: (creditNote: CreditNote | {
CreditNotes: CreditNote[];
}, args?: {
summarizeErrors?: boolean;
} & UnitDecimalPlacesArgs) => Promise<CreditNotesResponse>;
allocations: {
create: (allocation: Allocation, args?: {
CreditNoteID?: string;
}) => Promise<AllocationsResponse>;
};
attachments: {
get: (args?: {
EntityID: string;
get: (args: {
entityId: string;
}) => Promise<AttachmentsResponse>;
downloadAttachment: (args?: {
entityID: string;
downloadAttachment: (args: {
entityId: string;
mimeType: string;

@@ -236,7 +229,8 @@ fileName: string;

}) => Promise<void>;
uploadAttachment: (args?: {
entityID: string;
uploadAttachment: (args: {
entityId: string;
mimeType: string;
fileName: string;
pathToUpload: string;
includeOnline?: boolean;
}) => Promise<AttachmentsResponse>;

@@ -276,2 +270,76 @@ };

};
invoiceReminders: {
get: () => Promise<InvoiceRemindersResponse>;
};
invoices: {
get: (args?: {
InvoiceID?: string;
InvoiceNumber?: string;
createdByMyApp?: boolean;
} & HeaderArgs & PagingArgs & UnitDecimalPlacesArgs & QueryArgs) => Promise<InvoicesResponse>;
savePDF: (args?: {
InvoiceID: string;
InvoiceNumber?: string;
savePath: string;
}) => Promise<void>;
create: (invoice: Invoice | {
Invoices: Invoice[];
}, args?: {
summarizeErrors?: boolean;
} & UnitDecimalPlacesArgs) => Promise<InvoicesResponse>;
update: (invoices: Invoice | {
Invoices: Invoice[];
}, args?: {
InvoiceID?: string;
InvoiceNumber?: string;
where?: string;
summarizeErrors?: boolean;
} & UnitDecimalPlacesArgs) => Promise<InvoicesResponse>;
onlineInvoice: {
get: (args?: {
InvoiceID: string;
}) => Promise<string>;
};
attachments: {
get: (args: {
entityId: string;
}) => Promise<AttachmentsResponse>;
downloadAttachment: (args: {
entityId: string;
mimeType: string;
fileName: string;
pathToSave: string;
}) => Promise<void>;
uploadAttachment: (args: {
entityId: string;
mimeType: string;
fileName: string;
pathToUpload: string;
includeOnline?: boolean;
}) => Promise<AttachmentsResponse>;
};
};
repeatingInvoices: {
get: (args?: {
RepeatingInvoiceID?: string;
} & QueryArgs) => Promise<RepeatingInvoicesResponse>;
attachments: {
get: (args: {
entityId: string;
}) => Promise<AttachmentsResponse>;
downloadAttachment: (args: {
entityId: string;
mimeType: string;
fileName: string;
pathToSave: string;
}) => Promise<void>;
uploadAttachment: (args: {
entityId: string;
mimeType: string;
fileName: string;
pathToUpload: string;
includeOnline?: boolean;
}) => Promise<AttachmentsResponse>;
};
};
items: {

@@ -297,41 +365,2 @@ get: (args?: {

};
trackingCategories: {
get: (args?: {
TrackingCategoryID?: string;
includeArchived?: boolean;
} & HeaderArgs & QueryArgs) => Promise<TrackingCategoriesResponse>;
create: (trackingCategory: TrackingCategory | {
TrackingCategorys: TrackingCategory[];
}) => Promise<TrackingCategoriesResponse>;
update: (trackingCategory: TrackingCategory | {
TrackingCategorys: TrackingCategory[];
}, args?: {
TrackingCategoryID: string;
}) => Promise<TrackingCategoriesResponse>;
delete: (args: {
TrackingCategoryID: string;
}) => Promise<any>;
trackingOptions: {
create: (trackingOption: TrackingOption | {
TrackingOptions: TrackingOption[];
}, args?: {
TrackingCategoryID: string;
}) => Promise<TrackingCategoriesResponse>;
update: (trackingOption: TrackingOption | {
TrackingOptions: TrackingOption[];
}, args?: {
TrackingCategoryID: string;
TrackingOptionID: string;
}) => Promise<TrackingCategoriesResponse>;
delete: (args: {
TrackingCategoryID: string;
TrackingOptionID: string;
}) => Promise<any>;
};
};
users: {
get: (args?: {
UserID?: string;
} & HeaderArgs & QueryArgs) => Promise<UsersResponse>;
};
journals: {

@@ -344,22 +373,42 @@ get: (args?: {

};
brandingThemes: {
linkedTransactions: {
get: (args?: {
BrandingThemeID?: string;
}) => Promise<BrandingThemesResponse>;
LinkedTransactionID?: string;
} & QueryArgs & UnitDecimalPlacesArgs & HeaderArgs) => Promise<LinkedTransactionsResponse>;
create: (linkedTransaction: LinkedTransaction | {
LinkedTransactions: LinkedTransaction[];
}, args?: {
summarizeErrors?: boolean;
} & UnitDecimalPlacesArgs) => Promise<LinkedTransactionsResponse>;
update: (linkedTransaction: LinkedTransaction | {
LinkedTransactions: LinkedTransaction[];
}, args?: {
LinkedTransactionID?: string;
summarizeErrors?: boolean;
} & UnitDecimalPlacesArgs) => Promise<LinkedTransactionsResponse>;
delete: (args?: {
LinkedTransactionID?: string;
}) => Promise<void>;
};
bankTransfers: {
manualJournals: {
get: (args?: {
BankTransferID?: string;
} & HeaderArgs & QueryArgs) => Promise<BankTransfersResponse>;
create: (bankTransfers: BankTransfer | {
BankTransfers: BankTransfer[];
ManualJournalID?: string;
} & QueryArgs & PagingArgs & HeaderArgs) => Promise<ManualJournalsResponse>;
create: (manualJournals?: ManualJournal | {
ManualJournals: ManualJournal[];
}, args?: {
summarizeErrors: boolean;
}) => Promise<BankTransfersResponse>;
summarizeErrors?: boolean;
}) => Promise<ManualJournalsResponse>;
update: (manualJournals?: ManualJournal | {
ManualJournals: ManualJournal[];
}, args?: {
ManualJournalID?: string;
summarizeErrors?: boolean;
}) => Promise<ManualJournalsResponse>;
attachments: {
get: (args?: {
EntityID: string;
get: (args: {
entityId: string;
}) => Promise<AttachmentsResponse>;
downloadAttachment: (args?: {
entityID: string;
downloadAttachment: (args: {
entityId: string;
mimeType: string;

@@ -369,29 +418,11 @@ fileName: string;

}) => Promise<void>;
uploadAttachment: (args?: {
entityID: string;
uploadAttachment: (args: {
entityId: string;
mimeType: string;
fileName: string;
pathToUpload: string;
includeOnline?: boolean;
}) => Promise<AttachmentsResponse>;
};
};
manualJournals: {
attachments: {
get: (args?: {
EntityID: string;
}) => Promise<AttachmentsResponse>;
downloadAttachment: (args?: {
entityID: string;
mimeType: string;
fileName: string;
pathToSave: string;
}) => Promise<void>;
uploadAttachment: (args?: {
entityID: string;
mimeType: string;
fileName: string;
pathToUpload: string;
}) => Promise<AttachmentsResponse>;
};
};
organisation: {

@@ -406,2 +437,12 @@ get: () => Promise<OrganisationResponse>;

};
overpayments: {
get: (args?: {
OverpaymentID?: string;
} & QueryArgs & PagingArgs & UnitDecimalPlacesArgs & HeaderArgs) => Promise<OverpaymentsResponse>;
allocations: {
create: (body: Allocation[], args: {
OverpaymentID: string;
}) => Promise<OverpaymentsResponse>;
};
};
payments: {

@@ -426,3 +467,3 @@ get: (args?: {

PrepaymentID: string;
} & QueryArgs & PagingArgs & HeaderArgs) => Promise<PrepaymentsResponse>;
} & QueryArgs & PagingArgs & UnitDecimalPlacesArgs & HeaderArgs) => Promise<PrepaymentsResponse>;
allocations: {

@@ -436,7 +477,7 @@ create: (allocations: Allocation | {

attachments: {
get: (args?: {
EntityID: string;
get: (args: {
entityId: string;
}) => Promise<AttachmentsResponse>;
downloadAttachment: (args?: {
entityID: string;
downloadAttachment: (args: {
entityId: string;
mimeType: string;

@@ -446,30 +487,52 @@ fileName: string;

}) => Promise<void>;
uploadAttachment: (args?: {
entityID: string;
uploadAttachment: (args: {
entityId: string;
mimeType: string;
fileName: string;
pathToUpload: string;
includeOnline?: boolean;
}) => Promise<AttachmentsResponse>;
};
};
overpayments: {
purchaseOrders: {
get: (args?: {
OverpaymentID?: string;
} & QueryArgs & PagingArgs & HeaderArgs) => Promise<OverpaymentsResponse>;
update: (body: Allocation[], args: {
OverpaymentID: string;
}) => Promise<OverpaymentsResponse>;
PurchaseOrderID?: string;
PurchasOrderNumber?: string;
Status?: string;
DateFrom?: string;
DateTo?: string;
} & QueryArgs & HeaderArgs) => Promise<PurchaseOrdersResponse>;
create: (purchaseOrders?: PurchaseOrder | {
PurchaseOrders: PurchaseOrder[];
}, args?: {
summarizeErrors: boolean;
}) => Promise<PurchaseOrdersResponse>;
update: (purchaseOrders?: PurchaseOrder | {
PurchaseOrders: PurchaseOrder[];
}, args?: {
PurchaseOrderID?: string;
summarizeErrors?: boolean;
}) => Promise<PurchaseOrdersResponse>;
};
reports: {
receipts: {
get: (args?: {
ReportID: string;
}) => Promise<ReportsResponse>;
};
repeatingInvoices: {
ReceiptID?: string;
} & QueryArgs & UnitDecimalPlacesArgs & HeaderArgs) => Promise<ReceiptsResponse>;
create: (receipts?: Receipt | {
Receipts: Receipt[];
}, args?: {
summarizeErrors?: boolean;
} & UnitDecimalPlacesArgs) => Promise<ReceiptsResponse>;
update: (receipts?: Receipt | {
Receipts: Receipt[];
}, args?: {
ReceiptID?: string;
summarizeErrors?: boolean;
} & UnitDecimalPlacesArgs) => Promise<ReceiptsResponse>;
attachments: {
get: (args?: {
EntityID: string;
get: (args: {
entityId: string;
}) => Promise<AttachmentsResponse>;
downloadAttachment: (args?: {
entityID: string;
downloadAttachment: (args: {
entityId: string;
mimeType: string;

@@ -479,10 +542,16 @@ fileName: string;

}) => Promise<void>;
uploadAttachment: (args?: {
entityID: string;
uploadAttachment: (args: {
entityId: string;
mimeType: string;
fileName: string;
pathToUpload: string;
includeOnline?: boolean;
}) => Promise<AttachmentsResponse>;
};
};
reports: {
get: (args?: {
ReportID: string;
}) => Promise<ReportsResponse>;
};
taxRates: {

@@ -495,7 +564,41 @@ get: (args?: {

};
purchaseorders: {
create: (body?: object, args?: {
summarizeErrors: boolean;
trackingCategories: {
get: (args?: {
TrackingCategoryID?: string;
includeArchived?: boolean;
} & HeaderArgs & QueryArgs) => Promise<TrackingCategoriesResponse>;
create: (trackingCategory: TrackingCategory | {
TrackingCategorys: TrackingCategory[];
}) => Promise<TrackingCategoriesResponse>;
update: (trackingCategory: TrackingCategory | {
TrackingCategorys: TrackingCategory[];
}, args?: {
TrackingCategoryID: string;
}) => Promise<TrackingCategoriesResponse>;
delete: (args: {
TrackingCategoryID: string;
}) => Promise<any>;
trackingOptions: {
create: (trackingOption: TrackingOption | {
TrackingOptions: TrackingOption[];
}, args?: {
TrackingCategoryID: string;
}) => Promise<TrackingCategoriesResponse>;
update: (trackingOption: TrackingOption | {
TrackingOptions: TrackingOption[];
}, args?: {
TrackingCategoryID: string;
TrackingOptionID: string;
}) => Promise<TrackingCategoriesResponse>;
delete: (args: {
TrackingCategoryID: string;
TrackingOptionID: string;
}) => Promise<any>;
};
};
users: {
get: (args?: {
UserID?: string;
} & HeaderArgs & QueryArgs) => Promise<UsersResponse>;
};
}

@@ -111,6 +111,6 @@ "use strict";

}); },
create: function (bankTransaction) { return __awaiter(_this, void 0, void 0, function () {
create: function (bankTransaction, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'banktransactions';
endpoint = 'banktransactions' + utils_1.generateQueryString(args, true);
return [2 /*return*/, this.oauth1Client.put(endpoint, bankTransaction)];

@@ -128,81 +128,34 @@ });

};
_this.invoices = {
_this.bankTransfers = {
get: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint, header;
var endpoint;
return __generator(this, function (_a) {
endpoint = 'invoices';
if (args && args.InvoiceID) {
endpoint = endpoint + '/' + args.InvoiceID;
delete args.InvoiceID;
endpoint = 'banktransfers';
if (args && args.BankTransferID) {
endpoint = endpoint + '/' + args.BankTransferID;
delete args.BankTransferID;
}
else if (args && args.InvoiceNumber) {
endpoint = endpoint + '/' + args.InvoiceNumber;
delete args.InvoiceNumber;
}
header = this.generateHeader(args);
endpoint += utils_1.generateQueryString(args);
return [2 /*return*/, this.oauth1Client.get(endpoint, header)];
return [2 /*return*/, this.oauth1Client.get(endpoint, this.generateHeader(args))];
});
}); },
savePDF: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint, writeStream;
return __generator(this, function (_a) {
endpoint = 'invoices';
if (args && args.InvoiceID) {
endpoint = endpoint + '/' + args.InvoiceID;
delete args.InvoiceID;
}
else if (args && args.InvoiceNumber) {
endpoint = endpoint + '/' + args.InvoiceNumber;
delete args.InvoiceNumber;
}
endpoint += utils_1.generateQueryString(args);
writeStream = fs.createWriteStream(args.savePath);
return [2 /*return*/, this.oauth1Client.writeUTF8ResponseToStream(endpoint, 'application/pdf', writeStream)];
});
}); },
create: function (invoice, args) { return __awaiter(_this, void 0, void 0, function () {
create: function (bankTransfers, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'invoices' + utils_1.generateQueryString(args, true);
return [2 /*return*/, this.oauth1Client.put(endpoint, invoice)];
});
}); },
update: function (invoices, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = "invoices";
if (args && args.InvoiceID) {
endpoint = endpoint + '/' + args.InvoiceID;
delete args.InvoiceID;
}
else if (args && args.InvoiceNumber) {
endpoint = endpoint + '/' + args.InvoiceNumber;
delete args.InvoiceNumber;
}
endpoint = 'banktransfers';
endpoint += utils_1.generateQueryString(args, true);
return [2 /*return*/, this.oauth1Client.post(endpoint, invoices)];
return [2 /*return*/, this.oauth1Client.put(endpoint, bankTransfers)];
});
}); },
onlineInvoice: {
get: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'invoices';
if (args && args.InvoiceID) {
endpoint = endpoint + '/' + args.InvoiceID;
delete args.InvoiceID;
}
endpoint += '/onlineinvoice';
return [2 /*return*/, this.oauth1Client.get(endpoint)];
});
}); }
},
attachments: _this.generateAttachmentsEndpoint('invoices')
attachments: _this.generateAttachmentsEndpoint('banktransfers')
};
_this.invoiceReminders = {
get: function () { return __awaiter(_this, void 0, void 0, function () {
_this.brandingThemes = {
get: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'invoicereminders/settings';
endpoint = 'brandingthemes';
if (args && args.BrandingThemeID) {
endpoint = endpoint + '/' + args.BrandingThemeID;
delete args.BrandingThemeID;
}
return [2 /*return*/, this.oauth1Client.get(endpoint)];

@@ -212,10 +165,2 @@ });

};
_this.banktransactions = {
create: function (bankTransactions) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, null]; // TODO
});
}); },
attachments: _this.generateAttachmentsEndpoint('banktransactions')
};
_this.contactgroups = {

@@ -335,2 +280,57 @@ get: function (args) { return __awaiter(_this, void 0, void 0, function () {

_this.creditNotes = {
get: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint, header;
return __generator(this, function (_a) {
endpoint = 'creditnotes';
if (args && args.CreditNoteID) {
endpoint = endpoint + '/' + args.CreditNoteID;
delete args.CreditNoteID; // remove from query string
}
header = this.generateHeader(args);
endpoint += utils_1.generateQueryString(args);
return [2 /*return*/, this.oauth1Client.get(endpoint, header)];
});
}); },
savePDF: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint, writeStream;
return __generator(this, function (_a) {
endpoint = 'creditnotes';
if (args && args.CreditNoteID) {
endpoint = endpoint + '/' + args.CreditNoteID;
delete args.CreditNoteID;
}
endpoint += utils_1.generateQueryString(args);
writeStream = fs.createWriteStream(args.savePath);
return [2 /*return*/, this.oauth1Client.writeUTF8ResponseToStream(endpoint, 'application/pdf', writeStream)];
});
}); },
create: function (creditNote, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'creditnotes' + utils_1.generateQueryString(args, true);
return [2 /*return*/, this.oauth1Client.put(endpoint, creditNote)];
});
}); },
update: function (creditNote, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'creditnotes' + utils_1.generateQueryString(args, true);
return [2 /*return*/, this.oauth1Client.post(endpoint, creditNote)];
});
}); },
allocations: {
create: function (allocation, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'creditnotes';
if (args && args.CreditNoteID) {
endpoint = endpoint + '/' + args.CreditNoteID;
delete args.CreditNoteID; // remove from query string
}
endpoint += '/allocations';
endpoint += utils_1.generateQueryString(args);
return [2 /*return*/, this.oauth1Client.put(endpoint, allocation)];
});
}); },
},
attachments: _this.generateAttachmentsEndpoint('creditnotes')

@@ -416,2 +416,101 @@ };

};
_this.invoiceReminders = {
get: function () { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'invoicereminders/settings';
return [2 /*return*/, this.oauth1Client.get(endpoint)];
});
}); }
};
_this.invoices = {
get: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint, header;
return __generator(this, function (_a) {
endpoint = 'invoices';
if (args && args.InvoiceID) {
endpoint = endpoint + '/' + args.InvoiceID;
delete args.InvoiceID;
}
else if (args && args.InvoiceNumber) {
endpoint = endpoint + '/' + args.InvoiceNumber;
delete args.InvoiceNumber;
}
header = this.generateHeader(args);
endpoint += utils_1.generateQueryString(args);
return [2 /*return*/, this.oauth1Client.get(endpoint, header)];
});
}); },
savePDF: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint, writeStream;
return __generator(this, function (_a) {
endpoint = 'invoices';
if (args && args.InvoiceID) {
endpoint = endpoint + '/' + args.InvoiceID;
delete args.InvoiceID;
}
else if (args && args.InvoiceNumber) {
endpoint = endpoint + '/' + args.InvoiceNumber;
delete args.InvoiceNumber;
}
endpoint += utils_1.generateQueryString(args);
writeStream = fs.createWriteStream(args.savePath);
return [2 /*return*/, this.oauth1Client.writeUTF8ResponseToStream(endpoint, 'application/pdf', writeStream)];
});
}); },
create: function (invoice, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'invoices' + utils_1.generateQueryString(args, true);
return [2 /*return*/, this.oauth1Client.put(endpoint, invoice)];
});
}); },
update: function (invoices, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = "invoices";
if (args && args.InvoiceID) {
endpoint = endpoint + '/' + args.InvoiceID;
delete args.InvoiceID;
}
else if (args && args.InvoiceNumber) {
endpoint = endpoint + '/' + args.InvoiceNumber;
delete args.InvoiceNumber;
}
endpoint += utils_1.generateQueryString(args, true);
return [2 /*return*/, this.oauth1Client.post(endpoint, invoices)];
});
}); },
onlineInvoice: {
get: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'invoices';
if (args && args.InvoiceID) {
endpoint = endpoint + '/' + args.InvoiceID;
delete args.InvoiceID;
}
endpoint += '/onlineinvoice';
return [2 /*return*/, this.oauth1Client.get(endpoint)];
});
}); }
},
attachments: _this.generateAttachmentsEndpoint('invoices')
};
_this.repeatingInvoices = {
get: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint, headers;
return __generator(this, function (_a) {
endpoint = 'repeatinginvoices';
if (args && args.RepeatingInvoiceID) {
endpoint = endpoint + '/' + args.RepeatingInvoiceID;
delete args.RepeatingInvoiceID;
}
headers = this.generateHeader(args);
endpoint += utils_1.generateQueryString(args);
return [2 /*return*/, this.oauth1Client.get(endpoint, headers)];
});
}); },
attachments: _this.generateAttachmentsEndpoint('repeatinginvoices')
};
_this.items = {

@@ -462,9 +561,10 @@ get: function (args) { return __awaiter(_this, void 0, void 0, function () {

};
_this.trackingCategories = {
_this.journals = {
get: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint, headers;
return __generator(this, function (_a) {
endpoint = 'trackingcategories';
if (args && args.TrackingCategoryID) {
endpoint = endpoint + '/' + args.TrackingCategoryID;
endpoint = 'journals';
if (args && args.Recordfilter) {
endpoint = endpoint + '/' + args.Recordfilter;
delete args.Recordfilter;
}

@@ -475,19 +575,35 @@ headers = this.generateHeader(args);

});
}); }
};
_this.linkedTransactions = {
get: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint, header;
return __generator(this, function (_a) {
endpoint = 'linkedtransactions';
if (args && args.LinkedTransactionID) {
endpoint = endpoint + '/' + args.LinkedTransactionID;
delete args.LinkedTransactionID; // remove from query string
}
header = this.generateHeader(args);
endpoint += utils_1.generateQueryString(args);
return [2 /*return*/, this.oauth1Client.get(endpoint, header)];
});
}); },
create: function (trackingCategory) { return __awaiter(_this, void 0, void 0, function () {
create: function (linkedTransaction, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'trackingcategories';
return [2 /*return*/, this.oauth1Client.put(endpoint, trackingCategory)];
endpoint = 'linkedtransactions' + utils_1.generateQueryString(args, true);
return [2 /*return*/, this.oauth1Client.put(endpoint, linkedTransaction)];
});
}); },
update: function (trackingCategory, args) { return __awaiter(_this, void 0, void 0, function () {
update: function (linkedTransaction, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'trackingcategories';
if (args && args.TrackingCategoryID) {
endpoint = endpoint + '/' + args.TrackingCategoryID;
delete args.TrackingCategoryID;
endpoint = 'linkedtransactions';
if (args && args.LinkedTransactionID) {
endpoint = endpoint + '/' + args.LinkedTransactionID;
delete args.LinkedTransactionID; // remove from query string
}
return [2 /*return*/, this.oauth1Client.post(endpoint, trackingCategory)];
endpoint += utils_1.generateQueryString(args, true);
return [2 /*return*/, this.oauth1Client.post(endpoint, linkedTransaction)];
});

@@ -498,106 +614,45 @@ }); },

return __generator(this, function (_a) {
endpoint = 'trackingcategories/' + args.TrackingCategoryID;
endpoint = 'linkedtransactions';
if (args && args.LinkedTransactionID) {
endpoint = endpoint + '/' + args.LinkedTransactionID;
delete args.LinkedTransactionID; // remove from query string
}
endpoint += utils_1.generateQueryString(args, false);
return [2 /*return*/, this.oauth1Client.delete(endpoint)];
});
}); },
trackingOptions: {
create: function (trackingOption, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'trackingcategories';
if (args && args.TrackingCategoryID) {
endpoint = endpoint + '/' + args.TrackingCategoryID + '/Options';
delete args.TrackingCategoryID;
}
return [2 /*return*/, this.oauth1Client.put(endpoint, trackingOption)];
});
}); },
update: function (trackingOption, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'trackingcategories';
if (args && args.TrackingCategoryID && args.TrackingOptionID) {
endpoint = endpoint + '/' + args.TrackingCategoryID + '/Options/' + args.TrackingOptionID;
delete args.TrackingCategoryID;
delete args.TrackingOptionID;
}
return [2 /*return*/, this.oauth1Client.post(endpoint, trackingOption)];
});
}); },
delete: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'trackingcategories/' + args.TrackingCategoryID + '/Options/' + args.TrackingOptionID;
return [2 /*return*/, this.oauth1Client.delete(endpoint)];
});
}); },
}
};
_this.users = {
_this.manualJournals = {
get: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint, headers;
var endpoint, header;
return __generator(this, function (_a) {
endpoint = 'users';
if (args && args.UserID) {
endpoint = endpoint + '/' + args.UserID;
delete args.UserID;
endpoint = 'manualjournals';
if (args && args.ManualJournalID) {
endpoint += '/' + args.ManualJournalID;
delete args.ManualJournalID;
}
headers = this.generateHeader(args);
header = this.generateHeader(args);
endpoint += utils_1.generateQueryString(args);
return [2 /*return*/, this.oauth1Client.get(endpoint, headers)];
return [2 /*return*/, this.oauth1Client.get(endpoint, header)];
});
}); }
};
_this.journals = {
get: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint, headers;
return __generator(this, function (_a) {
endpoint = 'journals';
if (args && args.Recordfilter) {
endpoint = endpoint + '/' + args.Recordfilter;
delete args.Recordfilter;
}
headers = this.generateHeader(args);
endpoint += utils_1.generateQueryString(args);
return [2 /*return*/, this.oauth1Client.get(endpoint, headers)];
});
}); }
};
_this.brandingThemes = {
get: function (args) { return __awaiter(_this, void 0, void 0, function () {
}); },
create: function (manualJournals, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'brandingthemes';
if (args && args.BrandingThemeID) {
endpoint = endpoint + '/' + args.BrandingThemeID;
delete args.BrandingThemeID;
}
return [2 /*return*/, this.oauth1Client.get(endpoint)];
endpoint = 'manualjournals' + utils_1.generateQueryString(args, true);
return [2 /*return*/, this.oauth1Client.put(endpoint, manualJournals)];
});
}); }
};
_this.bankTransfers = {
get: function (args) { return __awaiter(_this, void 0, void 0, function () {
}); },
update: function (manualJournals, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'banktransfers';
if (args && args.BankTransferID) {
endpoint = endpoint + '/' + args.BankTransferID;
delete args.BankTransferID;
endpoint = 'manualjournals';
if (args && args.ManualJournalID) {
endpoint += '/' + args.ManualJournalID;
delete args.ManualJournalID;
}
endpoint += utils_1.generateQueryString(args);
return [2 /*return*/, this.oauth1Client.get(endpoint, this.generateHeader(args))];
});
}); },
create: function (bankTransfers, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'banktransfers';
endpoint += utils_1.generateQueryString(args, true);
return [2 /*return*/, this.oauth1Client.put(endpoint, bankTransfers)];
return [2 /*return*/, this.oauth1Client.post(endpoint, manualJournals)];
});
}); },
attachments: _this.generateAttachmentsEndpoint('banktransfers')
};
_this.manualJournals = {
attachments: _this.generateAttachmentsEndpoint('manualjournals')

@@ -628,2 +683,25 @@ };

};
_this.overpayments = {
get: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'overpayments';
if (args && args.OverpaymentID) {
endpoint += '/' + args.OverpaymentID;
delete args.OverpaymentID;
}
endpoint += utils_1.generateQueryString(args);
return [2 /*return*/, this.oauth1Client.get(endpoint)];
});
}); },
allocations: {
create: function (body, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = "overpayments/" + args.OverpaymentID + "/allocations";
return [2 /*return*/, this.oauth1Client.put(endpoint, body)];
});
}); }
}
};
_this.payments = {

@@ -689,23 +767,76 @@ get: function (args) { return __awaiter(_this, void 0, void 0, function () {

};
_this.overpayments = {
_this.purchaseOrders = {
get: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
var endpoint, headers;
return __generator(this, function (_a) {
endpoint = 'overpayments';
if (args && args.OverpaymentID) {
endpoint += '/' + args.OverpaymentID;
delete args.OverpaymentID;
endpoint = 'purchaseorders';
if (args && args.PurchaseOrderID) {
endpoint = endpoint + '/' + args.PurchaseOrderID;
delete args.PurchaseOrderID;
}
else if (args && args.PurchasOrderNumber) {
endpoint = endpoint + '/' + args.PurchasOrderNumber;
delete args.PurchasOrderNumber;
}
headers = this.generateHeader(args);
endpoint += utils_1.generateQueryString(args);
return [2 /*return*/, this.oauth1Client.get(endpoint)];
return [2 /*return*/, this.oauth1Client.get(endpoint, headers)];
});
}); },
update: function (body, args) { return __awaiter(_this, void 0, void 0, function () {
create: function (purchaseOrders, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = "overpayments/" + args.OverpaymentID + "/allocations";
return [2 /*return*/, this.oauth1Client.post(endpoint, body)];
endpoint = 'purchaseorders';
endpoint += utils_1.generateQueryString(args, true);
return [2 /*return*/, this.oauth1Client.put(endpoint, purchaseOrders)];
});
}); },
update: function (purchaseOrders, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'purchaseorders';
if (args && args.PurchaseOrderID) {
endpoint = endpoint + '/' + args.PurchaseOrderID;
delete args.PurchaseOrderID;
}
endpoint += utils_1.generateQueryString(args, true);
return [2 /*return*/, this.oauth1Client.post(endpoint, purchaseOrders)];
});
}); }
};
_this.receipts = {
get: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint, header;
return __generator(this, function (_a) {
endpoint = 'receipts';
if (args && args.ReceiptID) {
endpoint += '/' + args.ReceiptID;
delete args.ReceiptID;
}
header = this.generateHeader(args);
endpoint += utils_1.generateQueryString(args);
return [2 /*return*/, this.oauth1Client.get(endpoint, header)];
});
}); },
create: function (receipts, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'receipts' + utils_1.generateQueryString(args, true);
return [2 /*return*/, this.oauth1Client.put(endpoint, receipts)];
});
}); },
update: function (receipts, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'receipts';
if (args && args.ReceiptID) {
endpoint += '/' + args.ReceiptID;
delete args.ReceiptID;
}
endpoint += utils_1.generateQueryString(args, true);
return [2 /*return*/, this.oauth1Client.post(endpoint, receipts)];
});
}); },
attachments: _this.generateAttachmentsEndpoint('receipts')
};
_this.reports = {

@@ -725,5 +856,2 @@ get: function (args) { return __awaiter(_this, void 0, void 0, function () {

};
_this.repeatingInvoices = {
attachments: _this.generateAttachmentsEndpoint('repeatinginvoices')
};
_this.taxRates = {

@@ -757,11 +885,86 @@ get: function (args) { return __awaiter(_this, void 0, void 0, function () {

};
_this.purchaseorders = {
create: function (body, args) { return __awaiter(_this, void 0, void 0, function () {
_this.trackingCategories = {
get: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint, headers;
return __generator(this, function (_a) {
endpoint = 'trackingcategories';
if (args && args.TrackingCategoryID) {
endpoint = endpoint + '/' + args.TrackingCategoryID;
}
headers = this.generateHeader(args);
endpoint += utils_1.generateQueryString(args);
return [2 /*return*/, this.oauth1Client.get(endpoint, headers)];
});
}); },
create: function (trackingCategory) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'purchaseorders';
endpoint += utils_1.generateQueryString(args, true);
// TODO: Add interface here
return [2 /*return*/, this.oauth1Client.post(endpoint, body)];
endpoint = 'trackingcategories';
return [2 /*return*/, this.oauth1Client.put(endpoint, trackingCategory)];
});
}); },
update: function (trackingCategory, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'trackingcategories';
if (args && args.TrackingCategoryID) {
endpoint = endpoint + '/' + args.TrackingCategoryID;
delete args.TrackingCategoryID;
}
return [2 /*return*/, this.oauth1Client.post(endpoint, trackingCategory)];
});
}); },
delete: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'trackingcategories/' + args.TrackingCategoryID;
return [2 /*return*/, this.oauth1Client.delete(endpoint)];
});
}); },
trackingOptions: {
create: function (trackingOption, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'trackingcategories';
if (args && args.TrackingCategoryID) {
endpoint = endpoint + '/' + args.TrackingCategoryID + '/Options';
delete args.TrackingCategoryID;
}
return [2 /*return*/, this.oauth1Client.put(endpoint, trackingOption)];
});
}); },
update: function (trackingOption, args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'trackingcategories';
if (args && args.TrackingCategoryID && args.TrackingOptionID) {
endpoint = endpoint + '/' + args.TrackingCategoryID + '/Options/' + args.TrackingOptionID;
delete args.TrackingCategoryID;
delete args.TrackingOptionID;
}
return [2 /*return*/, this.oauth1Client.post(endpoint, trackingOption)];
});
}); },
delete: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint;
return __generator(this, function (_a) {
endpoint = 'trackingcategories/' + args.TrackingCategoryID + '/Options/' + args.TrackingOptionID;
return [2 /*return*/, this.oauth1Client.delete(endpoint)];
});
}); },
}
};
_this.users = {
get: function (args) { return __awaiter(_this, void 0, void 0, function () {
var endpoint, headers;
return __generator(this, function (_a) {
endpoint = 'users';
if (args && args.UserID) {
endpoint = endpoint + '/' + args.UserID;
delete args.UserID;
}
headers = this.generateHeader(args);
endpoint += utils_1.generateQueryString(args);
return [2 /*return*/, this.oauth1Client.get(endpoint, headers)];
});
}); }

@@ -771,11 +974,2 @@ };

}
AccountingAPIClient.prototype.generateHeader = function (args) {
if (args && args['If-Modified-Since']) {
var toReturn = {
'If-Modified-Since': args['If-Modified-Since']
};
delete args['If-Modified-Since'];
return toReturn;
}
};
AccountingAPIClient.prototype.generateAttachmentsEndpoint = function (path) {

@@ -787,3 +981,3 @@ var _this = this;

return __generator(this, function (_a) {
endpoint = path + "/" + args.EntityID + "/attachments";
endpoint = path + "/" + args.entityId + "/attachments";
return [2 /*return*/, this.oauth1Client.get(endpoint)];

@@ -797,3 +991,3 @@ });

case 0:
endpoint = path + "/" + args.entityID + "/attachments/" + args.fileName;
endpoint = path + "/" + args.entityId + "/attachments/" + args.fileName;
writeStream = fs.createWriteStream(args.pathToSave);

@@ -810,3 +1004,3 @@ return [4 /*yield*/, this.oauth1Client.writeBinaryResponseToStream(endpoint, args.mimeType, writeStream)];

return __generator(this, function (_a) {
endpoint = path + "/" + args.entityID + "/attachments/" + args.fileName;
endpoint = path + "/" + args.entityId + "/attachments/" + args.fileName + utils_1.generateQueryString({ IncludeOnline: args.includeOnline });
readStream = fs.createReadStream(args.pathToUpload);

@@ -819,4 +1013,13 @@ fileSize = fs.statSync(args.pathToUpload).size;

};
AccountingAPIClient.prototype.generateHeader = function (args) {
if (args && args['If-Modified-Since']) {
var toReturn = {
'If-Modified-Since': args['If-Modified-Since']
};
delete args['If-Modified-Since'];
return toReturn;
}
};
return AccountingAPIClient;
}(BaseAPIClient_1.BaseAPIClient));
exports.AccountingAPIClient = AccountingAPIClient;

@@ -5,2 +5,3 @@ "use strict";

var privateKey_helpers_1 = require("./helpers/privateKey-helpers");
var version = require('../../../package.json').version;
describe('config-helper', function () {

@@ -19,3 +20,3 @@ describe('Private apps', function () {

accept: 'application/json',
userAgent: 'NodeJS-XeroAPIClient.RDGDV41TRLQZDFSDX96TKQ2KRJIW4C',
userAgent: "NodeJS-XeroAPIClient." + version + ".RDGDV41TRLQZDFSDX96TKQ2KRJIW4C",
consumerKey: 'RDGDV41TRLQZDFSDX96TKQ2KRJIW4C',

@@ -51,3 +52,3 @@ consumerSecret: privateKey_helpers_1.testCertString(),

accept: 'application/json',
userAgent: 'NodeJS-XeroAPIClient.RDGDV41TRLQZDFSDX96TKQ2KRJIW4C',
userAgent: "NodeJS-XeroAPIClient." + version + ".RDGDV41TRLQZDFSDX96TKQ2KRJIW4C",
consumerKey: 'RDGDV41TRLQZDFSDX96TKQ2KRJIW4C',

@@ -84,3 +85,3 @@ consumerSecret: privateKey_helpers_1.testCertString(),

accept: 'application/json',
userAgent: 'NodeJS-XeroAPIClient.RDGDV41TRLQZDFSDX96TKQ2KRJIW4C',
userAgent: "NodeJS-XeroAPIClient." + version + ".RDGDV41TRLQZDFSDX96TKQ2KRJIW4C",
consumerKey: 'RDGDV41TRLQZDFSDX96TKQ2KRJIW4C',

@@ -113,4 +114,4 @@ consumerSecret: 'DJ3CMGDB0DIIA9DNEEJMRLZG0BWE7Y',

expect(retrievedState).toEqual({
userAgent: "NodeJS-XeroAPIClient." + version + ".RDGDV41TRLQZDFSDX96TKQ2KRJIW4C",
accept: 'application/json',
userAgent: 'NodeJS-XeroAPIClient.RDGDV41TRLQZDFSDX96TKQ2KRJIW4C',
consumerKey: 'RDGDV41TRLQZDFSDX96TKQ2KRJIW4C',

@@ -143,3 +144,3 @@ consumerSecret: privateKey_helpers_1.testCertString(),

accept: 'application/json',
userAgent: 'NodeJS-XeroAPIClient.RDGDV41TRLQZDFSDX96TKQ2KRJIW4C',
userAgent: "NodeJS-XeroAPIClient." + version + ".RDGDV41TRLQZDFSDX96TKQ2KRJIW4C",
consumerKey: 'RDGDV41TRLQZDFSDX96TKQ2KRJIW4C',

@@ -177,3 +178,3 @@ consumerSecret: privateKey_helpers_1.testCertString(),

accept: 'application/json',
userAgent: 'NodeJS-XeroAPIClient.RDGDV41TRLQZDFSDX96TKQ2KRJIW4C',
userAgent: "NodeJS-XeroAPIClient." + version + ".RDGDV41TRLQZDFSDX96TKQ2KRJIW4C",
consumerKey: 'RDGDV41TRLQZDFSDX96TKQ2KRJIW4C',

@@ -205,3 +206,3 @@ consumerSecret: privateKey_helpers_1.testCertString(),

accept: 'application/json',
userAgent: 'NodeJS-XeroAPIClient.RDGDV41TRLQZDFSDX96TKQ2KRJIW4C',
userAgent: "NodeJS-XeroAPIClient." + version + ".RDGDV41TRLQZDFSDX96TKQ2KRJIW4C",
consumerKey: 'RDGDV41TRLQZDFSDX96TKQ2KRJIW4C',

@@ -208,0 +209,0 @@ consumerSecret: privateKey_helpers_1.testCertString(),

@@ -36,2 +36,8 @@ "use strict";

});
it('omits param whose value is undefined', function () {
expect(utils_1.generateQueryString({ abc: undefined })).toEqual('');
});
it('omits param whose value is undefined, but keeps other params', function () {
expect(utils_1.generateQueryString({ page: 5, abc: undefined })).toEqual('?page=5');
});
it('handles multiple params', function () {

@@ -38,0 +44,0 @@ expect(utils_1.generateQueryString({ page: 5, where: 'Type=="ACCREC"' })).toEqual('?page=5&where=Type%3D%3D%22ACCREC%22');

@@ -6,3 +6,3 @@ /// <reference types="node" />

import * as fs from 'fs';
import { AttachmentsResponse } from '../AccountingAPI-types';
import { AttachmentsResponse } from '../AccountingAPI-responses';
/**

@@ -9,0 +9,0 @@ * TODO: Add support for the following keys:

@@ -6,2 +6,3 @@ "use strict";

var utils_1 = require("./utils");
var version = require('../../package.json').version;
function mapState(xeroConfig) {

@@ -45,3 +46,3 @@ var cert = xeroConfig.privateKeyPath ? utils_1.getStringFromFile(xeroConfig.privateKeyPath) : null; // TODO don't read twice

accept: 'application/json',
userAgent: 'NodeJS-XeroAPIClient.' + xeroConfig.consumerKey,
userAgent: 'NodeJS-XeroAPIClient.' + version + '.' + xeroConfig.consumerKey,
consumerKey: xeroConfig.consumerKey,

@@ -48,0 +49,0 @@ consumerSecret: xeroConfig.consumerSecret,

@@ -8,3 +8,3 @@ /// <reference types="node" />

import * as http from 'http';
import { AttachmentsResponse } from '../AccountingAPI-types';
import { AttachmentsResponse } from '../AccountingAPI-responses';
export interface IToken {

@@ -11,0 +11,0 @@ oauth_token: string;

@@ -24,9 +24,15 @@ "use strict";

if (addSummarizeErrorsParam === void 0) { addSummarizeErrorsParam = false; }
args = __assign({}, args);
if (addSummarizeErrorsParam && args.summarizeErrors == undefined) {
args.summarizeErrors = false;
var argsToUse = __assign({}, args);
if (addSummarizeErrorsParam && argsToUse.summarizeErrors == undefined) {
argsToUse.summarizeErrors = false;
}
if (args && Object.keys(args).length > 0) {
return '?' + querystring.stringify(args);
for (var _i = 0, _a = Object.keys(argsToUse); _i < _a.length; _i++) {
var key = _a[_i];
if (argsToUse[key] == undefined) {
delete argsToUse[key];
}
}
if (argsToUse && Object.keys(argsToUse).length > 0) {
return '?' + querystring.stringify(argsToUse);
}
else {

@@ -33,0 +39,0 @@ return '';

{
"name": "xero-node",
"version": "3.0.0-alpha.6",
"version": "3.0.0-alpha.7",
"description": "NodeJS Client for the Xero API, supporting Public, Private and Partner Apps",

@@ -9,4 +9,5 @@ "main": "lib/index.js",

"build-watch": "tsc --watch",
"build-docs": "typedoc --external-aliases internalapi --options ./typedoc.js ./src",
"lint": "tslint ./src/**/*.ts",
"prepublishOnly": "npm run build && npm run test",
"prepublishOnly": "npm run build",
"test-watch": "tsc --noEmit && jest --config ./jestconfig.js --watch",

@@ -17,3 +18,2 @@ "test": "tsc --noEmit && jest --config ./jestconfig.js",

"scratch": "ts-node ./src/scratch.ts",
"typedoc": "typedoc --mode file --external-aliases internalapi --exclude **/*_tests__/** --includeDeclarations --excludeExternals --out docs/ src/",
"create-key": "node ./.circleci/create_private_key.js"

@@ -43,3 +43,3 @@ },

"tslint": "^5.9.1",
"typedoc": "^0.11.0",
"typedoc": "^0.11.1",
"typedoc-plugin-internal-external": "^1.0.10",

@@ -46,0 +46,0 @@ "typescript": "^2.7.1"

[![npm version](https://badge.fury.io/js/xero-node.svg)](https://badge.fury.io/js/xero-node)
[![CircleCI](https://circleci.com/gh/XeroAPI/xero-node/tree/v3.svg?style=svg)](https://circleci.com/gh/XeroAPI/xero-node/tree/v3)
# node-xero
# xero-node
NodeJS Client for the [Xero API](http://developer.xero.com).
NodeJS Client for the [Xero API](http://developer.xero.com). Works with ES5, ES6+ and TypeScript.

@@ -14,2 +14,5 @@ Supports all application types:

Version 3 has been rebuilt fron the ground-up using TypeScript, to make it
more maintainable and to take advantage of modern JavaScript features.
<!-- [API Reference](https://xeroapi.github.io/xero-node/). -->

@@ -21,32 +24,2 @@

- all [accounting endpoints](https://developer.xero.com/documentation/api/api-overview)
- [ ] attachments
- [ ] accounts
- [ ] bankstatements
- [ ] banktransactions
- [ ] bank-transfers
- [ ] branding-themes
- [ ] contacts
- [ ] contactgroups
- [ ] credit-notes
- [ ] currencies
- [ ] employees
- [ ] expense-claims
- [ ] invoices
- [ ] invoice-reminders
- [ ] items
- [ ] journals
- [ ] linked-transactions
- [ ] manual-journals
- [ ] organisation
- [ ] overpayments
- [ ] payments
- [ ] prepayments
- [ ] purchase-orders
- [ ] receipts
- [ ] repeating-invoices
- [ ] reports
- [ ] tax-rates
- [ ] tracking-categories
- [ ] users
- [ ] types
- generic methods (`get`, `put`, `post`, `delete`) for calling any unsupported endpoints

@@ -60,29 +33,101 @@

### Configuration
# Usage Example for Private Apps
Sample configuration files for various application types are in the [integration test directory](src/__integration_tests__).
Create a `config.json` file:
| Parameter | Description | Mandatory | Default |
|----------------------|------------------------------------------------------------------------------------------|-----------|---------|
| consumerKey | The consumer key that is required with all calls to the Xero API | True | - |
| consumerSecret | The secret key from the developer portal that is required to authenticate your API calls | True | - |
| callbackBaseUrl | The callback that Xero should invoke when the authorization is successful | False | null |
| privateKeyPath | The filesystem path to your privatekey.pem file to sign the API calls | False | null |
| redirectOnError | Whether Xero Auth should redirect to your app in the event the user clicks 'Cancel' | False | true |
```json
{
"appType": "private",
"consumerKey": "your_consumer_key",
"consumerSecret": "your_consumer_secret",
"callbackUrl": null,
"privateKeyPath": "C:\\keys\\your_private_key.pem"
}
```
# Usage
Then add the following JavaScript (example works in NodeJS version 8 and above):
```javascript
const XeroClient = require('xero-node').AccountingAPIClient;
const config = require('/some/path/to/config.json');
const config = require('./config.json');
const xeroClient = new XeroClient(config);
(async () => {
//Print a count of invoices
let invoices = xeroClient.invoices.get()
console.log("Number of Invoices: " + invoices.length);
// You can initialise Private apps directly from your configuration
let xero = new XeroClient(config);
const result = await xero.invoices.get();
console.log('Number of invoices:', result.Invoices.length);
})();
```
### Examples
# Usage Example for Public and Partner Apps
Create a `config.json` file:
```json
{
"appType": "public",
"consumerKey": "your_consumer_key",
"consumerSecret": "your_consumer_secret",
"callbackUrl": null,
"privateKeyPath": "C:\\keys\\your_private_key.pem"
}
```
Then add the following JavaScript (example works in NodeJS version 8 and above):
```javascript
const XeroClient = require('xero-node').AccountingAPIClient;
const config = require('./config.json');
(async () => {
let xero = new XeroClient(config);
// Create request token and get an authorisation URL
const requestToken = await xero.oauth1Client.getRequestToken();
console.log('Received Request Token:', requestToken);
authUrl = xero.oauth1Client.buildAuthoriseUrl(requestToken);
console.log('Authorisation URL:', authUrl);
// Send the user to the Authorisation URL to authorise the connection
// Once the user has authorised your app, swap Request token for Access token
const oauth_verifier = 123456;
const savedRequestToken = {
oauth_token: 'aaa',
oauth_token_secret: 'bbb'
};
const accessToken = await xero.oauth1Client.swapRequestTokenforAccessToken(savedRequestToken, oauth_verifier);
console.log('Received Access Token:', accessToken);
// You should now store the access token securely for the user.
// You can make API calls straight away
const result = await xero.invoices.get();
console.log('Number of invoices:', result.Invoices.length);
// When making future calls, you can initialise the Xero client direectly with the stored access token:
const storedAccessToken = {
oauth_token: 'aaa',
oauth_token_secret: 'bbb',
oauth_session_handle: 'ccc',
oauth_expires_at: '2018-01-01T01:02:03'
};
const xero2 = new XeroClient(config, storedAccessToken);
const invoices = await xero2.invoices.get();
console.log('Number of invoices:', invoices.Invoices.length);
})();
```
### Further Examples
- [Integration tests](src/__integration_tests__)

@@ -89,0 +134,0 @@ - [Sample app](https://github.com/XeroAPI/xero-node-sample-app)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc