async Task <R> Request <R>( string provider, HttpMethod method, string path, StepStoneToken token, Func <HttpResponseMessage, Task <R> > parse, object content = null) { var setting = this.settings.FirstOrDefault(s => string.Equals(s.Name, provider, StringComparison.OrdinalIgnoreCase)); if (setting == null || !token.Tokens.TryGetValue(setting.Name, out var auth)) { this.logger.LogError("Stepstone token not found for {Key}, available: {Tokens}", setting.Name, string.Join(", ", token.Tokens.Keys)); return(default); // Provider not authenticated
Task <SearchResponse> IStepStoneService.Search( StepStoneToken token, string source, SearchRequest search, bool includeFacets, bool includeCandidatesActivity) => this.RequestJson <SearchResponse>( source, HttpMethod.Post, includeFacets && includeCandidatesActivity ? "Search?includeFacets=true&includeCandidatesActivity=true" : includeFacets ? "Search?includeFacets=true" : includeCandidatesActivity ? "Search?includeCandidatesActivity=true" : "Search", token, this.Clean(search));
async Task <StepStoneCV> IStepStoneService.CV(StepStoneToken token, string source, long id) { var cvs = await(this as IStepStoneService).CV(token, source, new long[1] { id }); var cv = cvs.FirstOrDefault(c => c.ID == id); // Try for matching ID first if (cv != null) { return(cv); } cv = cvs.FirstOrDefault(); if (cv != null) { // If ID's mismatch assume that we failed to parse the file entry name, log warning and override this.logger.LogWarning("CV File ID not matched: {Expected}!={Actual} {FileName}", id, cv.ID, cv.Filename); cv.ID = id; } return(cv); }
/// <summary>Request data from the StepStone API and parse the response as JSON.</summary> /// <typeparam name="R">The result type to expect.</typeparam> /// <param name="provider">The name of the source provider in the settings.</param> /// <param name="method">The HTTP verb to use.</param> /// <param name="path">The action to call (no "/" at start).</param> /// <param name="content">Optional content to send if POST</param> /// <param name="token">Security details for the StepStone session.</param> /// <returns>The response from the action.</returns> Task <R> RequestJson <R>( string provider, HttpMethod method, string path, StepStoneToken token, object content = null) => this.Request(provider, method, path, token, r => r.Content.ReadAsAsync <R>(SearchMediaFormatter), content);
Task <QuotaResponse> IStepStoneService.Quota(StepStoneToken token, string source) => this.RequestJson <QuotaResponse>(source, HttpMethod.Get, "Usage/Quota", token);
Task <IEnumerable <string> > IStepStoneService.Dictionary(StepStoneToken token, string source, StepStoneDictionary dictionary) => this.RequestJson <IEnumerable <string> >( source, HttpMethod.Get, $"Dictionary/{dictionary.ToString()}", token);
Task <IEnumerable <StepStoneCV> > IStepStoneService.CV(StepStoneToken token, string source, long[] ids) => this.Request( source, HttpMethod.Get, $"cv/{string.Join(',', ids)}", token, ZipResponseUtility.ParseCV);
Task <FoundCandidate> IStepStoneService.Candidate(StepStoneToken token, string source, long id) => this.RequestJson <FoundCandidate>( source, HttpMethod.Get, $"Candidate/{id}", token);