internal RequestSettings Serialize() { var parameters = new RequestSettings(); if (String.IsNullOrEmpty(Email)) { throw new ArgumentException("A recipient email address cannot be empty"); } parameters.Add("email", Email); if (!String.IsNullOrEmpty(FirstName)) { parameters.Add("first_name", FirstName); } if (!String.IsNullOrEmpty(LastName)) { parameters.Add("last_name", LastName); } if (!String.IsNullOrEmpty(CustomId)) { parameters.Add("custom_id", CustomId); } return(parameters); }
internal RequestSettings Serialize() { var parameters = new RequestSettings(); if (StartDate != DateTime.MaxValue) { parameters.Add("start_date", StartDate.ToString("yyyy-MM-dd HH':'mm':'ss")); } if (EndDate != DateTime.MinValue) { parameters.Add("end_date", EndDate.ToString("yyyy-MM-dd HH':'mm':'ss")); } if (!String.IsNullOrEmpty(Name)) { parameters.Add("name", Name); } if (OrderAsc.HasValue) { parameters.Add("order_asc", OrderAsc.Value); } parameters.Add("fields", new List <string> { "url", "open", "type", "name", "date_created", "date_modified" }); return(parameters); }
internal RequestSettings Serialize() { if (String.IsNullOrEmpty(SurveyTitle) || String.IsNullOrEmpty(SurveyNickname)) { throw new ArgumentException("SurveyTitle and SurveyNickname must both be populated."); } if ((TemplateId == 0 && FromSurveyId == 0) || (TemplateId > 0 && FromSurveyId > 0)) { throw new ArgumentException("You must populate either TemplateId or FromSurveyId, and not both."); } var parameters = new RequestSettings(); if (TemplateId != 0) { parameters.Add("template_id", TemplateId.ToString()); } if (FromSurveyId != 0) { parameters.Add("from_survey_id", FromSurveyId.ToString()); } parameters.Add("survey_title", SurveyTitle); parameters.Add("survey_nickname", SurveyNickname); if (LanguageId != Language.NotSet) { parameters.Add("language_id", (int)LanguageId); } return(parameters); }
internal RequestSettings Serialize() { var parameters = new RequestSettings(); parameters.Add("collector", Collector.Serialize()); parameters.Add("email_message", EmailMessage.Serialize()); return(parameters); }
private List<Survey> GetSurveyListPage(int page, int pageSize, bool limitPageSize, GetSurveyListSettings settings) { RequestSettings parameters = settings.Serialized; parameters.Add("page", page); if (limitPageSize) { parameters.Add("page_size", pageSize); } return GetSurveyListRequest(parameters); }
private List<Respondent> GetRespondentListPage(long surveyId, int page, int pageSize, bool limitPageSize, GetRespondentListSettings settings) { RequestSettings parameters = settings.Serialized; parameters.Add("survey_id", surveyId.ToString()); parameters.Add("page", page); if (limitPageSize) { parameters.Add("page_size", pageSize); } return GetRespondentListRequest(parameters); }
private List <Template> GetTemplateListPage(int page, int pageSize, bool limitPageSize, GetTemplateListSettings settings) { RequestSettings parameters = settings.Serialize(); parameters.Add("page", page); if (limitPageSize) { parameters.Add("page_size", pageSize); } return(GetTemplateListRequest(parameters)); }
private List <Collector> GetCollectorListPage(long surveyId, int page, int pageSize, bool limitPageSize, GetCollectorListSettings settings) { RequestSettings parameters = settings.Serialize(); parameters.Add("survey_id", surveyId.ToString()); parameters.Add("page", page); if (limitPageSize) { parameters.Add("page_size", pageSize); } return(GetCollectorListRequest(parameters)); }
public List <Response> GetResponses(long surveyId, List <long> respondents) { try { const string endPoint = "/surveys/get_responses"; var parameters = new RequestSettings(); parameters.Add("survey_id", surveyId.ToString()); parameters.Add("respondent_ids", respondents.Select(r => r.ToString())); var o = MakeApiRequest(endPoint, parameters); List <Response> responses = o.ToObject <List <Response> >(); return(responses); } catch (Exception e) { throw new SurveyMonkeyException("Error communicating with endpoint", e); } }
internal RequestSettings Serialize() { var parameters = new RequestSettings(); parameters.Add("reply_email", ReplyEmail); parameters.Add("subject", Subject); if (!String.IsNullOrEmpty(BodyText)) { parameters.Add("body_text", BodyText); } if (DisableFooter.HasValue) { parameters.Add("disable_footer", DisableFooter); } return(parameters); }
/// <summary> /// Create tabs. /// </summary> private void _initializeTabs() { RequestSettings.Add(new OverviewWidget(ActiveRequest), Director.Properties.Resources.RequestOverview); RequestSettings.Add(new HeaderList(ActiveRequest.Headers, ActiveRequest.ParentScenario), Director.Properties.Resources.RequestHeaders); RequestSettings.Add(new FileList(ActiveRequest.Files), Director.Properties.Resources.RequestFiles); RequestSettings.Add(new RequestWidget(ActiveRequest), Director.Properties.Resources.RequestTab); RequestSettings.Add(new ResponseWidget(ActiveRequest), Director.Properties.Resources.RequestResponse); }
public Collector CreateCollector(long surveyId, CreateCollectorSettings settings) { var parameters = new RequestSettings(); parameters.Add("survey_id", surveyId.ToString()); parameters.Add("collector", settings.Serialize()); try { const string endPoint = "/collectors/create_collector"; var o = MakeApiRequest(endPoint, parameters); Collector collector = o["collector"].ToObject <Collector>(); return(collector); } catch (Exception e) { throw new SurveyMonkeyException("Error communicating with endpoint", e); } }
internal RequestSettings Serialize() { var parameters = new RequestSettings(); if (!String.IsNullOrEmpty(Name)) { parameters.Add("name", Name); } if (!String.IsNullOrEmpty(ThankYouMessage)) { parameters.Add("thank_you_message", ThankYouMessage); } if (!String.IsNullOrEmpty(RedirectUrl)) { parameters.Add("redirect_url", RedirectUrl); } parameters.Add("type", "weblink"); return(parameters); }
public CreateRecipientsResponse CreateRecipients(long collectorId, long emailMessageId, List <Recipient> recipients) { var parameters = new RequestSettings(); parameters.Add("collector_id", collectorId.ToString()); parameters.Add("email_message_id", emailMessageId.ToString()); parameters.Add("send", true); parameters.Add("recipients", recipients.Select(r => r.Serialize())); try { const string endPoint = "/collectors/create_recipients"; var o = MakeApiRequest(endPoint, parameters); var response = new CreateRecipientsResponse(); response.Collector = o["collector"].ToObject <Collector>(); response.RecipientsReport = o["recipients_report"].ToObject <RecipientsReport>(); return(response); } catch (Exception e) { throw new SurveyMonkeyException("Error communicating with endpoint", e); } }
//TODO: deal with account upgrade notifications //Auto-paging public List<Respondent> GetRespondentList(long surveyId, GetRespondentListSettings settings) { var respondents = new List<Respondent>(); bool cont = true; int page = 1; while (cont) { RequestSettings parameters = settings.Serialized; parameters.Add("survey_id", surveyId.ToString()); parameters.Add("page", page); var newRespondents = GetRespondentListRequest(parameters); if (newRespondents.Count > 0) { respondents.AddRange(newRespondents); } if (newRespondents.Count < 1000) { cont = false; } page++; } return respondents; }
internal RequestSettings Serialize() { var parameters = new RequestSettings(); if (LanguageId != Language.NotSet) { parameters.Add("language_id", (int)LanguageId); } if (CategoryId != 0) { parameters.Add("category_id", CategoryId.ToString()); } if (ShowOnlyAvailableToCurrentUser.HasValue) { parameters.Add("show_only_available_to_current_user", ShowOnlyAvailableToCurrentUser.Value); } parameters.Add("fields", new List <string> { "language_id", "title", "short_description", "long_description", "is_available_to_current_user", "is_featured", "is_certified", "page_count", "question_count", "preview_url", "category_id", "category_name", "category_description", "date_modified", "date_created" }); return(parameters); }
//Auto-paging public List <Collector> GetCollectorList(long surveyId, GetCollectorListSettings settings) { var collectors = new List <Collector>(); bool cont = true; int page = 1; while (cont) { RequestSettings parameters = settings.Serialize(); parameters.Add("survey_id", surveyId.ToString()); parameters.Add("page", page); var newCollectors = GetCollectorListRequest(parameters); if (newCollectors.Count > 0) { collectors.AddRange(newCollectors); } if (newCollectors.Count < 1000) { cont = false; } page++; } return(collectors); }
public Collector GetResponseCounts(long collectorId) { try { const string endPoint = "/surveys/get_response_counts"; var parameters = new RequestSettings(); parameters.Add("collector_id", collectorId.ToString()); var o = MakeApiRequest(endPoint, parameters); Collector collector = o.ToObject<Collector>(); return collector; } catch (Exception e) { throw new SurveyMonkeyException("Error communicating with endpoint", e); } }
public Survey GetSurveyDetails(long surveyId) { try { const string endPoint = "/surveys/get_survey_details"; var parameters = new RequestSettings(); parameters.Add("survey_id", surveyId.ToString()); var o = MakeApiRequest(endPoint, parameters); JsonDeserializeGetSurveyDetails rawSurvey = o.ToObject<JsonDeserializeGetSurveyDetails>(); Survey survey = rawSurvey.ToSurvey(); return survey; } catch (Exception e) { throw new SurveyMonkeyException("Error communicating with endpoint", e); } }
//Auto-paging public List<Survey> GetSurveyList(GetSurveyListSettings settings) { var surveys = new List<Survey>(); bool cont = true; int page = 1; while (cont) { RequestSettings parameters = settings.Serialized; parameters.Add("page", page); var newSurveys = GetSurveyListRequest(parameters); if (newSurveys.Count > 0) { surveys.AddRange(newSurveys); } if (newSurveys.Count < 1000) { cont = false; } page++; } return surveys; }
internal RequestSettings Serialize() { var parameters = new RequestSettings(); if (StartDate != DateTime.MaxValue) { parameters.Add("start_date", StartDate.ToString("yyyy-MM-dd HH':'mm':'ss")); } if (EndDate != DateTime.MinValue) { parameters.Add("end_date", EndDate.ToString("yyyy-MM-dd HH':'mm':'ss")); } if (!String.IsNullOrEmpty(Title)) { parameters.Add("title", Title); } if (!String.IsNullOrEmpty(RecipientEmail)) { parameters.Add("recipient_email", RecipientEmail); } if (OrderAsc.HasValue) { parameters.Add("order_asc", OrderAsc.Value); } parameters.Add("fields", new List <string> { "title", "analysis_url", "preview_url", "date_created", "date_modified", "language_id", "question_count", "num_responses" }); return(parameters); }
internal RequestSettings Serialize() { var parameters = new RequestSettings(); parameters.Add("type", "email"); //only email collectors are supported if (!String.IsNullOrEmpty(Name)) { parameters.Add("name", Name); } if (!String.IsNullOrEmpty(ThankYouMessage)) { parameters.Add("thank_you_message", ThankYouMessage); } if (!String.IsNullOrEmpty(RedirectUrl)) { parameters.Add("redirect_url", RedirectUrl); } parameters.Add("recipients", Recipients.Select(r => r.Serialize())); parameters.Add("send", true); return(parameters); }
public Collector GetResponseCounts(long collectorId) { try { const string endPoint = "/surveys/get_response_counts"; var parameters = new RequestSettings(); parameters.Add("collector_id", collectorId.ToString()); var o = MakeApiRequest(endPoint, parameters); Collector collector = o.ToObject<Collector>(); return collector; } catch (Exception e) { throw new SurveyMonkeyException("Error communicating with endpoint", e); } }
private List<Response> GetResponsesRequest(long surveyId, List<long> respondents) { try { const string endPoint = "/surveys/get_responses"; var parameters = new RequestSettings(); parameters.Add("survey_id", surveyId.ToString()); parameters.Add("respondent_ids", respondents.Select(r => r.ToString())); var o = MakeApiRequest(endPoint, parameters); List<Response> responses = o.ToObject<List<Response>>(); return responses; } catch (Exception e) { throw new SurveyMonkeyException("Error communicating with endpoint", e); } }
private RecipientReport CreateRecipients(long collectorId, List<Recipient> recipients, object settings) { RequestSettings parameters = new RequestSettings(); parameters.Add("collector_id", collectorId.ToString()); parameters.Add("recipients", recipients); return CreateRecipientsRequest(parameters); }
public Survey GetSurveyDetails(long surveyId) { try { const string endPoint = "/surveys/get_survey_details"; var parameters = new RequestSettings(); parameters.Add("survey_id", surveyId.ToString()); var o = MakeApiRequest(endPoint, parameters); JsonDeserializeGetSurveyDetails rawSurvey = o.ToObject<JsonDeserializeGetSurveyDetails>(); Survey survey = rawSurvey.ToSurvey(); return survey; } catch (Exception e) { throw new SurveyMonkeyException("Error communicating with endpoint", e); } }
internal RequestSettings Serialize() { var parameters = new RequestSettings(); if (CollectorId != 0) { parameters.Add("collector_id", CollectorId.ToString()); } if (StartDate != DateTime.MaxValue) { parameters.Add("start_date", StartDate.ToString("yyyy-MM-dd HH':'mm':'ss")); } if (EndDate != DateTime.MinValue) { parameters.Add("end_date", EndDate.ToString("yyyy-MM-dd HH':'mm':'ss")); } if (StartModifiedDate != DateTime.MaxValue) { parameters.Add("start_modified_date", StartModifiedDate.ToString("yyyy-MM-dd HH':'mm':'ss")); } if (EndModifiedDate != DateTime.MinValue) { parameters.Add("end_modified_date", EndModifiedDate.ToString("yyyy-MM-dd HH':'mm':'ss")); } if (OrderAsc.HasValue) { parameters.Add("order_asc", OrderAsc.Value); } if (OrderBy != Order.NotSet) { string orderByString = ""; if (OrderBy == Order.RespondentId) { orderByString = "respondent_id"; } if (OrderBy == Order.DateStart) { orderByString = "date_start"; } if (OrderBy == Order.DateModified) { orderByString = "date_modified"; } parameters.Add("order_by", orderByString); } parameters.Add("fields", new List <string> { "date_start", "date_modified", "collector_id", "collection_mode", "custom_id", "email", "first_name", "last_name", "ip_address", "status", "analysis_url", "recipient_id" }); return(parameters); }