UmbracoFlare.Manager.CloudflareManager.PurgeEverything C# (CSharp) Method

PurgeEverything() public method

public PurgeEverything ( string domain ) : StatusWithMessage
domain string
return UmbracoFlare.Models.StatusWithMessage
        public StatusWithMessage PurgeEverything(string domain)
        {
            //If the setting is turned off, then don't do anything.
            if (!CloudflareConfiguration.Instance.PurgeCacheOn) return new StatusWithMessage() { Success = false, Message = "Clould flare for umbraco is turned of as indicated in the config file." };

            //We only want the host and not the scheme or port number so just to ensure that is what we are getting we will
            //proccess it as a uri.
            Uri domainAsUri;
            try
            {
                domainAsUri= new Uri(domain);
                domain = domainAsUri.Authority;
            }
            catch(Exception e)
            {
                //So if we are here it didn't parse as an uri so we will assume that it was given in the correct format (without http://)
            }

            //Get the zone for the given domain
            Zone websiteZone = GetZone(domain);

            if (websiteZone == null)
            {
                //this will already be logged in the GetZone method so just relay that it was bad.
                return new StatusWithMessage(false, String.Format("We could not purge the cache because the domain {0} is not valid with the provided api key and email combo. Please ensure this domain is registered under these credentials on your cloudflare dashboard.", domain));
            }

            bool statusFromApi = this._api.PurgeCache(websiteZone.Id, null, true);

            if(!statusFromApi)
            {
                return new StatusWithMessage(false, CloudflareMessages.CLOUDFLARE_API_ERROR);
            }
            else
            {
                return new StatusWithMessage(true, "");
            }
        }