/// <summary> /// Validate the user entered the required data and in the correct format. /// </summary> protected override ValidationResult ValidateUI() { ValidationResult result = base.ValidateUI(); if (result.IsValid) { // Get list status IRestResponse <ListDataResponse> response = this.GetListResponse("CheckListStatus"); // Is the list ready? if (response.Data.success) { result.IsValid = true; } else { result.IsValid = false; result.AddErrorMsg("Your recipient list is not uploaded, or it's still processing."); } } return(result); }
/// <summary> /// Fetches and updates the Recipient List in an order where the Recipient List was set to RecipientListStatus UnderConstruction /// Used for delayed Recipient Lists that fetched after order submission. /// </summary> public override ValidationResult updateListFromProvider() { ValidationResult result = new ValidationResult(false); try { ListDataConfig config = ConfigUtils.LoadConfiguration(ConfigurationXML); // Call API URL to get list data string listId = ConfigUtils.GetListIdFromSelectionXml(SelectionXML); string listGUID = ConfigUtils.GetListGUIDFromSelectionXml(SelectionXML); // Call the API url to get the list RestClient client = new RestClient(config.ApiUrl); RestRequest request = new RestRequest("", Method.GET); request.AddParameter("action", "DownloadList"); request.AddParameter("externalTrackingType", "ListId"); request.AddParameter("externalTrackingId", listId); request.AddParameter("listGuid", listGUID); request.AddParameter("format", "uStore"); request.AddParameter("type", "xml"); // Execute the request IRestResponse <ListDataResponse> response = client.Execute <ListDataResponse>(request); // Is the list ready? if (response.Data.success && response.Data.list_count > 0) { // XML Format // // Important: Must contain <RecipitentList></RecipitentList> // for each record. The spelling is wrong but required // // <?xml version=\"1.0\" encoding=\"utf-16\"?> // <NewDataSet><RecipitentList><first>John</first></RecipitentList></NewDataSet> XmlDocument xml = new XmlDocument(); xml.LoadXml(response.Data.xml_data); RecipientListXML = xml; RecipientListStatus = uStoreStatus.StrStatus.Active; NumberOfRecipients = response.Data.list_count; // Save the recipient list to the uStore system SaveRecipientList(); // The returned ValidationResult should be set to true only if the recipient list is ready. // This is important in order to avoid moving the order out from Pending Recipient List queue. result.IsValid = true; // The following message is being logged by uStore. Not mandatory. result.AddInfoMsg("Recipient List plugin sample - delayed recipient list was successfully fetched."); } } catch (Exception e) { result.AddErrorMsg(e.Message); } return(result); }