Add full continue-on-fail support to all nodes (#1996)

* Update Compression node

* Update Crypto node

* Update DateTime node

* Update EditImage node

* Update EmailSend node

* Update ExecuteWorkflow node

* Update FTP node

* Update Function node

* Update FunctionItem node

* Update ExecuteCommand node

* Update OpenWeatherMap node

* Update ReadBinaryFile node

* Update ReadPdf node

* Update RssFeedRead node & add URL validation

* Update SpreadsheetFile node

* Update Switch node

* Update WriteBinaryFile node

* Update Xml node

* Update ActiveCampaign node

* Update Airtable node

* Update ApiTemplateIo node

* Update Asana node

* Update AwsLambda node

* Update AwsSns node

* Update AwsComprehend node

* Update AwsRekognition node

* Update AwsS3 node

* Fix Error item

* Update AwsSes node

* Update AwsSqs node

* Update Amqp node

* Update Bitly node

* Update Box node

* Update Brandfetch node

* Update CircleCi node

* Update Clearbit node

* Update ClickUp node

* Update Cockpit node

* Update CoinGecko node

* Update Contentful node

* Update ConvertKit node

* Update Cortex node

* Update CustomerIo node

* Update DeepL node

* Update Demio node

* Update Disqus node

* Update Drift node

* Update Dropbox node

* Update GetResponse node

* Refactor & Update Ghost node

* Update Github node

* Update Gitlab node

* Update GoogleAnalytics node

* Update GoogleBooks node

* Update GoogleCalendar node

* Update GoogleDrive node

* Update Gmail node

* Update GoogleSheets node

* Update GoogleSlides node

* Update GoogleTasks node

* Update Gotify node

* Update GraphQL node

* Update HackerNews node

* Update Harvest node

* Update HtmlExtract node

* Update Hubspot node

* Update Hunter node

* Update Intercom node

* Update Kafka node

* Refactor & update Line node

* Update LinkedIn node

* Update Mailchimp node

* Update Mandrill node

* Update Matrix node

* Update Mautic node

* Update Medium node

* Update MessageBird node

* Update Mindee node

* Update Mocean node

* Update MondayCom node

* Update MicrosoftExcel node

* Update MicrosoftOneDrive node

* Update MicrosoftOutlook node

* Update Affinity node

* Update Chargebee node

* Update Discourse node

* Update Freshdesk node

* Update YouTube node

* Update InvoiceNinja node

* Update MailerLite node

* Update Mailgun node

* Update Mailjet node

* Update Mattermost node

* Update Nasa node

* Update NextCloud node

* Update OpenThesaurus node

* Update Orbit node

* Update PagerDuty node

* Update PayPal node

* Update Peekalink node

* Update Phantombuster node

* Update PostHog node

* Update ProfitWell node

* Refactor & Update Pushbullet node

* Update QuickBooks node

* Update Raindrop node

* Update Reddit node

* Update Rocketchat node

* Update S3 node

* Update Salesforce node

* Update SendGrid node

* Update SentryIo node

* Update Shopify node

* Update Signl4 node

* Update Slack node

* Update Spontit node

* Update Spotify node

* Update Storyblok node

* Refactor & Update Strapi node

* Refactor & Update Strava node

* Update Taiga node

* Refactor & update Tapfiliate node

* Update Telegram node

* Update TheHive node

* Update Todoist node

* Update TravisCi node

* Update Trello node

* Update Twilio node

* Update Twist node

* Update Twitter node

* Update Uplead node

* Update UProc node

* Update Vero node

* Update Webflow node

* Update Wekan node

* Update Wordpress node

* Update Xero node

* Update Yourls node

* Update Zendesk node

* Update ZohoCrm node

* Refactor & Update Zoom node

* Update Zulip node

* Update Clockify node

* Update MongoDb node

* Update MySql node

* Update MicrosoftTeams node

* Update Stackby node

* Refactor Discourse node

* Support corner-case in Github node update

* Support corner-case in Gitlab node update

* Refactor & Update GoogleContacts node

* Refactor Mindee node

* Update Coda node

* Lint fixes

* Update Beeminder node

* Update Google Firebase RealtimeDatabase node

* Update HelpScout node

* Update Mailcheck node

* Update Paddle node

* Update Pipedrive node

* Update Pushover node

* Update Segment node

* Refactor & Update Vonage node

* Added new conditions to warnings on execute batch cmd

* Added keep only properties flag

* Fixed code for keep only props

* Added dependencies for image editing

Co-authored-by: dali <servfrdali@yahoo.fr>
This commit is contained in:
Omar Ajoue
2021-07-20 08:58:54 +02:00
committed by GitHub
parent 6a9401aa51
commit d6239d5bfb
159 changed files with 35795 additions and 33847 deletions

View File

@@ -896,321 +896,159 @@ export class Spotify implements INodeType {
returnAll = false;
for (let i = 0; i < items.length; i++) {
if (resource === 'player') {
try {
if (resource === 'player') {
// -----------------------------
// Player Operations
// -----------------------------
// -----------------------------
// Player Operations
// -----------------------------
if (operation === 'pause') {
requestMethod = 'PUT';
if (operation === 'pause') {
requestMethod = 'PUT';
endpoint = `/me/player/pause`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = { success: true };
} else if (operation === 'recentlyPlayed') {
requestMethod = 'GET';
endpoint = `/me/player/recently-played`;
const limit = this.getNodeParameter('limit', i) as number;
qs = {
limit,
};
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.items;
} else if (operation === 'currentlyPlaying') {
requestMethod = 'GET';
endpoint = `/me/player/currently-playing`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
} else if (operation === 'nextSong') {
requestMethod = 'POST';
endpoint = `/me/player/next`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = { success: true };
} else if (operation === 'previousSong') {
requestMethod = 'POST';
endpoint = `/me/player/previous`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = { success: true };
} else if (operation === 'startMusic') {
requestMethod = 'PUT';
endpoint = `/me/player/play`;
const id = this.getNodeParameter('id', i) as string;
body.context_uri = id;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = { success: true };
} else if (operation === 'addSongToQueue') {
requestMethod = 'POST';
endpoint = `/me/player/queue`;
const id = this.getNodeParameter('id', i) as string;
qs = {
uri: id,
};
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = { success: true };
} else if (operation === 'resume') {
requestMethod = 'PUT';
endpoint = `/me/player/play`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = { success: true };
} else if (operation === 'volume') {
requestMethod = 'PUT';
endpoint = `/me/player/volume`;
const volumePercent = this.getNodeParameter('volumePercent', i) as number;
qs = {
volume_percent: volumePercent,
};
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = { success: true };
}
} else if (resource === 'album') {
// -----------------------------
// Album Operations
// -----------------------------
if (operation === 'get') {
const uri = this.getNodeParameter('id', i) as string;
const id = uri.replace('spotify:album:', '');
requestMethod = 'GET';
endpoint = `/albums/${id}`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
} else if (operation === 'getNewReleases') {
endpoint = '/browse/new-releases';
requestMethod = 'GET';
const filters = this.getNodeParameter('filters', i) as IDataObject;
if (Object.keys(filters).length) {
Object.assign(qs, filters);
}
returnAll = this.getNodeParameter('returnAll', i) as boolean;
if (!returnAll) {
qs.limit = this.getNodeParameter('limit', i);
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.albums.items;
}
} else if (operation === 'getTracks') {
const uri = this.getNodeParameter('id', i) as string;
const id = uri.replace('spotify:album:', '');
requestMethod = 'GET';
endpoint = `/albums/${id}/tracks`;
propertyName = 'tracks';
returnAll = this.getNodeParameter('returnAll', i) as boolean;
propertyName = 'items';
if (!returnAll) {
const limit = this.getNodeParameter('limit', i) as number;
qs = {
limit,
};
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.items;
}
} else if (operation === 'search') {
requestMethod = 'GET';
endpoint = '/search';
propertyName = 'albums.items';
returnAll = this.getNodeParameter('returnAll', i) as boolean;
const q = this.getNodeParameter('query', i) as string;
const filters = this.getNodeParameter('filters', i) as IDataObject;
qs = {
q,
type: 'album',
...filters,
};
if (returnAll === false) {
const limit = this.getNodeParameter('limit', i) as number;
qs.limit = limit;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.albums.items;
}
}
} else if (resource === 'artist') {
// -----------------------------
// Artist Operations
// -----------------------------
const uri = this.getNodeParameter('id', i, '') as string;
const id = uri.replace('spotify:artist:', '');
if (operation === 'getAlbums') {
endpoint = `/artists/${id}/albums`;
returnAll = this.getNodeParameter('returnAll', i) as boolean;
propertyName = 'items';
if (!returnAll) {
const limit = this.getNodeParameter('limit', i) as number;
qs = {
limit,
};
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.items;
}
} else if (operation === 'getRelatedArtists') {
endpoint = `/artists/${id}/related-artists`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.artists;
} else if (operation === 'getTopTracks') {
const country = this.getNodeParameter('country', i) as string;
qs = {
country,
};
endpoint = `/artists/${id}/top-tracks`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.tracks;
} else if (operation === 'get') {
requestMethod = 'GET';
endpoint = `/artists/${id}`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
} else if (operation === 'search') {
requestMethod = 'GET';
endpoint = '/search';
propertyName = 'artists.items';
returnAll = this.getNodeParameter('returnAll', i) as boolean;
const q = this.getNodeParameter('query', i) as string;
const filters = this.getNodeParameter('filters', i) as IDataObject;
qs = {
q,
limit: 50,
type: 'artist',
...filters,
};
if (returnAll === false) {
const limit = this.getNodeParameter('limit', i) as number;
qs.limit = limit;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.artists.items;
}
}
} else if (resource === 'playlist') {
// -----------------------------
// Playlist Operations
// -----------------------------
if (['delete', 'get', 'getTracks', 'add'].includes(operation)) {
const uri = this.getNodeParameter('id', i) as string;
const id = uri.replace('spotify:playlist:', '');
if (operation === 'delete') {
requestMethod = 'DELETE';
const trackId = this.getNodeParameter('trackID', i) as string;
body.tracks = [
{
uri: trackId,
},
];
endpoint = `/playlists/${id}/tracks`;
endpoint = `/me/player/pause`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = { success: true };
} else if (operation === 'get') {
} else if (operation === 'recentlyPlayed') {
requestMethod = 'GET';
endpoint = `/playlists/${id}`;
endpoint = `/me/player/recently-played`;
const limit = this.getNodeParameter('limit', i) as number;
qs = {
limit,
};
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
} else if (operation === 'getTracks') {
responseData = responseData.items;
} else if (operation === 'currentlyPlaying') {
requestMethod = 'GET';
endpoint = `/playlists/${id}/tracks`;
endpoint = `/me/player/currently-playing`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
} else if (operation === 'nextSong') {
requestMethod = 'POST';
endpoint = `/me/player/next`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = { success: true };
} else if (operation === 'previousSong') {
requestMethod = 'POST';
endpoint = `/me/player/previous`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = { success: true };
} else if (operation === 'startMusic') {
requestMethod = 'PUT';
endpoint = `/me/player/play`;
const id = this.getNodeParameter('id', i) as string;
body.context_uri = id;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = { success: true };
} else if (operation === 'addSongToQueue') {
requestMethod = 'POST';
endpoint = `/me/player/queue`;
const id = this.getNodeParameter('id', i) as string;
qs = {
uri: id,
};
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = { success: true };
} else if (operation === 'resume') {
requestMethod = 'PUT';
endpoint = `/me/player/play`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = { success: true };
} else if (operation === 'volume') {
requestMethod = 'PUT';
endpoint = `/me/player/volume`;
const volumePercent = this.getNodeParameter('volumePercent', i) as number;
qs = {
volume_percent: volumePercent,
};
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = { success: true };
}
} else if (resource === 'album') {
// -----------------------------
// Album Operations
// -----------------------------
if (operation === 'get') {
const uri = this.getNodeParameter('id', i) as string;
const id = uri.replace('spotify:album:', '');
requestMethod = 'GET';
endpoint = `/albums/${id}`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
} else if (operation === 'getNewReleases') {
endpoint = '/browse/new-releases';
requestMethod = 'GET';
const filters = this.getNodeParameter('filters', i) as IDataObject;
if (Object.keys(filters).length) {
Object.assign(qs, filters);
}
returnAll = this.getNodeParameter('returnAll', i) as boolean;
if (!returnAll) {
qs.limit = this.getNodeParameter('limit', i);
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.albums.items;
}
} else if (operation === 'getTracks') {
const uri = this.getNodeParameter('id', i) as string;
const id = uri.replace('spotify:album:', '');
requestMethod = 'GET';
endpoint = `/albums/${id}/tracks`;
propertyName = 'tracks';
returnAll = this.getNodeParameter('returnAll', i) as boolean;
@@ -1220,194 +1058,372 @@ export class Spotify implements INodeType {
const limit = this.getNodeParameter('limit', i) as number;
qs = {
'limit': limit,
limit,
};
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.items;
}
} else if (operation === 'add') {
requestMethod = 'POST';
} else if (operation === 'search') {
requestMethod = 'GET';
const trackId = this.getNodeParameter('trackID', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
endpoint = '/search';
propertyName = 'albums.items';
returnAll = this.getNodeParameter('returnAll', i) as boolean;
const q = this.getNodeParameter('query', i) as string;
const filters = this.getNodeParameter('filters', i) as IDataObject;
qs = {
uris: trackId,
q,
type: 'album',
...filters,
};
if (additionalFields.position !== undefined) {
qs.position = additionalFields.position;
if (returnAll === false) {
const limit = this.getNodeParameter('limit', i) as number;
qs.limit = limit;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.albums.items;
}
}
} else if (resource === 'artist') {
// -----------------------------
// Artist Operations
// -----------------------------
const uri = this.getNodeParameter('id', i, '') as string;
const id = uri.replace('spotify:artist:', '');
if (operation === 'getAlbums') {
endpoint = `/artists/${id}/albums`;
returnAll = this.getNodeParameter('returnAll', i) as boolean;
propertyName = 'items';
if (!returnAll) {
const limit = this.getNodeParameter('limit', i) as number;
qs = {
limit,
};
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.items;
}
endpoint = `/playlists/${id}/tracks`;
} else if (operation === 'getRelatedArtists') {
endpoint = `/artists/${id}/related-artists`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
}
} else if (operation === 'getUserPlaylists') {
requestMethod = 'GET';
endpoint = '/me/playlists';
responseData = responseData.artists;
returnAll = this.getNodeParameter('returnAll', i) as boolean;
propertyName = 'items';
if (!returnAll) {
const limit = this.getNodeParameter('limit', i) as number;
} else if (operation === 'getTopTracks') {
const country = this.getNodeParameter('country', i) as string;
qs = {
limit,
country,
};
endpoint = `/artists/${id}/top-tracks`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.items;
}
responseData = responseData.tracks;
} else if (operation === 'create') {
} else if (operation === 'get') {
// https://developer.spotify.com/console/post-playlists/
requestMethod = 'GET';
body.name = this.getNodeParameter('name', i) as string;
endpoint = `/artists/${id}`;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
if (Object.keys(additionalFields).length) {
Object.assign(body, additionalFields);
}
responseData = await spotifyApiRequest.call(this, 'POST', '/me/playlists', body, qs);
} else if (operation === 'search') {
requestMethod = 'GET';
endpoint = '/search';
propertyName = 'playlists.items';
returnAll = this.getNodeParameter('returnAll', i) as boolean;
const q = this.getNodeParameter('query', i) as string;
const filters = this.getNodeParameter('filters', i) as IDataObject;
qs = {
q,
type: 'playlist',
limit: 50,
...filters,
};
if (returnAll === false) {
const limit = this.getNodeParameter('limit', i) as number;
qs.limit = limit;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.playlists.items;
}
}
} else if (operation === 'search') {
requestMethod = 'GET';
} else if (resource === 'track') {
endpoint = '/search';
// -----------------------------
// Track Operations
// -----------------------------
propertyName = 'artists.items';
const uri = this.getNodeParameter('id', i, '') as string;
const id = uri.replace('spotify:track:', '');
requestMethod = 'GET';
if (operation === 'getAudioFeatures') {
endpoint = `/audio-features/${id}`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
} else if (operation === 'get') {
endpoint = `/tracks/${id}`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
} else if (operation === 'search') {
requestMethod = 'GET';
endpoint = '/search';
propertyName = 'tracks.items';
returnAll = this.getNodeParameter('returnAll', i) as boolean;
const q = this.getNodeParameter('query', i) as string;
const filters = this.getNodeParameter('filters', i) as IDataObject;
qs = {
q,
type: 'track',
limit: 50,
...filters,
};
if (returnAll === false) {
const limit = this.getNodeParameter('limit', i) as number;
qs.limit = limit;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.tracks.items;
}
}
} else if (resource === 'library') {
// -----------------------------
// Library Operations
// -----------------------------
if (operation === 'getLikedTracks') {
requestMethod = 'GET';
endpoint = '/me/tracks';
returnAll = this.getNodeParameter('returnAll', i) as boolean;
propertyName = 'items';
if (!returnAll) {
const limit = this.getNodeParameter('limit', i) as number;
returnAll = this.getNodeParameter('returnAll', i) as boolean;
const q = this.getNodeParameter('query', i) as string;
const filters = this.getNodeParameter('filters', i) as IDataObject;
qs = {
limit,
};
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.items;
}
}
} else if (resource === 'myData') {
if (operation === 'getFollowingArtists') {
requestMethod = 'GET';
endpoint = `/me/following`;
propertyName = 'artists.items';
if (!returnAll) {
const limit = this.getNodeParameter('limit', i) as number;
qs = {
q,
limit: 50,
type: 'artist',
limit,
...filters,
};
if (returnAll === false) {
const limit = this.getNodeParameter('limit', i) as number;
qs.limit = limit;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.artists.items;
}
}
} else if (resource === 'playlist') {
// -----------------------------
// Playlist Operations
// -----------------------------
if (['delete', 'get', 'getTracks', 'add'].includes(operation)) {
const uri = this.getNodeParameter('id', i) as string;
const id = uri.replace('spotify:playlist:', '');
if (operation === 'delete') {
requestMethod = 'DELETE';
const trackId = this.getNodeParameter('trackID', i) as string;
body.tracks = [
{
uri: trackId,
},
];
endpoint = `/playlists/${id}/tracks`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = { success: true };
} else if (operation === 'get') {
requestMethod = 'GET';
endpoint = `/playlists/${id}`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
} else if (operation === 'getTracks') {
requestMethod = 'GET';
endpoint = `/playlists/${id}/tracks`;
returnAll = this.getNodeParameter('returnAll', i) as boolean;
propertyName = 'items';
if (!returnAll) {
const limit = this.getNodeParameter('limit', i) as number;
qs = {
'limit': limit,
};
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.items;
}
} else if (operation === 'add') {
requestMethod = 'POST';
const trackId = this.getNodeParameter('trackID', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
qs = {
uris: trackId,
};
if (additionalFields.position !== undefined) {
qs.position = additionalFields.position;
}
endpoint = `/playlists/${id}/tracks`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
}
} else if (operation === 'getUserPlaylists') {
requestMethod = 'GET';
endpoint = '/me/playlists';
returnAll = this.getNodeParameter('returnAll', i) as boolean;
propertyName = 'items';
if (!returnAll) {
const limit = this.getNodeParameter('limit', i) as number;
qs = {
limit,
};
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.items;
}
} else if (operation === 'create') {
// https://developer.spotify.com/console/post-playlists/
body.name = this.getNodeParameter('name', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
if (Object.keys(additionalFields).length) {
Object.assign(body, additionalFields);
}
responseData = await spotifyApiRequest.call(this, 'POST', '/me/playlists', body, qs);
} else if (operation === 'search') {
requestMethod = 'GET';
endpoint = '/search';
propertyName = 'playlists.items';
returnAll = this.getNodeParameter('returnAll', i) as boolean;
const q = this.getNodeParameter('query', i) as string;
const filters = this.getNodeParameter('filters', i) as IDataObject;
qs = {
q,
type: 'playlist',
limit: 50,
...filters,
};
if (returnAll === false) {
const limit = this.getNodeParameter('limit', i) as number;
qs.limit = limit;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.playlists.items;
}
}
} else if (resource === 'track') {
// -----------------------------
// Track Operations
// -----------------------------
const uri = this.getNodeParameter('id', i, '') as string;
const id = uri.replace('spotify:track:', '');
requestMethod = 'GET';
if (operation === 'getAudioFeatures') {
endpoint = `/audio-features/${id}`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.artists.items;
} else if (operation === 'get') {
endpoint = `/tracks/${id}`;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
} else if (operation === 'search') {
requestMethod = 'GET';
endpoint = '/search';
propertyName = 'tracks.items';
returnAll = this.getNodeParameter('returnAll', i) as boolean;
const q = this.getNodeParameter('query', i) as string;
const filters = this.getNodeParameter('filters', i) as IDataObject;
qs = {
q,
type: 'track',
limit: 50,
...filters,
};
if (returnAll === false) {
const limit = this.getNodeParameter('limit', i) as number;
qs.limit = limit;
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.tracks.items;
}
}
} else if (resource === 'library') {
// -----------------------------
// Library Operations
// -----------------------------
if (operation === 'getLikedTracks') {
requestMethod = 'GET';
endpoint = '/me/tracks';
returnAll = this.getNodeParameter('returnAll', i) as boolean;
propertyName = 'items';
if (!returnAll) {
const limit = this.getNodeParameter('limit', i) as number;
qs = {
limit,
};
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.items;
}
}
} else if (resource === 'myData') {
if (operation === 'getFollowingArtists') {
requestMethod = 'GET';
endpoint = `/me/following`;
propertyName = 'artists.items';
if (!returnAll) {
const limit = this.getNodeParameter('limit', i) as number;
qs = {
type: 'artist',
limit,
};
responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.artists.items;
}
}
}
}
if (returnAll) {
responseData = await spotifyApiRequestAllItems.call(this, propertyName, requestMethod, endpoint, body, qs);
}
if (returnAll) {
responseData = await spotifyApiRequestAllItems.call(this, propertyName, requestMethod, endpoint, body, qs);
}
if (Array.isArray(responseData)) {
returnData.push.apply(returnData, responseData as IDataObject[]);
} else {
returnData.push(responseData as IDataObject);
if (Array.isArray(responseData)) {
returnData.push.apply(returnData, responseData as IDataObject[]);
} else {
returnData.push(responseData as IDataObject);
}
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ error: error.message });
continue;
}
throw error;
}
}
return [this.helpers.returnJsonArray(returnData)];
}
}