Initial commit: n8n Strike API node
- Add Strike API credentials configuration - Implement Strike node with 9 resources (Account, Balance, Currency Exchange, Deposit, Invoice, Payment, Payment Method, Payout, Rates) - Add comprehensive operation descriptions for all resources - Include CLAUDE.MD documentation - Set up build configuration with TypeScript, ESLint, and Prettier 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
61
nodes/Strike/StrikeApi.ts
Normal file
61
nodes/Strike/StrikeApi.ts
Normal file
@ -0,0 +1,61 @@
|
||||
import type { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-workflow';
|
||||
import type { IDataObject, IHttpRequestMethods, IHttpRequestOptions } from 'n8n-workflow';
|
||||
|
||||
export async function strikeApiRequest(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions,
|
||||
method: IHttpRequestMethods,
|
||||
endpoint: string,
|
||||
body: IDataObject = {},
|
||||
query: IDataObject = {},
|
||||
): Promise<any> {
|
||||
const credentials = await this.getCredentials('strikeApi');
|
||||
|
||||
const baseUrl = credentials.environment === 'sandbox'
|
||||
? 'https://api.strike.me'
|
||||
: 'https://api.strike.me';
|
||||
|
||||
const options: IHttpRequestOptions = {
|
||||
method,
|
||||
url: `${baseUrl}/v1${endpoint}`,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body,
|
||||
qs: query,
|
||||
json: true,
|
||||
};
|
||||
|
||||
if (Object.keys(body).length === 0) {
|
||||
delete options.body;
|
||||
}
|
||||
|
||||
if (Object.keys(query).length === 0) {
|
||||
delete options.qs;
|
||||
}
|
||||
|
||||
return this.helpers.requestWithAuthentication.call(this, 'strikeApi', options);
|
||||
}
|
||||
|
||||
export async function strikeApiRequestAllItems(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
method: IHttpRequestMethods,
|
||||
endpoint: string,
|
||||
body: IDataObject = {},
|
||||
query: IDataObject = {},
|
||||
): Promise<any[]> {
|
||||
const returnData: any[] = [];
|
||||
let responseData;
|
||||
query.$top = query.$top || 100;
|
||||
query.$skip = 0;
|
||||
|
||||
do {
|
||||
responseData = await strikeApiRequest.call(this, method, endpoint, body, query);
|
||||
const items = responseData.items || responseData;
|
||||
if (Array.isArray(items)) {
|
||||
returnData.push(...items);
|
||||
}
|
||||
query.$skip += query.$top as number;
|
||||
} while (responseData.items && responseData.items.length === query.$top);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
Reference in New Issue
Block a user