/// <summary>
        /// Modify device information
        /// </summary>
        /// <param name="device">Which device to use.</param>
        /// <param name="includeEntitites">Set this to false to not add entitites to response. (default: true)</param>
        /// <returns></returns>
        public async Task <Account> UpdateDeliveryDeviceAsync(DeviceType device, bool?includeEntitites, CancellationToken cancelToken = default(CancellationToken))
        {
            var accountUrl = BaseUrl + "account/update_delivery_device.json";

            var reqProc = new AccountRequestProcessor <Account>();

            var parameters = new Dictionary <string, string>
            {
                { "device", device.ToString().ToLower() }
            };

            if (includeEntitites != null)
            {
                parameters.Add("include_entities", includeEntitites.ToString().ToLower());
            }

            RawResult =
                await TwitterExecutor.PostToTwitterAsync <Account>(
                    accountUrl,
                    parameters,
                    cancelToken)
                .ConfigureAwait(false);

            return(reqProc.ProcessActionResult(RawResult, AccountAction.Settings));
        }
Example #2
0
        /// <summary>
        /// Modify device information
        /// </summary>
        /// <param name="device">Which device to use.</param>
        /// <param name="includeEntitites">Set this to false to not add entitites to response. (default: true)</param>
        /// <param name="callback">Async Callback.</param>
        /// <returns></returns>
        public static Account UpdateDeliveryDevice(this TwitterContext ctx, DeviceType device, bool includeEntitites, Action <TwitterAsyncResponse <User> > callback)
        {
            var accountUrl = ctx.BaseUrl + "account/update_delivery_device.json";

            var reqProc = new AccountRequestProcessor <Account>();

            ITwitterExecute exec = ctx.TwitterExecutor;

            exec.AsyncCallback = callback;
            var resultsJson =
                exec.PostToTwitter(
                    accountUrl,
                    new Dictionary <string, string>
            {
                { "device", device.ToString().ToLower() },
                { "include_entities", includeEntitites.ToString().ToLower() }
            },
                    response => reqProc.ProcessActionResult(response, AccountAction.Settings));

            Account acct = reqProc.ProcessActionResult(resultsJson, AccountAction.Settings);

            return(acct);
        }
Example #3
0
        /// <summary>
        /// Updates user's account settings
        /// </summary>
        /// <param name="trendLocationWeoid">WEOID for Trend Location the user is interested in.</param>
        /// <param name="sleepTimeEnabled">Turn on time periods when notifications won't be sent.</param>
        /// <param name="startSleepTime">Don't send notifications at this time or later this time. (hour from 00 to 23)</param>
        /// <param name="endSleepTime">Start sending notifications again after this time. (hour from 00 to 23)</param>
        /// <param name="timeZone">User's time zone.</param>
        /// <param name="lang">User's language.</param>
        /// <param name="callback">Async Callback.</param>
        /// <returns>Account information with Settings property populated.</returns>
        public static Account UpdateAccountSettings(this TwitterContext ctx, int?trendLocationWoeid, bool?sleepTimeEnabled, int?startSleepTime, int?endSleepTime, string timeZone, string lang, Action <TwitterAsyncResponse <User> > callback)
        {
            var accountUrl = ctx.BaseUrl + "account/settings.json";

            if (trendLocationWoeid == null &&
                sleepTimeEnabled == null &&
                startSleepTime == null &&
                endSleepTime == null &&
                string.IsNullOrEmpty(timeZone) &&
                string.IsNullOrEmpty(lang))
            {
                throw new ArgumentException("At least one parameter must be provided as arguments, but none are specified.", NoInputParam);
            }

            var reqProc = new AccountRequestProcessor <Account>();

            ITwitterExecute exec = ctx.TwitterExecutor;

            exec.AsyncCallback = callback;
            var resultsJson =
                exec.PostToTwitter(
                    accountUrl,
                    new Dictionary <string, string>
            {
                { "trend_location_woeid", trendLocationWoeid.ToString() },
                { "sleep_time_enabled", sleepTimeEnabled.ToString() },
                { "start_sleep_time", startSleepTime.ToString() },
                { "end_sleep_time", endSleepTime.ToString() },
                { "time_zone", timeZone },
                { "lang", lang }
            },
                    response => reqProc.ProcessActionResult(response, AccountAction.Settings));

            Account acct = reqProc.ProcessActionResult(resultsJson, AccountAction.Settings);

            return(acct);
        }
Example #4
0
        /// <summary>
        /// Updates user's account settings
        /// </summary>
        /// <param name="trendLocationWeoid">WEOID for Trend Location the user is interested in.</param>
        /// <param name="sleepTimeEnabled">Turn on time periods when notifications won't be sent.</param>
        /// <param name="startSleepTime">Don't send notifications at this time or later this time. (hour from 00 to 23)</param>
        /// <param name="endSleepTime">Start sending notifications again after this time. (hour from 00 to 23)</param>
        /// <param name="timeZone">User's time zone.</param>
        /// <param name="lang">User's language.</param>
        /// <returns>Account information with Settings property populated.</returns>
        public async Task <Account> UpdateAccountSettingsAsync(int?trendLocationWoeid, bool?sleepTimeEnabled, int?startSleepTime, int?endSleepTime, string timeZone, string lang, CancellationToken cancelToken = default(CancellationToken))
        {
            var accountUrl = BaseUrl + "account/settings.json";

            if (trendLocationWoeid == null &&
                sleepTimeEnabled == null &&
                startSleepTime == null &&
                endSleepTime == null &&
                string.IsNullOrWhiteSpace(timeZone) &&
                string.IsNullOrWhiteSpace(lang))
            {
                throw new ArgumentException("At least one parameter must be provided as arguments, but none are specified.", NoInputParam);
            }

            var reqProc    = new AccountRequestProcessor <Account>();
            var parameters = new Dictionary <string, string>
            {
                { "time_zone", timeZone },
                { "lang", lang }
            };

            if (trendLocationWoeid != null)
            {
                parameters.Add("trend_location_woeid", trendLocationWoeid.ToString());
            }
            if (sleepTimeEnabled != null)
            {
                parameters.Add("sleep_time_enabled", sleepTimeEnabled.ToString().ToLower());
            }
            if (startSleepTime != null)
            {
                parameters.Add("start_sleep_time", startSleepTime.ToString());
            }
            if (endSleepTime != null)
            {
                parameters.Add("end_sleep_time", endSleepTime.ToString());
            }

            RawResult =
                await TwitterExecutor.PostFormUrlEncodedToTwitterAsync <Account>(
                    HttpMethod.Post.ToString(),
                    accountUrl,
                    parameters,
                    cancelToken)
                .ConfigureAwait(false);

            return(reqProc.ProcessActionResult(RawResult, AccountAction.Settings));
        }