mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 05:04:05 -08:00
⚡ Migrated API from V1beta to V1 (#813)
This commit is contained in:
parent
5eb30b34a9
commit
3cafc68f19
|
@ -38,7 +38,7 @@ export class Coda implements INodeType {
|
||||||
group: ['output'],
|
group: ['output'],
|
||||||
version: 1,
|
version: 1,
|
||||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||||
description: 'Consume Coda Beta API',
|
description: 'Consume Coda API',
|
||||||
defaults: {
|
defaults: {
|
||||||
name: 'Coda',
|
name: 'Coda',
|
||||||
color: '#c02428',
|
color: '#c02428',
|
||||||
|
@ -152,7 +152,7 @@ export class Coda implements INodeType {
|
||||||
async getViews(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
async getViews(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
const returnData: INodePropertyOptions[] = [];
|
const returnData: INodePropertyOptions[] = [];
|
||||||
const docId = this.getCurrentNodeParameter('docId');
|
const docId = this.getCurrentNodeParameter('docId');
|
||||||
const views = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/views`, {});
|
const views = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/tables?tableTypes=view`, {});
|
||||||
for (const view of views) {
|
for (const view of views) {
|
||||||
const viewName = view.name;
|
const viewName = view.name;
|
||||||
const viewId = view.id;
|
const viewId = view.id;
|
||||||
|
@ -185,7 +185,7 @@ export class Coda implements INodeType {
|
||||||
const returnData: INodePropertyOptions[] = [];
|
const returnData: INodePropertyOptions[] = [];
|
||||||
const docId = this.getCurrentNodeParameter('docId');
|
const docId = this.getCurrentNodeParameter('docId');
|
||||||
const viewId = this.getCurrentNodeParameter('viewId');
|
const viewId = this.getCurrentNodeParameter('viewId');
|
||||||
const viewRows = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/views/${viewId}/rows`, {});
|
const viewRows = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/tables/${viewId}/rows`, {});
|
||||||
for (const viewRow of viewRows) {
|
for (const viewRow of viewRows) {
|
||||||
const viewRowName = viewRow.name;
|
const viewRowName = viewRow.name;
|
||||||
const viewRowId = viewRow.id;
|
const viewRowId = viewRow.id;
|
||||||
|
@ -204,7 +204,7 @@ export class Coda implements INodeType {
|
||||||
const docId = this.getCurrentNodeParameter('docId');
|
const docId = this.getCurrentNodeParameter('docId');
|
||||||
const viewId = this.getCurrentNodeParameter('viewId');
|
const viewId = this.getCurrentNodeParameter('viewId');
|
||||||
|
|
||||||
const viewColumns = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/views/${viewId}/columns`, {});
|
const viewColumns = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/tables/${viewId}/columns`, {});
|
||||||
for (const viewColumn of viewColumns) {
|
for (const viewColumn of viewColumns) {
|
||||||
const viewColumnName = viewColumn.name;
|
const viewColumnName = viewColumn.name;
|
||||||
const viewColumnId = viewColumn.id;
|
const viewColumnId = viewColumn.id;
|
||||||
|
@ -488,7 +488,7 @@ export class Coda implements INodeType {
|
||||||
for (let i = 0; i < items.length; i++) {
|
for (let i = 0; i < items.length; i++) {
|
||||||
const docId = this.getNodeParameter('docId', i) as string;
|
const docId = this.getNodeParameter('docId', i) as string;
|
||||||
const viewId = this.getNodeParameter('viewId', i) as string;
|
const viewId = this.getNodeParameter('viewId', i) as string;
|
||||||
const endpoint = `/docs/${docId}/views/${viewId}`;
|
const endpoint = `/docs/${docId}/tables/${viewId}`;
|
||||||
responseData = await codaApiRequest.call(this, 'GET', endpoint, {});
|
responseData = await codaApiRequest.call(this, 'GET', endpoint, {});
|
||||||
returnData.push(responseData);
|
returnData.push(responseData);
|
||||||
}
|
}
|
||||||
|
@ -499,7 +499,7 @@ export class Coda implements INodeType {
|
||||||
for (let i = 0; i < items.length; i++) {
|
for (let i = 0; i < items.length; i++) {
|
||||||
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
||||||
const docId = this.getNodeParameter('docId', i) as string;
|
const docId = this.getNodeParameter('docId', i) as string;
|
||||||
const endpoint = `/docs/${docId}/views`;
|
const endpoint = `/docs/${docId}/tables?tableTypes=view`;
|
||||||
if (returnAll) {
|
if (returnAll) {
|
||||||
responseData = await codaApiRequestAllItems.call(this, 'items', 'GET', endpoint, {});
|
responseData = await codaApiRequestAllItems.call(this, 'items', 'GET', endpoint, {});
|
||||||
} else {
|
} else {
|
||||||
|
@ -516,7 +516,7 @@ export class Coda implements INodeType {
|
||||||
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
||||||
const viewId = this.getNodeParameter('viewId', 0) as string;
|
const viewId = this.getNodeParameter('viewId', 0) as string;
|
||||||
const options = this.getNodeParameter('options', 0) as IDataObject;
|
const options = this.getNodeParameter('options', 0) as IDataObject;
|
||||||
const endpoint = `/docs/${docId}/views/${viewId}/rows`;
|
const endpoint = `/docs/${docId}/tables/${viewId}/rows`;
|
||||||
if (options.useColumnNames === false) {
|
if (options.useColumnNames === false) {
|
||||||
qs.useColumnNames = options.useColumnNames as boolean;
|
qs.useColumnNames = options.useColumnNames as boolean;
|
||||||
} else {
|
} else {
|
||||||
|
@ -561,7 +561,7 @@ export class Coda implements INodeType {
|
||||||
const docId = this.getNodeParameter('docId', i) as string;
|
const docId = this.getNodeParameter('docId', i) as string;
|
||||||
const viewId = this.getNodeParameter('viewId', i) as string;
|
const viewId = this.getNodeParameter('viewId', i) as string;
|
||||||
const rowId = this.getNodeParameter('rowId', i) as string;
|
const rowId = this.getNodeParameter('rowId', i) as string;
|
||||||
const endpoint = `/docs/${docId}/views/${viewId}/rows/${rowId}`;
|
const endpoint = `/docs/${docId}/tables/${viewId}/rows/${rowId}`;
|
||||||
responseData = await codaApiRequest.call(this, 'DELETE', endpoint);
|
responseData = await codaApiRequest.call(this, 'DELETE', endpoint);
|
||||||
returnData.push.apply(returnData,responseData);
|
returnData.push.apply(returnData,responseData);
|
||||||
}
|
}
|
||||||
|
@ -574,7 +574,7 @@ export class Coda implements INodeType {
|
||||||
const viewId = this.getNodeParameter('viewId', i) as string;
|
const viewId = this.getNodeParameter('viewId', i) as string;
|
||||||
const rowId = this.getNodeParameter('rowId', i) as string;
|
const rowId = this.getNodeParameter('rowId', i) as string;
|
||||||
const columnId = this.getNodeParameter('columnId', i) as string;
|
const columnId = this.getNodeParameter('columnId', i) as string;
|
||||||
const endpoint = `/docs/${docId}/views/${viewId}/rows/${rowId}/buttons/${columnId}`;
|
const endpoint = `/docs/${docId}/tables/${viewId}/rows/${rowId}/buttons/${columnId}`;
|
||||||
responseData = await codaApiRequest.call(this, 'POST', endpoint);
|
responseData = await codaApiRequest.call(this, 'POST', endpoint);
|
||||||
returnData.push.apply(returnData,responseData);
|
returnData.push.apply(returnData,responseData);
|
||||||
}
|
}
|
||||||
|
@ -585,7 +585,7 @@ export class Coda implements INodeType {
|
||||||
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
||||||
const docId = this.getNodeParameter('docId', i) as string;
|
const docId = this.getNodeParameter('docId', i) as string;
|
||||||
const viewId = this.getNodeParameter('viewId', i) as string;
|
const viewId = this.getNodeParameter('viewId', i) as string;
|
||||||
const endpoint = `/docs/${docId}/views/${viewId}/columns`;
|
const endpoint = `/docs/${docId}/tables/${viewId}/columns`;
|
||||||
if (returnAll) {
|
if (returnAll) {
|
||||||
responseData = await codaApiRequestAllItems.call(this, 'items', 'GET', endpoint, {});
|
responseData = await codaApiRequestAllItems.call(this, 'items', 'GET', endpoint, {});
|
||||||
} else {
|
} else {
|
||||||
|
@ -607,12 +607,13 @@ export class Coda implements INodeType {
|
||||||
const keyName = this.getNodeParameter('keyName', i) as string;
|
const keyName = this.getNodeParameter('keyName', i) as string;
|
||||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||||
const body: IDataObject = {};
|
const body: IDataObject = {};
|
||||||
const endpoint = `/docs/${docId}/views/${viewId}/rows/${rowId}`;
|
const endpoint = `/docs/${docId}/tables/${viewId}/rows/${rowId}`;
|
||||||
if (options.disableParsing) {
|
if (options.disableParsing) {
|
||||||
qs.disableParsing = options.disableParsing as boolean;
|
qs.disableParsing = options.disableParsing as boolean;
|
||||||
}
|
}
|
||||||
const cells = [];
|
const cells = [];
|
||||||
cells.length = 0;
|
cells.length = 0;
|
||||||
|
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
for (const key of Object.keys(items[i].json[keyName])) {
|
for (const key of Object.keys(items[i].json[keyName])) {
|
||||||
cells.push({
|
cells.push({
|
||||||
|
|
|
@ -17,13 +17,14 @@ export async function codaApiRequest(this: IExecuteFunctions | IExecuteSingleFun
|
||||||
method,
|
method,
|
||||||
qs,
|
qs,
|
||||||
body,
|
body,
|
||||||
uri: uri ||`https://coda.io/apis/v1beta1${resource}`,
|
uri: uri ||`https://coda.io/apis/v1${resource}`,
|
||||||
json: true
|
json: true
|
||||||
};
|
};
|
||||||
options = Object.assign({}, options, option);
|
options = Object.assign({}, options, option);
|
||||||
if (Object.keys(options.body).length === 0) {
|
if (Object.keys(options.body).length === 0) {
|
||||||
delete options.body;
|
delete options.body;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.request!(options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
Loading…
Reference in a new issue