diff --git a/packages/nodes-base/credentials/invoiceNinjaServerApi.credentials.ts b/packages/nodes-base/credentials/InvoiceNinjaApi.credentials.ts similarity index 63% rename from packages/nodes-base/credentials/invoiceNinjaServerApi.credentials.ts rename to packages/nodes-base/credentials/InvoiceNinjaApi.credentials.ts index 906b638921..d79c23859e 100644 --- a/packages/nodes-base/credentials/invoiceNinjaServerApi.credentials.ts +++ b/packages/nodes-base/credentials/InvoiceNinjaApi.credentials.ts @@ -3,15 +3,15 @@ import { NodePropertyTypes, } from 'n8n-workflow'; -export class InvoiceNinjaServerApi implements ICredentialType { - name = 'invoiceNinjaServerApi'; +export class InvoiceNinjaApi implements ICredentialType { + name = 'invoiceNinjaApi'; displayName = 'Invoice Ninja API'; properties = [ { - displayName: 'Domain', - name: 'domain', + displayName: 'URL', + name: 'url', type: 'string' as NodePropertyTypes, - default: '', + default: 'https://app.invoiceninja.com', }, { displayName: 'API Token', diff --git a/packages/nodes-base/credentials/InvoiceNinjaCloudApi.credentials.ts b/packages/nodes-base/credentials/InvoiceNinjaCloudApi.credentials.ts deleted file mode 100644 index f9ecdad0e4..0000000000 --- a/packages/nodes-base/credentials/InvoiceNinjaCloudApi.credentials.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { - ICredentialType, - NodePropertyTypes, -} from 'n8n-workflow'; - -export class InvoiceNinjaCloudApi implements ICredentialType { - name = 'invoiceNinjaCloudApi'; - displayName = 'Invoice Ninja API'; - properties = [ - { - displayName: 'API Token', - name: 'apiToken', - type: 'string' as NodePropertyTypes, - default: '', - }, - ]; -} diff --git a/packages/nodes-base/nodes/InvoiceNinja/ClientDescription.ts b/packages/nodes-base/nodes/InvoiceNinja/ClientDescription.ts index e10c751183..4a9a467d8d 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/ClientDescription.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/ClientDescription.ts @@ -18,6 +18,11 @@ export const clientOperations = [ value: 'create', description: 'Create a new client', }, + { + name: 'Delete', + value: 'delete', + description: 'Delete a client', + }, { name: 'Get', value: 'get', @@ -28,11 +33,6 @@ export const clientOperations = [ value: 'getAll', description: 'Get data of all clients', }, - { - name: 'Delete', - value: 'delete', - description: 'Delete a client', - } ], default: 'create', description: 'The operation to perform.', diff --git a/packages/nodes-base/nodes/InvoiceNinja/ClientInterface.ts b/packages/nodes-base/nodes/InvoiceNinja/ClientInterface.ts index 998ad2138a..0590068e9a 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/ClientInterface.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/ClientInterface.ts @@ -8,7 +8,7 @@ export interface IContact { } export interface IClient { - contacts?: IContact[], + contacts?: IContact[]; name?: string; address1?: string; address2?: string; diff --git a/packages/nodes-base/nodes/InvoiceNinja/ExpenseDescription.ts b/packages/nodes-base/nodes/InvoiceNinja/ExpenseDescription.ts index 39e1c61bb1..3bf3f6977e 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/ExpenseDescription.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/ExpenseDescription.ts @@ -18,21 +18,21 @@ export const expenseOperations = [ value: 'create', description: 'Create a new expense', }, + { + name: 'Delete', + value: 'delete', + description: 'Delete an expense', + }, { name: 'Get', value: 'get', - description: 'Get data of a expense', + description: 'Get data of an expense', }, { name: 'Get All', value: 'getAll', description: 'Get data of all expenses', }, - { - name: 'Delete', - value: 'delete', - description: 'Delete a expense', - } ], default: 'create', description: 'The operation to perform.', @@ -60,6 +60,12 @@ export const expenseFields = [ }, }, options: [ + { + displayName: 'Amount', + name: 'amount', + type: 'number', + default: 0, + }, { displayName: 'Billable', name: 'billable', diff --git a/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts b/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts index 2eeea9f596..9d690807c2 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts @@ -13,29 +13,21 @@ import { import { get } from 'lodash'; -export async function invoiceninjaApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query?: IDataObject, uri?: string): Promise { // tslint:disable-line:no-any - let token; - let endpoint; - const cloudCredentials = this.getCredentials('invoiceNinjaCloudApi'); - const serverCredentials = this.getCredentials('invoiceNinjaServerApi'); - if (cloudCredentials === undefined && serverCredentials === undefined) { +export async function invoiceNinjaApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query?: IDataObject, uri?: string): Promise { // tslint:disable-line:no-any + const credentials = this.getCredentials('invoiceNinjaApi'); + if (credentials === undefined) { throw new Error('No credentials got returned!'); } - if (cloudCredentials !== undefined) { - endpoint = 'https://app.invoiceninja.com'; - token = cloudCredentials!.apiToken; - } else { - endpoint = serverCredentials!.domain; - token = serverCredentials!.apiToken; - } + + const baseUrl = credentials!.url || 'https://app.invoiceninja.com'; const options: OptionsWithUri = { headers: { Accept: 'application/json', - 'X-Ninja-Token': token, + 'X-Ninja-Token': credentials.apiToken, }, method, qs: query, - uri: uri || `${endpoint}/api/v1${resource}`, + uri: uri || `${baseUrl}/api/v1${endpoint}`, body, json: true }; @@ -54,7 +46,7 @@ export async function invoiceninjaApiRequest(this: IHookFunctions | IExecuteFunc } } -export async function invoiceninjaApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function invoiceNinjaApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any const returnData: IDataObject[] = []; @@ -63,8 +55,8 @@ export async function invoiceninjaApiRequestAllItems(this: IExecuteFunctions | I query.per_page = 100; do { - responseData = await invoiceninjaApiRequest.call(this, method, endpoint, body, query, uri); - let next = get(responseData, 'meta.pagination.links.next') as string | undefined; + responseData = await invoiceNinjaApiRequest.call(this, method, endpoint, body, query, uri); + const next = get(responseData, 'meta.pagination.links.next') as string | undefined; if (next) { uri = next; } diff --git a/packages/nodes-base/nodes/InvoiceNinja/InvoiceDescription.ts b/packages/nodes-base/nodes/InvoiceNinja/InvoiceDescription.ts index de5a17f974..51ace0215c 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/InvoiceDescription.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/InvoiceDescription.ts @@ -18,6 +18,11 @@ export const invoiceOperations = [ value: 'create', description: 'Create a new invoice', }, + { + name: 'Delete', + value: 'delete', + description: 'Delete a invoice', + }, { name: 'Email', value: 'email', @@ -33,11 +38,6 @@ export const invoiceOperations = [ value: 'getAll', description: 'Get data of all invoices', }, - { - name: 'Delete', - value: 'delete', - description: 'Delete a invoice', - } ], default: 'create', description: 'The operation to perform.', @@ -175,7 +175,7 @@ export const invoiceFields = [ default: '', }, { - displayName: 'Po Number', + displayName: 'PO Number', name: 'poNumber', type: 'string', default: '', diff --git a/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts b/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts index 5c996e0384..b1be5bdcd0 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts @@ -3,23 +3,23 @@ import { } from 'n8n-core'; import { IDataObject, - INodeTypeDescription, INodeExecutionData, - INodeType, ILoadOptionsFunctions, INodePropertyOptions, + INodeType, + INodeTypeDescription, } from 'n8n-workflow'; import { - invoiceninjaApiRequest, - invoiceninjaApiRequestAllItems, + invoiceNinjaApiRequest, + invoiceNinjaApiRequestAllItems, } from './GenericFunctions'; import { + clientFields, clientOperations, - clientFields } from './ClientDescription'; import { + invoiceFields, invoiceOperations, - invoiceFields } from './InvoiceDescription'; import { IClient, @@ -33,29 +33,29 @@ import { IItem, } from './invoiceInterface'; import { + taskFields, taskOperations, - taskFields } from './TaskDescription'; import { ITask, } from './TaskInterface'; import { + paymentFields, paymentOperations, - paymentFields } from './PaymentDescription'; import { IPayment, } from './PaymentInterface'; import { + expenseFields, expenseOperations, - expenseFields } from './ExpenseDescription'; import { IExpense, } from './ExpenseInterface'; import { + quoteFields, quoteOperations, - quoteFields } from './QuoteDescription'; import { IQuote, @@ -78,45 +78,11 @@ export class InvoiceNinja implements INodeType { outputs: ['main'], credentials: [ { - name: 'invoiceNinjaCloudApi', + name: 'invoiceNinjaApi', required: true, - displayOptions: { - show: { - invoiceNinjaVersion: [ - 'cloud', - ], - }, - }, - }, - { - name: 'invoiceNinjaServerApi', - required: true, - displayOptions: { - show: { - invoiceNinjaVersion: [ - 'server', - ], - }, - }, }, ], properties: [ - { - displayName: 'Version', - name: 'invoiceNinjaVersion', - type: 'options', - options: [ - { - name: 'Cloud', - value: 'cloud', - }, - { - name: 'Server (Self Hosted)', - value: 'server', - }, - ], - default: 'cloud', - }, { displayName: 'Resource', name: 'resource', @@ -171,7 +137,7 @@ export class InvoiceNinja implements INodeType { // select them easily async getClients(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const clients = await invoiceninjaApiRequestAllItems.call(this, 'data', 'GET', '/clients'); + const clients = await invoiceNinjaApiRequestAllItems.call(this, 'data', 'GET', '/clients'); for (const client of clients) { const clientName = client.display_name; const clientId = client.id; @@ -186,7 +152,7 @@ export class InvoiceNinja implements INodeType { // select them easily async getProjects(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const projects = await invoiceninjaApiRequestAllItems.call(this, 'data', 'GET', '/projects'); + const projects = await invoiceNinjaApiRequestAllItems.call(this, 'data', 'GET', '/projects'); for (const project of projects) { const projectName = project.name; const projectId = project.id; @@ -201,7 +167,7 @@ export class InvoiceNinja implements INodeType { // select them easily async getInvoices(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const invoices = await invoiceninjaApiRequestAllItems.call(this, 'data', 'GET', '/invoices'); + const invoices = await invoiceNinjaApiRequestAllItems.call(this, 'data', 'GET', '/invoices'); for (const invoice of invoices) { const invoiceName = invoice.invoice_number; const invoiceId = invoice.id; @@ -230,7 +196,7 @@ export class InvoiceNinja implements INodeType { // select them easily async getVendors(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const vendors = await invoiceninjaApiRequestAllItems.call(this, 'data', 'GET', '/vendors'); + const vendors = await invoiceNinjaApiRequestAllItems.call(this, 'data', 'GET', '/vendors'); for (const vendor of vendors) { const vendorName = vendor.name; const vendorId = vendor.id; @@ -245,7 +211,7 @@ export class InvoiceNinja implements INodeType { // select them easily async getExpenseCategories(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const categories = await invoiceninjaApiRequestAllItems.call(this, 'data', 'GET', '/expense_categories'); + const categories = await invoiceNinjaApiRequestAllItems.call(this, 'data', 'GET', '/expense_categories'); for (const category of categories) { const categoryName = category.name; const categoryId = category.id; @@ -306,8 +272,8 @@ export class InvoiceNinja implements INodeType { last_name: contactValue.lastName as string, email: contactValue.email as string, phone: contactValue.phone as string, - } - contacts.push(contact) + }; + contacts.push(contact); } body.contacts = contacts; } @@ -329,7 +295,7 @@ export class InvoiceNinja implements INodeType { body.postal_code = billingAddressValue.postalCode as string; body.country_id = parseInt(billingAddressValue.countryCode as string, 10); } - responseData = await invoiceninjaApiRequest.call(this, 'POST', '/clients', body); + responseData = await invoiceNinjaApiRequest.call(this, 'POST', '/clients', body); responseData = responseData.data; } if (operation === 'get') { @@ -338,7 +304,7 @@ export class InvoiceNinja implements INodeType { if (options.include) { qs.include = options.include as string; } - responseData = await invoiceninjaApiRequest.call(this, 'GET', `/clients/${clientId}`, {}, qs); + responseData = await invoiceNinjaApiRequest.call(this, 'GET', `/clients/${clientId}`, {}, qs); responseData = responseData.data; } if (operation === 'getAll') { @@ -348,16 +314,16 @@ export class InvoiceNinja implements INodeType { qs.include = options.include as string; } if (returnAll === true) { - responseData = await invoiceninjaApiRequestAllItems.call(this, 'data', 'GET', '/clients', {}, qs); + responseData = await invoiceNinjaApiRequestAllItems.call(this, 'data', 'GET', '/clients', {}, qs); } else { qs.per_page = this.getNodeParameter('limit', 0) as number; - responseData = await invoiceninjaApiRequest.call(this, 'GET', '/clients', {}, qs); + responseData = await invoiceNinjaApiRequest.call(this, 'GET', '/clients', {}, qs); responseData = responseData.data; } } if (operation === 'delete') { const clientId = this.getNodeParameter('clientId', i) as string; - responseData = await invoiceninjaApiRequest.call(this, 'DELETE', `/clients/${clientId}`); + responseData = await invoiceNinjaApiRequest.call(this, 'DELETE', `/clients/${clientId}`); responseData = responseData.data; } } @@ -444,17 +410,17 @@ export class InvoiceNinja implements INodeType { tax_rate2: itemValue.taxRate2 as number, tax_name1: itemValue.taxName1 as string, tax_name2: itemValue.taxName2 as string, - } - items.push(item) + }; + items.push(item); } body.invoice_items = items; } - responseData = await invoiceninjaApiRequest.call(this, 'POST', '/invoices', body); + responseData = await invoiceNinjaApiRequest.call(this, 'POST', '/invoices', body); responseData = responseData.data; } if (operation === 'email') { const invoiceId = this.getNodeParameter('invoiceId', i) as string; - responseData = await invoiceninjaApiRequest.call(this, 'POST', '/email_invoice', { id: invoiceId }); + responseData = await invoiceNinjaApiRequest.call(this, 'POST', '/email_invoice', { id: invoiceId }); } if (operation === 'get') { const invoiceId = this.getNodeParameter('invoiceId', i) as string; @@ -462,7 +428,7 @@ export class InvoiceNinja implements INodeType { if (options.include) { qs.include = options.include as string; } - responseData = await invoiceninjaApiRequest.call(this, 'GET', `/invoices/${invoiceId}`, {}, qs); + responseData = await invoiceNinjaApiRequest.call(this, 'GET', `/invoices/${invoiceId}`, {}, qs); responseData = responseData.data; } if (operation === 'getAll') { @@ -475,16 +441,16 @@ export class InvoiceNinja implements INodeType { qs.invoice_number = options.invoiceNumber as string; } if (returnAll === true) { - responseData = await invoiceninjaApiRequestAllItems.call(this, 'data', 'GET', '/invoices', {}, qs); + responseData = await invoiceNinjaApiRequestAllItems.call(this, 'data', 'GET', '/invoices', {}, qs); } else { qs.per_page = this.getNodeParameter('limit', 0) as number; - responseData = await invoiceninjaApiRequest.call(this, 'GET', '/invoices', {}, qs); + responseData = await invoiceNinjaApiRequest.call(this, 'GET', '/invoices', {}, qs); responseData = responseData.data; } } if (operation === 'delete') { const invoiceId = this.getNodeParameter('invoiceId', i) as string; - responseData = await invoiceninjaApiRequest.call(this, 'DELETE', `/invoices/${invoiceId}`); + responseData = await invoiceNinjaApiRequest.call(this, 'DELETE', `/invoices/${invoiceId}`); responseData = responseData.data; } } @@ -519,13 +485,13 @@ export class InvoiceNinja implements INodeType { to = new Date(logValue.endDate as string).getTime()/1000 as number; } if (logValue.duration) { - to = from + (logValue.duration as number * 3600) + to = from + (logValue.duration as number * 3600); } logs.push([from as number, to as number]); } body.time_log = JSON.stringify(logs); } - responseData = await invoiceninjaApiRequest.call(this, 'POST', '/tasks', body); + responseData = await invoiceNinjaApiRequest.call(this, 'POST', '/tasks', body); responseData = responseData.data; } if (operation === 'get') { @@ -534,7 +500,7 @@ export class InvoiceNinja implements INodeType { if (options.include) { qs.include = options.include as string; } - responseData = await invoiceninjaApiRequest.call(this, 'GET', `/tasks/${taskId}`, {}, qs); + responseData = await invoiceNinjaApiRequest.call(this, 'GET', `/tasks/${taskId}`, {}, qs); responseData = responseData.data; } if (operation === 'getAll') { @@ -544,16 +510,16 @@ export class InvoiceNinja implements INodeType { qs.include = options.include as string; } if (returnAll === true) { - responseData = await invoiceninjaApiRequestAllItems.call(this, 'data', 'GET', '/tasks', {}, qs); + responseData = await invoiceNinjaApiRequestAllItems.call(this, 'data', 'GET', '/tasks', {}, qs); } else { qs.per_page = this.getNodeParameter('limit', 0) as number; - responseData = await invoiceninjaApiRequest.call(this, 'GET', '/tasks', {}, qs); + responseData = await invoiceNinjaApiRequest.call(this, 'GET', '/tasks', {}, qs); responseData = responseData.data; } } if (operation === 'delete') { const taskId = this.getNodeParameter('taskId', i) as string; - responseData = await invoiceninjaApiRequest.call(this, 'DELETE', `/tasks/${taskId}`); + responseData = await invoiceNinjaApiRequest.call(this, 'DELETE', `/tasks/${taskId}`); responseData = responseData.data; } } @@ -575,7 +541,7 @@ export class InvoiceNinja implements INodeType { if (additionalFields.privateNotes) { body.private_notes = additionalFields.privateNotes as string; } - responseData = await invoiceninjaApiRequest.call(this, 'POST', '/payments', body); + responseData = await invoiceNinjaApiRequest.call(this, 'POST', '/payments', body); responseData = responseData.data; } if (operation === 'get') { @@ -584,7 +550,7 @@ export class InvoiceNinja implements INodeType { if (options.include) { qs.include = options.include as string; } - responseData = await invoiceninjaApiRequest.call(this, 'GET', `/payments/${paymentId}`, {}, qs); + responseData = await invoiceNinjaApiRequest.call(this, 'GET', `/payments/${paymentId}`, {}, qs); responseData = responseData.data; } if (operation === 'getAll') { @@ -594,16 +560,16 @@ export class InvoiceNinja implements INodeType { qs.include = options.include as string; } if (returnAll === true) { - responseData = await invoiceninjaApiRequestAllItems.call(this, 'data', 'GET', '/payments', {}, qs); + responseData = await invoiceNinjaApiRequestAllItems.call(this, 'data', 'GET', '/payments', {}, qs); } else { qs.per_page = this.getNodeParameter('limit', 0) as number; - responseData = await invoiceninjaApiRequest.call(this, 'GET', '/payments', {}, qs); + responseData = await invoiceNinjaApiRequest.call(this, 'GET', '/payments', {}, qs); responseData = responseData.data; } } if (operation === 'delete') { const paymentId = this.getNodeParameter('paymentId', i) as string; - responseData = await invoiceninjaApiRequest.call(this, 'DELETE', `/payments/${paymentId}`); + responseData = await invoiceNinjaApiRequest.call(this, 'DELETE', `/payments/${paymentId}`); responseData = responseData.data; } } @@ -611,6 +577,9 @@ export class InvoiceNinja implements INodeType { if (operation === 'create') { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const body: IExpense = {}; + if (additionalFields.amount) { + body.amount = additionalFields.amount as number; + } if (additionalFields.billable) { body.should_be_invoiced = additionalFields.billable as boolean; } @@ -659,27 +628,27 @@ export class InvoiceNinja implements INodeType { if (additionalFields.vendor) { body.vendor_id = additionalFields.vendor as number; } - responseData = await invoiceninjaApiRequest.call(this, 'POST', '/expenses', body); + responseData = await invoiceNinjaApiRequest.call(this, 'POST', '/expenses', body); responseData = responseData.data; } if (operation === 'get') { const expenseId = this.getNodeParameter('expenseId', i) as string; - responseData = await invoiceninjaApiRequest.call(this, 'GET', `/expenses/${expenseId}`, {}, qs); + responseData = await invoiceNinjaApiRequest.call(this, 'GET', `/expenses/${expenseId}`, {}, qs); responseData = responseData.data; } if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', 0) as boolean; if (returnAll === true) { - responseData = await invoiceninjaApiRequestAllItems.call(this, 'data', 'GET', '/payments', {}, qs); + responseData = await invoiceNinjaApiRequestAllItems.call(this, 'data', 'GET', '/expenses', {}, qs); } else { qs.per_page = this.getNodeParameter('limit', 0) as number; - responseData = await invoiceninjaApiRequest.call(this, 'GET', '/payments', {}, qs); + responseData = await invoiceNinjaApiRequest.call(this, 'GET', '/expenses', {}, qs); responseData = responseData.data; } } if (operation === 'delete') { const expenseId = this.getNodeParameter('expenseId', i) as string; - responseData = await invoiceninjaApiRequest.call(this, 'DELETE', `/expenses/${expenseId}`); + responseData = await invoiceNinjaApiRequest.call(this, 'DELETE', `/expenses/${expenseId}`); responseData = responseData.data; } } @@ -752,8 +721,8 @@ export class InvoiceNinja implements INodeType { if (additionalFields.paid) { body.paid = additionalFields.paid as number; } - if (additionalFields.emailQoute) { - body.email_invoice = additionalFields.emailQoute as boolean; + if (additionalFields.emailQuote) { + body.email_invoice = additionalFields.emailQuote as boolean; } const invoceItemsValues = (this.getNodeParameter('invoiceItemsUi', i) as IDataObject).invoiceItemsValues as IDataObject[]; if (invoceItemsValues) { @@ -768,17 +737,17 @@ export class InvoiceNinja implements INodeType { tax_rate2: itemValue.taxRate2 as number, tax_name1: itemValue.taxName1 as string, tax_name2: itemValue.taxName2 as string, - } - items.push(item) + }; + items.push(item); } body.invoice_items = items; } - responseData = await invoiceninjaApiRequest.call(this, 'POST', '/invoices', body); + responseData = await invoiceNinjaApiRequest.call(this, 'POST', '/invoices', body); responseData = responseData.data; } if (operation === 'email') { const quoteId = this.getNodeParameter('quoteId', i) as string; - responseData = await invoiceninjaApiRequest.call(this, 'POST', '/email_invoice', { id: quoteId }); + responseData = await invoiceNinjaApiRequest.call(this, 'POST', '/email_invoice', { id: quoteId }); } if (operation === 'get') { const quoteId = this.getNodeParameter('quoteId', i) as string; @@ -786,7 +755,7 @@ export class InvoiceNinja implements INodeType { if (options.include) { qs.include = options.include as string; } - responseData = await invoiceninjaApiRequest.call(this, 'GET', `/invoices/${quoteId}`, {}, qs); + responseData = await invoiceNinjaApiRequest.call(this, 'GET', `/invoices/${quoteId}`, {}, qs); responseData = responseData.data; } if (operation === 'getAll') { @@ -799,16 +768,16 @@ export class InvoiceNinja implements INodeType { qs.invoice_number = options.invoiceNumber as string; } if (returnAll === true) { - responseData = await invoiceninjaApiRequestAllItems.call(this, 'data', 'GET', '/quotes', {}, qs); + responseData = await invoiceNinjaApiRequestAllItems.call(this, 'data', 'GET', '/quotes', {}, qs); } else { qs.per_page = this.getNodeParameter('limit', 0) as number; - responseData = await invoiceninjaApiRequest.call(this, 'GET', '/quotes', {}, qs); + responseData = await invoiceNinjaApiRequest.call(this, 'GET', '/quotes', {}, qs); responseData = responseData.data; } } if (operation === 'delete') { const quoteId = this.getNodeParameter('quoteId', i) as string; - responseData = await invoiceninjaApiRequest.call(this, 'DELETE', `/invoices/${quoteId}`); + responseData = await invoiceNinjaApiRequest.call(this, 'DELETE', `/invoices/${quoteId}`); responseData = responseData.data; } } diff --git a/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.png b/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.png deleted file mode 100644 index d35e3050c7..0000000000 Binary files a/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.png and /dev/null differ diff --git a/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinjaTrigger.node.ts b/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinjaTrigger.node.ts index 924b3947dc..f84982c0f1 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinjaTrigger.node.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinjaTrigger.node.ts @@ -10,7 +10,7 @@ import { } from 'n8n-workflow'; import { - invoiceninjaApiRequest, + invoiceNinjaApiRequest, } from './GenericFunctions'; export class InvoiceNinjaTrigger implements INodeType { @@ -29,26 +29,8 @@ export class InvoiceNinjaTrigger implements INodeType { outputs: ['main'], credentials: [ { - name: 'invoiceNinjaCloudApi', + name: 'invoiceNinjaApi', required: true, - displayOptions: { - show: { - invoiceNinjaVersion: [ - 'cloud', - ], - }, - }, - }, - { - name: 'invoiceNinjaServerApi', - required: true, - displayOptions: { - show: { - invoiceNinjaVersion: [ - 'server', - ], - }, - }, }, ], webhooks: [ @@ -60,45 +42,29 @@ export class InvoiceNinjaTrigger implements INodeType { }, ], properties: [ - { - displayName: 'Version', - name: 'invoiceNinjaVersion', - type: 'options', - options: [ - { - name: 'Cloud', - value: 'cloud', - }, - { - name: 'Server (Self Hosted)', - value: 'server', - }, - ], - default: 'cloud', - }, { displayName: 'Event', name: 'event', type: 'options', options: [ { - name: 'client.created', + name: 'Client Created', value: 'create_client', }, { - name: 'invoce.created', + name: 'Invoice Created', value: 'create_invoice', }, { - name: 'payment.created', + name: 'Payment Created', value: 'create_payment', }, { - name: 'quote.created', + name: 'Quote Created', value: 'create_quote', }, { - name: 'vendor.created', + name: 'Vendor Created', value: 'create_vendor', }, ], @@ -126,7 +92,7 @@ export class InvoiceNinjaTrigger implements INodeType { event, }; - const responseData = await invoiceninjaApiRequest.call(this, 'POST', endpoint, body); + const responseData = await invoiceNinjaApiRequest.call(this, 'POST', endpoint, body); if (responseData.id === undefined) { // Required data is missing so was not successful @@ -145,7 +111,7 @@ export class InvoiceNinjaTrigger implements INodeType { const endpoint = `/hooks/${webhookData.webhookId}`; try { - await invoiceninjaApiRequest.call(this, 'DELETE', endpoint); + await invoiceNinjaApiRequest.call(this, 'DELETE', endpoint); } catch (e) { return false; } diff --git a/packages/nodes-base/nodes/InvoiceNinja/PaymentDescription.ts b/packages/nodes-base/nodes/InvoiceNinja/PaymentDescription.ts index e3e2763f14..baa24a495a 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/PaymentDescription.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/PaymentDescription.ts @@ -18,6 +18,11 @@ export const paymentOperations = [ value: 'create', description: 'Create a new payment', }, + { + name: 'Delete', + value: 'delete', + description: 'Delete a payment', + }, { name: 'Get', value: 'get', @@ -28,11 +33,6 @@ export const paymentOperations = [ value: 'getAll', description: 'Get data of all payments', }, - { - name: 'Delete', - value: 'delete', - description: 'Delete a payment', - } ], default: 'create', description: 'The operation to perform.', diff --git a/packages/nodes-base/nodes/InvoiceNinja/QuoteDescription.ts b/packages/nodes-base/nodes/InvoiceNinja/QuoteDescription.ts index 5bdf4ab87d..142cbcd782 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/QuoteDescription.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/QuoteDescription.ts @@ -18,6 +18,11 @@ export const quoteOperations = [ value: 'create', description: 'Create a new quote', }, + { + name: 'Delete', + value: 'delete', + description: 'Delete a quote', + }, { name: 'Email', value: 'email', @@ -33,11 +38,6 @@ export const quoteOperations = [ value: 'getAll', description: 'Get data of all quotes', }, - { - name: 'Delete', - value: 'delete', - description: 'Delete a quote', - } ], default: 'create', description: 'The operation to perform.', @@ -117,8 +117,8 @@ export const quoteFields = [ default: '', }, { - displayName: 'Email Qoute', - name: 'emailQoute', + displayName: 'Email Quote', + name: 'emailQuote', type: 'boolean', default: false, }, @@ -135,7 +135,7 @@ export const quoteFields = [ default: '', }, { - displayName: 'Qoute Status', + displayName: 'Quote Status', name: 'quoteStatus', type: 'options', options: [ @@ -351,7 +351,7 @@ export const quoteFields = [ /* quote:get */ /* -------------------------------------------------------------------------- */ { - displayName: 'Qoute ID', + displayName: 'Quote ID', name: 'quoteId', type: 'string', required: true, @@ -459,7 +459,7 @@ export const quoteFields = [ }, options: [ { - displayName: 'Qoute Number', + displayName: 'Quote Number', name: 'quoteNumber', type: 'string', default: '', diff --git a/packages/nodes-base/nodes/InvoiceNinja/TaskDescription.ts b/packages/nodes-base/nodes/InvoiceNinja/TaskDescription.ts index a3c608fc9e..f03ffb9bb6 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/TaskDescription.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/TaskDescription.ts @@ -18,6 +18,11 @@ export const taskOperations = [ value: 'create', description: 'Create a new task', }, + { + name: 'Delete', + value: 'delete', + description: 'Delete a task', + }, { name: 'Get', value: 'get', @@ -28,11 +33,6 @@ export const taskOperations = [ value: 'getAll', description: 'Get data of all tasks', }, - { - name: 'Delete', - value: 'delete', - description: 'Delete a task', - } ], default: 'create', description: 'The operation to perform.', diff --git a/packages/nodes-base/nodes/InvoiceNinja/invoiceNinja.png b/packages/nodes-base/nodes/InvoiceNinja/invoiceNinja.png new file mode 100644 index 0000000000..50c5ac69ca Binary files /dev/null and b/packages/nodes-base/nodes/InvoiceNinja/invoiceNinja.png differ diff --git a/packages/nodes-base/package.json b/packages/nodes-base/package.json index ac14ada5bc..b3467fc31e 100644 --- a/packages/nodes-base/package.json +++ b/packages/nodes-base/package.json @@ -62,8 +62,7 @@ "dist/credentials/HunterApi.credentials.js", "dist/credentials/Imap.credentials.js", "dist/credentials/IntercomApi.credentials.js", - "dist/credentials/InvoiceNinjaCloudApi.credentials.js", - "dist/credentials/InvoiceNinjaServerApi.credentials.js", + "dist/credentials/InvoiceNinjaApi.credentials.js", "dist/credentials/JiraSoftwareCloudApi.credentials.js", "dist/credentials/JiraSoftwareServerApi.credentials.js", "dist/credentials/JotFormApi.credentials.js",