mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
Add subreddit search functionality
This commit is contained in:
parent
3f810629c4
commit
49001ce789
|
@ -10,6 +10,7 @@ import {
|
|||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
import { queryString } from '../TheHive/QueryFunctions';
|
||||
|
||||
|
||||
/**
|
||||
|
@ -101,7 +102,9 @@ export async function handleListing(
|
|||
return await redditApiRequestAllItems.call(this, 'GET', endpoint, {}, {}, true);
|
||||
}
|
||||
|
||||
const qs: IDataObject = { limit: this.getNodeParameter('limit', i) };
|
||||
const qs: IDataObject = {
|
||||
limit: this.getNodeParameter('limit', i),
|
||||
};
|
||||
responseData = await redditApiRequestAllItems.call(this, 'GET', endpoint, qs, {}, true);
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
|
||||
|
|
|
@ -210,6 +210,15 @@ export class Reddit implements INodeType {
|
|||
|
||||
}
|
||||
|
||||
} else if (operation === 'search') {
|
||||
|
||||
const endpoint = `api/search_reddit_names.json`;
|
||||
const qs: IDataObject = {
|
||||
query: this.getNodeParameter('keyword', i),
|
||||
};
|
||||
|
||||
responseData = await redditApiRequest.call(this, 'GET', endpoint, qs, {}, true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,9 @@ export const subredditOperations = [
|
|||
] as INodeProperties[];
|
||||
|
||||
export const subredditFields = [
|
||||
// ----------------------------------
|
||||
// get: subreddit
|
||||
// ----------------------------------
|
||||
{
|
||||
displayName: 'Content',
|
||||
name: 'content',
|
||||
|
@ -153,4 +156,66 @@ export const subredditFields = [
|
|||
},
|
||||
},
|
||||
},
|
||||
// ----------------------------------
|
||||
// search: subreddit
|
||||
// ----------------------------------
|
||||
{
|
||||
displayName: 'Keyword',
|
||||
name: 'keyword',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
description: 'The keyword for the subreddit name search',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'subreddit',
|
||||
],
|
||||
operation: [
|
||||
'search',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Return all results',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'subreddit',
|
||||
],
|
||||
operation: [
|
||||
'search',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
default: 5,
|
||||
description: 'The number of results to return',
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 100,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'subreddit',
|
||||
],
|
||||
operation: [
|
||||
'search',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
|
Loading…
Reference in a new issue