/// <summary> /// Retrieve the API key from App.Config and check if its valid /// </summary> public static string FeatchApiKey() { try { string apiKey = ConfigurationManager.AppSettings["MailChimpApiKey"]; if (!String.IsNullOrEmpty(apiKey)) { return(apiKey); } else { string msg = MailChimpExceptionMessage.NullOrEmptyMessage(CommandProperty.apikey); throw new MailChimpExceptions(msg); } } catch (NullReferenceException ex) { string message = "MailChimp API Key missing! To resolve Add a key named \'MailChimpApiKey\' in your config and SET its value with your mailchimp API key!"; throw new MailChimpExceptions(message); } catch (Exception ex) { throw new MailChimpExceptions(ex.Message); } }
/// <summary> /// Get the datacenter prefix based on the API key passed /// </summary> private static string GetDatacenterPrefix() { string apikey = FeatchApiKey(); // The key should contain a '-' if (!apikey.Contains('-')) { return(MailChimpExceptionMessage.InvalidMessage(CommandProperty.apikey)); } return(apikey.Split('-')[1]); }