Esempio n. 1
0
        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
Esempio n. 2
0
 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));
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 /// <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);
Esempio n. 5
0
 Task <QuotaResponse> IStepStoneService.Quota(StepStoneToken token, string source) =>
 this.RequestJson <QuotaResponse>(source, HttpMethod.Get, "Usage/Quota", token);
Esempio n. 6
0
 Task <IEnumerable <string> > IStepStoneService.Dictionary(StepStoneToken token, string source, StepStoneDictionary dictionary) =>
 this.RequestJson <IEnumerable <string> >(
     source, HttpMethod.Get, $"Dictionary/{dictionary.ToString()}", token);
Esempio n. 7
0
 Task <IEnumerable <StepStoneCV> > IStepStoneService.CV(StepStoneToken token, string source, long[] ids) =>
 this.Request(
     source, HttpMethod.Get, $"cv/{string.Join(',', ids)}", token, ZipResponseUtility.ParseCV);
Esempio n. 8
0
 Task <FoundCandidate> IStepStoneService.Candidate(StepStoneToken token, string source, long id) =>
 this.RequestJson <FoundCandidate>(
     source, HttpMethod.Get, $"Candidate/{id}", token);