Exemple #1
0
 /// <summary>
 /// Resets all properties, because there is no real logging out from Todoist.com
 /// </summary>
 public void LogOff()
 {
     this.id              = 0;
     this.email           = string.Empty;
     this.fullName        = string.Empty;
     this.apiToken        = string.Empty;
     this.startPage       = new StartPage();
     this.timeZone        = null;
     this.timeZoneOffset  = new TimeZoneOffset();
     this.timeFormat      = new TimeFormat();
     this.dateFormat      = 0;
     this.sortOrder       = SortOrder.OldestDatesFirst;
     this.notifoAccount   = string.Empty;
     this.mobileNumber    = string.Empty;
     this.mobileHost      = string.Empty;
     this.premiumUntil    = string.Empty;
     this.defaultReminder = new DefaultReminder();
     this.jsonData        = string.Empty;
 }
Exemple #2
0
        /// <summary>
        /// The analyse json.
        /// </summary>
        private void AnalyseJson()
        {
            JObject o = JObject.Parse(this.JsonData);

            this.notifoAccount = (string)o.SelectToken("notifo");
            this.apiToken      = (string)o.SelectToken("api_token");
            switch ((int)o.SelectToken("time_format"))
            {
            case 0:
                this.timeFormat = TimeFormat.TwentyFourHourClock;
                break;

            case 1:
                this.timeFormat = TimeFormat.TwelveHourClock;
                break;
            }

            switch ((int)o.SelectToken("sort_order"))
            {
            case 0:
                this.sortOrder = SortOrder.OldestDatesFirst;
                break;

            case 1:
                this.sortOrder = SortOrder.NewestDatesFirst;
                break;
            }

            this.fullName     = (string)o.SelectToken("full_name");
            this.mobileNumber = (string)o.SelectToken("mobile_number");
            this.mobileHost   = (string)o.SelectToken("mobile_host");
            this.timeZone     = (string)o.SelectToken("timezone");

            this.id = (int)o.SelectToken("id");

            switch ((int)o.SelectToken("date_format"))
            {
            case 0:
                this.dateFormat = DateFormat.DdMmYyyy;
                break;

            case 1:
                this.dateFormat = DateFormat.MmDdYyyy;
                break;
            }

            this.premiumUntil = (string)o.SelectToken("premium_until");

            JToken timeZoneString = o.SelectToken("tz_offset");

            this.timeZoneOffset = new TimeZoneOffset(
                timeZoneString.First.Value <string>(),
                timeZoneString.First.Next.Value <int>(),
                timeZoneString.First.Next.Next.Value <int>(),
                timeZoneString.First.Next.Next.Next.Value <bool>());

            switch ((string)o.SelectToken("default_reminder"))
            {
            case "email":
                this.defaultReminder = DefaultReminder.Email;
                break;

            case "mobile":
                this.defaultReminder = DefaultReminder.Mobile;
                break;

            case "notifo":
                this.defaultReminder = DefaultReminder.Notifo;
                break;

            case "no_defalt":
                this.defaultReminder = DefaultReminder.NoDefault;
                break;
            }

            this.email = (string)o.SelectToken("email");
        }