Beispiel #1
0
        /// <summary>
        /// See <see cref="INfieldExternalApisLogService.PostAsync"/>
        /// </summary>
        public Task <string> PostAsync(ExternalApiLogDownload logDownloadRequest)
        {
            Ensure.ArgumentNotNull(logDownloadRequest, nameof(logDownloadRequest));

            return(Client.PostAsJsonAsync(ExternalApiDownloadLogUri, logDownloadRequest)
                   .ContinueWith(task => task.Result.Content.ReadAsStringAsync().Result)
                   .ContinueWith(task => JsonConvert.DeserializeObject <BackgroundActivityStatus>(task.Result))
                   .ContinueWith(task => ConnectionClient.GetActivityResultAsync <string>(task.Result.ActivityId, "DownloadDataUrl").Result)
                   .FlattenExceptions());
        }
 public Task <int> DeleteAsync(string surveyId, int interviewId)
 {
     CheckSurveyId(surveyId);
     return(Client.DeleteAsync(InterviewsApiUri(surveyId, interviewId))
            .ContinueWith(
                responseMessageTask => responseMessageTask.Result.Content.ReadAsStringAsync().Result)
            .ContinueWith(stringResult =>
                          JsonConvert.DeserializeObject <BackgroundActivityStatus>(stringResult.Result).ActivityId)
            .ContinueWith(activityResult => ConnectionClient.GetActivityResultAsync <int>(activityResult.Result, "DeletedTotal"))
            .Unwrap()
            .FlattenExceptions());
 }
        private Task <int> ClearAsync(string surveyId, List <SampleFilter> filters, IEnumerable <string> columnsToClear)
        {
            var uri = new Uri(SurveySampleUrl(surveyId) + "Clear");

            var request = new ClearSurveySampleModel
            {
                Filters = filters,
                Columns = columnsToClear
            };

            return(Client.PutAsJsonAsync(uri, request)
                   .ContinueWith(responseMessageTask => responseMessageTask.Result.Content.ReadAsStringAsync().Result)
                   .ContinueWith(stringResult => JsonConvert.DeserializeObject <BackgroundActivityStatus>(stringResult.Result).ActivityId)
                   .ContinueWith(activityResult => ConnectionClient.GetActivityResultAsync <int>(activityResult.Result, "ClearTotal"))
                   .Unwrap()
                   .FlattenExceptions());
        }
        public Task <int> DeleteAsync(string surveyId, string respondentKey)
        {
            Ensure.ArgumentNotNullOrEmptyString(surveyId, nameof(surveyId));
            Ensure.ArgumentNotNullOrEmptyString(respondentKey, nameof(respondentKey));

            var uri     = SurveySampleUrl(surveyId);
            var filters = new List <SampleFilter>
            {
                new SampleFilter {
                    Name = RespondentKey, Op = "eq", Value = respondentKey
                }
            };

            return(Client.DeleteAsJsonAsync <IEnumerable <SampleFilter> >(uri, filters)
                   .ContinueWith(responseMessageTask => responseMessageTask.Result.Content.ReadAsStringAsync().Result)
                   .ContinueWith(stringResult => JsonConvert.DeserializeObject <BackgroundActivityStatus>(stringResult.Result).ActivityId)
                   .ContinueWith(activityResult => ConnectionClient.GetActivityResultAsync <int>(activityResult.Result, "DeletedTotal"))
                   .Unwrap()
                   .FlattenExceptions());
        }