public DnsimpleClient(string username, ApiToken token)
 {
     client = new DNSimpleRestClient(username, token);
 }
Ejemplo n.º 2
0
        private static void UpdateRecordIfNeeded(RecordUpdateRequest rur)
        {
            try
            {
                // Is the update request enabled?
                if (rur.Enabled)
                {
                    // Yes, so validate first
                    rur.Validate();

                    // Check if it is time to update...
                    bool bUpdate = true;
                    if (rur.LastUpdated.HasValue)
                    {
                        TimeSpan ts = DateTime.Now.Subtract(rur.LastUpdated.Value);
                        bUpdate = ts.TotalMinutes >= rur.UpdateFrequencyMinutes;
                    }

                    // Update?
                    if (bUpdate)
                    {
                        string pwd = null;
                        string tok = null;
                        if(rur.IsApiToken)
                        {
                            tok = rur.Password;
                        }
                        else
                        {
                            pwd = rur.Password;
                        }

                        DNSimple.DNSimpleRestClient c = new DNSimpleRestClient(rur.EmailAddress, pwd, tok);

                        rur.RecordContent = GetPublicIP();
                        dynamic ret = c.UpdateRecord(rur.Domain, rur.RecordId, rur.RecordName, rur.RecordContent);
                        rur.LastUpdated = DateTime.Now;
                    }
                }
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }
 public DnsimpleClient(string username, string password)
 {
     client = new DNSimpleRestClient(username, password);
 }