mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
⚡ Minor improvements to Google Books Node
This commit is contained in:
parent
9a1328ccfb
commit
709dcdd57c
|
@ -26,7 +26,7 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
|
|||
body,
|
||||
qs,
|
||||
uri: uri || `https://www.googleapis.com/books/${resource}`,
|
||||
json: true
|
||||
json: true,
|
||||
};
|
||||
try {
|
||||
if (Object.keys(headers).length !== 0) {
|
||||
|
@ -67,7 +67,7 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
|
|||
}
|
||||
// Try to return the error prettier
|
||||
throw new Error(
|
||||
`Google Books error response [${error.statusCode}]: ${errors}`
|
||||
`Google Books error response [${error.statusCode}]: ${errors}`,
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
|
@ -117,7 +117,7 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
|
|||
'typ': 'JWT',
|
||||
'alg': 'RS256',
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
|
@ -130,7 +130,7 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
|
|||
assertion: signature,
|
||||
},
|
||||
uri: 'https://oauth2.googleapis.com/token',
|
||||
json: true
|
||||
json: true,
|
||||
};
|
||||
|
||||
//@ts-ignore
|
||||
|
|
|
@ -95,7 +95,7 @@ export class GoogleBooks implements INodeType {
|
|||
},
|
||||
],
|
||||
default: 'bookshelf',
|
||||
description: 'The resource to operate on',
|
||||
description: 'The resource to operate on.',
|
||||
},
|
||||
{
|
||||
displayName: 'Operation',
|
||||
|
@ -121,7 +121,7 @@ export class GoogleBooks implements INodeType {
|
|||
},
|
||||
},
|
||||
default: 'get',
|
||||
description: 'The operation to perform',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
{
|
||||
displayName: 'Operation',
|
||||
|
@ -162,7 +162,7 @@ export class GoogleBooks implements INodeType {
|
|||
},
|
||||
},
|
||||
default: 'getAll',
|
||||
description: 'The operation to perform',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
{
|
||||
displayName: 'Operation',
|
||||
|
@ -188,7 +188,7 @@ export class GoogleBooks implements INodeType {
|
|||
},
|
||||
},
|
||||
default: 'get',
|
||||
description: 'The operation to perform',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
{
|
||||
displayName: 'My Library',
|
||||
|
@ -204,7 +204,7 @@ export class GoogleBooks implements INodeType {
|
|||
],
|
||||
resource: [
|
||||
'bookshelf',
|
||||
'bookshelfVolume'
|
||||
'bookshelfVolume',
|
||||
],
|
||||
},
|
||||
},
|
||||
|
@ -217,7 +217,7 @@ export class GoogleBooks implements INodeType {
|
|||
displayName: 'Search Query',
|
||||
name: 'searchQuery',
|
||||
type: 'string',
|
||||
description: 'Full-text search query string',
|
||||
description: 'Full-text search query string.',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
|
@ -260,7 +260,7 @@ export class GoogleBooks implements INodeType {
|
|||
displayName: 'Bookshelf ID',
|
||||
name: 'shelfId',
|
||||
type: 'string',
|
||||
description: 'ID of the bookshelf',
|
||||
description: 'ID of the bookshelf.',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
|
@ -274,7 +274,7 @@ export class GoogleBooks implements INodeType {
|
|||
],
|
||||
resource: [
|
||||
'bookshelf',
|
||||
'bookshelfVolume'
|
||||
'bookshelfVolume',
|
||||
],
|
||||
},
|
||||
},
|
||||
|
@ -283,7 +283,7 @@ export class GoogleBooks implements INodeType {
|
|||
displayName: 'Bookshelf ID',
|
||||
name: 'shelfId',
|
||||
type: 'string',
|
||||
description: 'ID of the bookshelf',
|
||||
description: 'ID of the bookshelf.',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
|
@ -301,7 +301,7 @@ export class GoogleBooks implements INodeType {
|
|||
displayName: 'Volume ID',
|
||||
name: 'volumeId',
|
||||
type: 'string',
|
||||
description: 'ID of the volume',
|
||||
description: 'ID of the volume.',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
|
@ -323,7 +323,7 @@ export class GoogleBooks implements INodeType {
|
|||
displayName: 'Volume Position',
|
||||
name: 'volumePosition',
|
||||
type: 'string',
|
||||
description: 'Position on shelf to move the item (0 puts the item before the current first item, 1 puts it between the first and the second and so on) ',
|
||||
description: 'Position on shelf to move the item (0 puts the item before the<br />current first item, 1 puts it between the first and the second and so on).',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
|
@ -389,7 +389,7 @@ export class GoogleBooks implements INodeType {
|
|||
if (operation === 'get') {
|
||||
const volumeId = this.getNodeParameter('volumeId', i) as string;
|
||||
responseData = await googleApiRequest.call(this, 'GET', `v1/volumes/${volumeId}`, {});
|
||||
} else if (operation === 'getAll') {
|
||||
} else if (operation === 'getAll') {
|
||||
const searchQuery = this.getNodeParameter('searchQuery', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
if (returnAll) {
|
||||
|
@ -399,7 +399,7 @@ export class GoogleBooks implements INodeType {
|
|||
responseData = await googleApiRequest.call(this, 'GET', `v1/volumes?q=${searchQuery}`, {}, qs);
|
||||
responseData = responseData.items || [];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (resource === 'bookshelf') {
|
||||
|
@ -450,7 +450,7 @@ export class GoogleBooks implements INodeType {
|
|||
responseData = await googleApiRequest.call(this, 'POST', `v1/mylibrary/bookshelves/${shelfId}/clearVolumes`);
|
||||
}
|
||||
|
||||
if (operation === 'getAll') {
|
||||
if (operation === 'getAll') {
|
||||
const shelfId = this.getNodeParameter('shelfId', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
const myLibrary = this.getNodeParameter('myLibrary', i) as boolean;
|
||||
|
|
Loading…
Reference in a new issue