mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor: Add IRequestOptions type to helpers.request for more type safety (no-changelog) (#8563)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import type { OptionsWithUri } from 'request';
|
||||
|
||||
import type {
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
IHookFunctions,
|
||||
IHttpRequestMethods,
|
||||
ILoadOptionsFunctions,
|
||||
IRequestOptions,
|
||||
IWebhookFunctions,
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
@@ -20,12 +20,12 @@ import type {
|
||||
|
||||
export async function facebookApiRequest(
|
||||
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions,
|
||||
method: string,
|
||||
method: IHttpRequestMethods,
|
||||
resource: string,
|
||||
body = {},
|
||||
qs: IDataObject = {},
|
||||
): Promise<any> {
|
||||
const options: OptionsWithUri = {
|
||||
const options: IRequestOptions = {
|
||||
headers: {
|
||||
accept: 'application/json',
|
||||
},
|
||||
@@ -51,7 +51,7 @@ export async function appAccessTokenRead(
|
||||
): Promise<{ access_token: string }> {
|
||||
const credentials = await this.getCredentials('facebookLeadAdsOAuth2Api');
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
const options: IRequestOptions = {
|
||||
headers: {
|
||||
'content-type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
@@ -73,7 +73,7 @@ export async function appAccessTokenRead(
|
||||
|
||||
export async function facebookAppApiRequest(
|
||||
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions,
|
||||
method: string,
|
||||
method: IHttpRequestMethods,
|
||||
resource: string,
|
||||
body?: { type: 'json'; payload: IDataObject } | { type: 'form'; payload: IDataObject },
|
||||
qs: IDataObject = {},
|
||||
@@ -81,7 +81,7 @@ export async function facebookAppApiRequest(
|
||||
const tokenResponse = await appAccessTokenRead.call(this);
|
||||
const appAccessToken = tokenResponse.access_token;
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
const options: IRequestOptions = {
|
||||
headers: {
|
||||
accept: 'application/json',
|
||||
authorization: `Bearer ${appAccessToken}`,
|
||||
@@ -164,7 +164,7 @@ export async function facebookEntityDetail(
|
||||
|
||||
export async function facebookPageApiRequest(
|
||||
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions,
|
||||
method: string,
|
||||
method: IHttpRequestMethods,
|
||||
resource: string,
|
||||
body = {},
|
||||
qs: IDataObject = {},
|
||||
@@ -172,7 +172,7 @@ export async function facebookPageApiRequest(
|
||||
const pageId = this.getNodeParameter('page', '', { extractValue: true }) as string;
|
||||
const page = (await facebookEntityDetail.call(this, pageId)) as FacebookPage;
|
||||
const pageAccessToken = page.access_token;
|
||||
const options: OptionsWithUri = {
|
||||
const options: IRequestOptions = {
|
||||
headers: {
|
||||
accept: 'application/json',
|
||||
authorization: `Bearer ${pageAccessToken}`,
|
||||
|
||||
Reference in New Issue
Block a user