Update to webhook
This commit is contained in:
@@ -290,21 +290,14 @@ public class TradingController : BaseController
|
|||||||
|
|
||||||
var httpClient = _httpClientFactory.CreateClient();
|
var httpClient = _httpClientFactory.CreateClient();
|
||||||
|
|
||||||
// Create multipart form data content
|
|
||||||
using var content = new MultipartFormDataContent();
|
|
||||||
content.Add(new StringContent(request.IndicatorName), "field-0");
|
|
||||||
content.Add(new StringContent(request.StrategyDescription), "field-1");
|
|
||||||
content.Add(new StringContent(request.DocumentationUrl), "field-2");
|
|
||||||
content.Add(new StringContent(request.ImageUrl ?? string.Empty), "field-3");
|
|
||||||
content.Add(new StringContent(request.RequesterName), "field-4");
|
|
||||||
|
|
||||||
_logger.LogInformation(
|
_logger.LogInformation(
|
||||||
"Submitting indicator request: {IndicatorName} - {Strategy} by {Requester}",
|
"Submitting indicator request: {IndicatorName} - {Strategy} by {Requester}",
|
||||||
request.IndicatorName,
|
request.IndicatorName,
|
||||||
request.StrategyDescription,
|
request.StrategyDescription,
|
||||||
request.RequesterName);
|
request.RequesterName);
|
||||||
|
|
||||||
var response = await httpClient.PostAsync(webhookUrl, content);
|
// Send as JSON payload
|
||||||
|
var response = await httpClient.PostAsJsonAsync(webhookUrl, request);
|
||||||
|
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
},
|
},
|
||||||
"N8n": {
|
"N8n": {
|
||||||
"WebhookUrl": "https://n8n.kai.managing.live/webhook/fa9308b6-983b-42ec-b085-71599d655951",
|
"WebhookUrl": "https://n8n.kai.managing.live/webhook/fa9308b6-983b-42ec-b085-71599d655951",
|
||||||
"IndicatorRequestWebhookUrl": "https://n8n.kai.managing.live/form-test/c7dd294c-004e-4c0f-b4ce-42cc19734e0e"
|
"IndicatorRequestWebhookUrl": "https://n8n.kai.managing.live/webhook/3aa07b66-1e64-46a7-8618-af300914cb11"
|
||||||
},
|
},
|
||||||
"Sentry": {
|
"Sentry": {
|
||||||
"Dsn": "https://fe12add48c56419bbdfa86227c188e7a@glitch.kai.managing.live/1",
|
"Dsn": "https://fe12add48c56419bbdfa86227c188e7a@glitch.kai.managing.live/1",
|
||||||
|
|||||||
@@ -3595,6 +3595,50 @@ export class TradingClient extends AuthorizedApiBase {
|
|||||||
}
|
}
|
||||||
return Promise.resolve<PrivyInitAddressResponse>(null as any);
|
return Promise.resolve<PrivyInitAddressResponse>(null as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trading_RequestIndicator(request: IndicatorRequestDto): Promise<FileResponse> {
|
||||||
|
let url_ = this.baseUrl + "/Trading/RequestIndicator";
|
||||||
|
url_ = url_.replace(/[?&]$/, "");
|
||||||
|
|
||||||
|
const content_ = JSON.stringify(request);
|
||||||
|
|
||||||
|
let options_: RequestInit = {
|
||||||
|
body: content_,
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Accept": "application/octet-stream"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return this.transformOptions(options_).then(transformedOptions_ => {
|
||||||
|
return this.http.fetch(url_, transformedOptions_);
|
||||||
|
}).then((_response: Response) => {
|
||||||
|
return this.processTrading_RequestIndicator(_response);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected processTrading_RequestIndicator(response: Response): Promise<FileResponse> {
|
||||||
|
const status = response.status;
|
||||||
|
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
|
||||||
|
if (status === 200 || status === 206) {
|
||||||
|
const contentDisposition = response.headers ? response.headers.get("content-disposition") : undefined;
|
||||||
|
let fileNameMatch = contentDisposition ? /filename\*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/g.exec(contentDisposition) : undefined;
|
||||||
|
let fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[3] || fileNameMatch[2] : undefined;
|
||||||
|
if (fileName) {
|
||||||
|
fileName = decodeURIComponent(fileName);
|
||||||
|
} else {
|
||||||
|
fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
|
||||||
|
fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
|
||||||
|
}
|
||||||
|
return response.blob().then(blob => { return { fileName: fileName, data: blob, status: status, headers: _headers }; });
|
||||||
|
} else if (status !== 200 && status !== 204) {
|
||||||
|
return response.text().then((_responseText) => {
|
||||||
|
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return Promise.resolve<FileResponse>(null as any);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UserClient extends AuthorizedApiBase {
|
export class UserClient extends AuthorizedApiBase {
|
||||||
@@ -5058,6 +5102,14 @@ export interface PrivyInitAddressResponse {
|
|||||||
isAlreadyInitialized?: boolean;
|
isAlreadyInitialized?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IndicatorRequestDto {
|
||||||
|
indicatorName?: string;
|
||||||
|
strategyDescription?: string;
|
||||||
|
documentationUrl?: string;
|
||||||
|
imageUrl?: string | null;
|
||||||
|
requesterName?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface LoginRequest {
|
export interface LoginRequest {
|
||||||
name: string;
|
name: string;
|
||||||
address: string;
|
address: string;
|
||||||
|
|||||||
@@ -1233,6 +1233,14 @@ export interface PrivyInitAddressResponse {
|
|||||||
isAlreadyInitialized?: boolean;
|
isAlreadyInitialized?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IndicatorRequestDto {
|
||||||
|
indicatorName?: string;
|
||||||
|
strategyDescription?: string;
|
||||||
|
documentationUrl?: string;
|
||||||
|
imageUrl?: string | null;
|
||||||
|
requesterName?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface LoginRequest {
|
export interface LoginRequest {
|
||||||
name: string;
|
name: string;
|
||||||
address: string;
|
address: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user