feat(Oura Node): Update node for v2 api (#11604)

This commit is contained in:
Jon
2024-11-07 11:53:05 +00:00
committed by GitHub
parent 20fd38f351
commit 3348fbb154
6 changed files with 299 additions and 80 deletions

View File

@@ -4,7 +4,7 @@ import type {
IHookFunctions,
ILoadOptionsFunctions,
JsonObject,
IRequestOptions,
IHttpRequestOptions,
IHttpRequestMethods,
} from 'n8n-workflow';
import { NodeApiError } from 'n8n-workflow';
@@ -18,15 +18,11 @@ export async function ouraApiRequest(
uri?: string,
option: IDataObject = {},
) {
const credentials = await this.getCredentials('ouraApi');
let options: IRequestOptions = {
headers: {
Authorization: `Bearer ${credentials.accessToken}`,
},
let options: IHttpRequestOptions = {
method,
qs,
body,
uri: uri || `https://api.ouraring.com/v1${resource}`,
url: uri ?? `https://api.ouraring.com/v2${resource}`,
json: true,
};
@@ -41,7 +37,7 @@ export async function ouraApiRequest(
options = Object.assign({}, options, option);
try {
return await this.helpers.request(options);
return await this.helpers.httpRequestWithAuthentication.call(this, 'ouraApi', options);
} catch (error) {
throw new NodeApiError(this.getNode(), error as JsonObject);
}