public async Task <IActionResult> CreateHook([FromForm] HookInputData input) { string folderId = ExtractFolderIdFromHref(input.href); if (string.IsNullOrWhiteSpace(folderId)) { return(BadRequest()); } string projectId = ExtractProjectIdFromHref(input.href); if (string.IsNullOrWhiteSpace(projectId)) { return(BadRequest()); } Credentials = await Credentials.FromSessionAsync(base.Request.Cookies, Response.Cookies); if (Credentials == null) { return(Unauthorized()); } DMWebhook webhooksApi = new DMWebhook(Credentials.TokenInternal, CallbackUrl); await webhooksApi.CreateHook(Event.VersionAdded, projectId, folderId); return(Ok()); }
public async Task <IActionResult> CreateHook([FromForm] HookInputData input) { if (string.IsNullOrWhiteSpace(input.FolderId)) { return(BadRequest()); } if (string.IsNullOrWhiteSpace(input.ProjectId)) { return(BadRequest()); } if (string.IsNullOrWhiteSpace(input.HubId)) { return(BadRequest()); } Credentials = await Credentials.FromSessionAsync(base.Request.Cookies, Response.Cookies); if (Credentials == null) { return(Unauthorized()); } DMWebhook webhooksApi = new DMWebhook(Credentials.TokenInternal, CallbackUrl); await webhooksApi.CreateHook(Event.VersionAdded, input.ProjectId, input.FolderId, await webhooksApi.GetHubRegion(input.HubId)); return(Ok()); }