private Uri SurveyPackageApi(string surveyId, InterviewPackageType interviewPackageType) { var uriText = new StringBuilder(ConnectionClient.NfieldServerUri.AbsoluteUri); uriText.AppendFormat("Surveys/{0}/Package/?type={1}", surveyId, interviewPackageType); return new Uri(uriText.ToString()); }
public System.Threading.Tasks.Task<SurveyPackage> GetSurveyPackageAsync(string surveyId, InterviewPackageType interviewPackageType) { ValidateParams(surveyId, interviewPackageType); return Client.GetAsync(SurveyPackageApi(surveyId, interviewPackageType).AbsoluteUri) .ContinueWith(task => task.Result.Content.ReadAsStringAsync().Result) .ContinueWith(task => JsonConvert.DeserializeObject<SurveyPackage>(task.Result)) .FlattenExceptions(); }
private static void ValidateParams(string surveyId, InterviewPackageType interviewPackageType) { if (surveyId == null) throw new ArgumentNullException("surveyId"); if (surveyId.Trim().Length == 0) throw new ArgumentException("surveyId cannot be empty"); if (interviewPackageType == InterviewPackageType.Unknown) throw new ArgumentException("package type cannot be Unknown"); }
private static void ValidateParams(string surveyId, InterviewPackageType interviewPackageType) { if (surveyId == null) { throw new ArgumentNullException("surveyId"); } if (surveyId.Trim().Length == 0) { throw new ArgumentException("surveyId cannot be empty"); } if (interviewPackageType == InterviewPackageType.Unknown) { throw new ArgumentException("package type cannot be Unknown"); } }
private Uri SurveyPackageApi(string surveyId, InterviewPackageType interviewPackageType) { return(new Uri(ConnectionClient.NfieldServerUri, $"Surveys/{surveyId}/Package/?type={interviewPackageType}")); }
public System.Threading.Tasks.Task <SurveyPackage> GetSurveyPackageAsync(string surveyId, InterviewPackageType interviewPackageType) { ValidateParams(surveyId, interviewPackageType); return(Client.GetAsync(SurveyPackageApi(surveyId, interviewPackageType)) .ContinueWith(task => task.Result.Content.ReadAsStringAsync().Result) .ContinueWith(task => JsonConvert.DeserializeObject <SurveyPackage>(task.Result)) .FlattenExceptions()); }