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 <IList <GetHookData.Hook> > GetHooks(string href) { string folderId = ExtractFolderIdFromHref(href); if (string.IsNullOrWhiteSpace(folderId)) { return(null); } Credentials = await Credentials.FromSessionAsync(base.Request.Cookies, Response.Cookies); if (Credentials == null) { return(null); } DMWebhook webhooksApi = new DMWebhook(Credentials.TokenInternal, CallbackUrl); IList <GetHookData.Hook> hooks = await webhooksApi.Hooks(Event.VersionAdded, folderId); return(hooks); }