Matt Hamilton avatar Matt Hamilton committed 8b3411a

1.1.0

Comments (0)

Files changed (24)

 <?xml version="1.0"?>
 <package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd">
   <metadata>
-    <version>1.0.1</version>
+    <version>1.1.0</version>
     <authors>mabster</authors>
     <owners>Matt Hamilton</owners>
     <licenseUrl>http://www.opensource.org/licenses/ms-pl.html</licenseUrl>

Budgie/Entities/TwitterEntityCollection.cs

             Hashtags = new List<TwitterHashtag>();
         }
 
+        IEnumerator<TwitterEntity> Enumerator
+        {
+            get
+            {
+                return Media.AsEnumerable<TwitterEntity>()
+                    .Concat(Urls)
+                    .Concat(Mentions)
+                    .Concat(Hashtags)
+                    .OrderBy(e => e.Indices.Item1)
+                    .GetEnumerator();
+            }
+        }
+
         public IEnumerable<TwitterMedia> Media { get; internal set; }
         public IEnumerable<TwitterUrl> Urls { get; internal set; }
         public IEnumerable<TwitterMention> Mentions { get; internal set; }
 
         public IEnumerator<TwitterEntity> GetEnumerator()
         {
-            return Media.AsEnumerable<TwitterEntity>().Concat(Urls).Concat(Mentions).Concat(Hashtags).OrderBy(e => e.Indices.Item1).GetEnumerator();
+            return Enumerator;
         }
 
         System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
         {
-            return Media.AsEnumerable<TwitterEntity>().Concat(Urls).Concat(Mentions).Concat(Hashtags).OrderBy(e => e.Indices.Item1).GetEnumerator();
+            return Enumerator;
         }
     }
 }

Budgie/Extensions/WebResponseExtensions.cs

 using System.IO;
 using System.Net;
 using System.Threading.Tasks;
+using Budgie.Json;
 using Newtonsoft.Json;
-using Budgie.Json;
 
 namespace Budgie.Extensions
 {
     internal static class WebResponseExtensions
     {
+        public static Task<ITwitterResponse<T>> RespondWith<T>(this Task<WebResponse> task, Func<String, T> resultFactory)
+        {
+            return task.ContinueWith<ITwitterResponse<T>>(t =>
+            {
+                var result = t.ToTwitterResponse<T>();
+                if (result.StatusCode != System.Net.HttpStatusCode.OK) return result;
+
+                result.Result = resultFactory(result.RawContent);
+                return result;
+            });
+        }
+
         public static TwitterResponse<T> ToTwitterResponse<T>(this Task<WebResponse> task, T result = default(T))
         {
-
             if (task.IsFaulted)
             {
                 var message = (task.Exception.InnerException ?? task.Exception).Message;
                         }
                         catch
                         {
-                            // the content wasn't valid josn, so just report the exception
+                            // the content wasn't valid json, so just report the exception
                         }
                     }
                 }
                 {
                     StatusCode = HttpStatusCode.InternalServerError,
                     ErrorMessage = message,
-
                 };
             }
 
                 };
             }
 
-            var hr = response as HttpWebResponse;
-            if (hr != null)
-            {
-                tr.StatusCode = hr.StatusCode;
-                tr.ErrorMessage = hr.StatusDescription;
-            }
+            tr.StatusCode = response.StatusCode;
+            tr.ErrorMessage = response.StatusDescription;
             tr.RawContent = response.GetContentString();
             tr.Result = result;
 

Budgie/Json/JsonDirectMessage.cs

         public JsonUser recipient { get; set; }
         public JsonEntityCollection entities { get; set; }
 
-        public static explicit operator TwitterStatus(JsonDirectMessage j)
+        public static implicit operator TwitterStatus(JsonDirectMessage j)
         {
             return new TwitterStatus
             {

Budgie/Json/JsonError.cs

-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
+
 namespace Budgie.Json
 {
     internal class JsonError

Budgie/Json/JsonMedia.cs

 using System;
-using System.Collections.Generic;
-using System.Linq;
 using Budgie.Entities;
 
 namespace Budgie.Json

Budgie/Json/JsonSavedSearch.cs

         public DateTime created_at { get; set; }
         public string query { get; set; }
 
-        public static explicit operator TwitterSavedSearch(JsonSavedSearch j)
+        public static implicit operator TwitterSavedSearch(JsonSavedSearch j)
         {
             return new TwitterSavedSearch
             {

Budgie/Json/JsonStatus.cs

         public JsonStatus retweeted_status { get; set; }
         public JsonEntityCollection entities { get; set; }
 
-        public static explicit operator TwitterStatus(JsonStatus j)
+        public static implicit operator TwitterStatus(JsonStatus j)
         {
             var status = new TwitterStatus
             {

Budgie/Json/JsonUser.cs

         public int followers_count { get; set; }
         public int statuses_count { get; set; }
 
-        public static explicit operator TwitterUser(JsonUser j)
+        public static implicit operator TwitterUser(JsonUser j)
         {
             var user = new TwitterUser
             {

Budgie/TwitterAnonymousClient.Friendships.cs

-using System.Collections.Concurrent;
+using System;
+using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.Net;
 using System.Threading.Tasks;
 namespace Budgie
 {
     using IdsResponse = ITwitterResponse<IEnumerable<long>>;
-    using System;
 
     partial class TwitterAnonymousClient
     {

Budgie/TwitterAnonymousClient.Http.cs

 using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
+using System.IO;
 using System.Net;
 using System.Threading.Tasks;
-using System.IO;
 
 namespace Budgie
 {

Budgie/TwitterAnonymousClient.Lists.cs

-using System.Collections.Concurrent;
+using System;
+using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.Net;
 using System.Threading.Tasks;
 namespace Budgie
 {
     using ListsResponse = ITwitterResponse<IEnumerable<TwitterList>>;
-    using System;
 
     partial class TwitterAnonymousClient
     {
             return GetListsByCursor(relativeUri);
         }
 
-        public Task<ITwitterResponse<IEnumerable<TwitterStatus>>> GetListTimelineAsync(long id, int? count = null, long? since = null)
+        public Task<ITwitterResponse<IEnumerable<TwitterStatus>>> GetListTimelineAsync(long id, int? count = null, long? since = null, long? max = null)
         {
-            return GetTimelineAsync("lists/statuses.json?list_id=" + id, count, since);
+            return GetTimelineAsync("lists/statuses.json?list_id=" + id, count, since, max);
         }
     }
 }

Budgie/TwitterAnonymousClient.Timelines.cs

 
 namespace Budgie
 {
-    using TimelineResponse = Budgie.ITwitterResponse<IEnumerable<TwitterStatus>>;
+    using TimelineResponse = ITwitterResponse<IEnumerable<TwitterStatus>>;
 
     partial class TwitterAnonymousClient
     {
-        protected Task<TimelineResponse> GetTimelineAsync(string relativeUri, int? count, long? since)
+        protected Task<TimelineResponse> GetTimelineAsync(string relativeUri, int? count, long? since, long? max)
         {
             relativeUri += (relativeUri.Contains("?") ? "&" : "?")
                 + "include_entities=true&count=" + (count ?? DefaultPageSize);
 
             if (since.HasValue) relativeUri += "&since_id=" + since;
+            if (max.HasValue) relativeUri += "&max_id=" + max;
 
-            return HttpGetAsync(relativeUri).ContinueWith<TimelineResponse>(t =>
-            {
-                var result = t.ToTwitterResponse<IEnumerable<TwitterStatus>>();
-                if (result.StatusCode != HttpStatusCode.OK) return result;
-
-                result.Result = JsonConvert.DeserializeObject<IEnumerable<JsonStatus>>(result.RawContent, new TwitterizerDateConverter())
+            return HttpGetAsync(relativeUri).RespondWith<IEnumerable<TwitterStatus>>(content =>
+                JsonConvert.DeserializeObject<IEnumerable<JsonStatus>>(content, new TwitterizerDateConverter())
                     .Select(j => (TwitterStatus)j)
-                    .ToList();
-                return result;
-            });
+                    .ToList());
         }
 
-        public virtual Task<TimelineResponse> GetUserTimelineAsync(string screenName, int? count = null, long? since = null)
+        public virtual Task<TimelineResponse> GetUserTimelineAsync(string screenName, int? count = null, long? since = null, long? max = null)
         {
             if (string.IsNullOrWhiteSpace(screenName)) throw new ArgumentException("screenName must be specified", "screenName");
 
-            return GetTimelineAsync("statuses/user_timeline.json?screen_name=" + Encode(screenName), count, since);
+            return GetTimelineAsync("statuses/user_timeline.json?screen_name=" + Encode(screenName), count, since, max);
         }
 
-        public Task<TimelineResponse> GetRetweetsToUserAsync(string screenName, int? count = null, long? since = null)
+        public Task<TimelineResponse> GetRetweetsToUserAsync(string screenName, int? count = null, long? since = null, long? max = null)
         {
             if (string.IsNullOrWhiteSpace(screenName)) throw new ArgumentException("screenName must be specified", "screenName");
 
-            return GetTimelineAsync("statuses/retweeted_to_user.json?screen_name=" + Encode(screenName), count, since);
+            return GetTimelineAsync("statuses/retweeted_to_user.json?screen_name=" + Encode(screenName), count, since, max);
         }
 
-        public Task<TimelineResponse> GetRetweetsByUserAsync(string screenName, int? count = null, long? since = null)
+        public Task<TimelineResponse> GetRetweetsByUserAsync(string screenName, int? count = null, long? since = null, long? max = null)
         {
             if (string.IsNullOrWhiteSpace(screenName)) throw new ArgumentException("screenName must be specified", "screenName");
 
-            return GetTimelineAsync("statuses/retweeted_by_user.json?screen_name=" + Encode(screenName), count, since);
+            return GetTimelineAsync("statuses/retweeted_by_user.json?screen_name=" + Encode(screenName), count, since, max);
         }
     }
 }

Budgie/TwitterAnonymousClient.Tweets.cs

 
 namespace Budgie
 {
-    using UsersResponse = ITwitterResponse<IEnumerable<TwitterUser>>;
-    using StatusResponse = ITwitterResponse<TwitterStatus>;
-
     partial class TwitterAnonymousClient
     {
-        public Task<StatusResponse> GetStatusAsync(long statusId)
+        public Task<ITwitterResponse<TwitterStatus>> GetStatusAsync(long statusId)
         {
             var relativeUri = "statuses/show/" + statusId + ".json?include_entities=true";
 
-            return HttpGetAsync(relativeUri).ContinueWith<StatusResponse>(t =>
-            {
-                var result = t.ToTwitterResponse<TwitterStatus>();
-                if (result.StatusCode != HttpStatusCode.OK) return result;
-
-                result.Result = (TwitterStatus)JsonConvert.DeserializeObject<JsonStatus>(result.RawContent, new TwitterizerDateConverter());
-                return result;
-            });
+            return HttpGetAsync(relativeUri).RespondWith<TwitterStatus>(content =>
+                JsonConvert.DeserializeObject<JsonStatus>(content, new TwitterizerDateConverter()));
         }
 
-        public Task<UsersResponse> GetRetweetersAsync(long statusId, int? count = null)
+        public Task<ITwitterResponse<IEnumerable<TwitterUser>>> GetRetweetersAsync(long statusId, int? count = null)
         {
             var relativeUri = "statuses/" + statusId + "/retweeted_by.json";
             if (count.HasValue) relativeUri += "?count=" + count;
 
-            return HttpGetAsync(relativeUri).ContinueWith<UsersResponse>(t =>
-            {
-                var result = t.ToTwitterResponse<IEnumerable<TwitterUser>>();
-                if (result.StatusCode != HttpStatusCode.OK) return result;
-
-                result.Result = JsonConvert.DeserializeObject<IEnumerable<JsonUser>>(result.RawContent, new TwitterizerDateConverter())
+            return HttpGetAsync(relativeUri).RespondWith<IEnumerable<TwitterUser>>(content =>
+                JsonConvert.DeserializeObject<IEnumerable<JsonUser>>(content, new TwitterizerDateConverter())
                     .Select(j => (TwitterUser)j)
-                    .ToList();
-                return result;
-            });
+                    .ToList());
         }
     }
 }

Budgie/TwitterAnonymousClient.Users.cs

 
 namespace Budgie
 {
-    using UserResponse = ITwitterResponse<TwitterUser>;
-    using UsersResponse = ITwitterResponse<IEnumerable<TwitterUser>>;
-
     partial class TwitterAnonymousClient
     {
-        public Task<UsersResponse> LookupUsersAsync(IEnumerable<long> ids)
+        public Task<ITwitterResponse<IEnumerable<TwitterUser>>> LookupUsersAsync(IEnumerable<long> ids)
         {
             var count = ids.Count();
             var users = new ConcurrentBag<TwitterUser>();
             var page = 0;
             var pageSize = 99;
 
-            return HttpPostAsync("users/lookup.json", "user_id=" + String.Join(",", ids.Take(pageSize))).ContinueWith<UsersResponse>(t =>
+            return HttpPostAsync("users/lookup.json", "user_id=" + String.Join(",", ids.Take(pageSize))).ContinueWith<ITwitterResponse<IEnumerable<TwitterUser>>>(t =>
             {
                 while (true)
                 {
             });
         }
 
-        public Task<UserResponse> GetUserAsync(string screenName)
+        public Task<ITwitterResponse<TwitterUser>> GetUserAsync(string screenName)
         {
             if (string.IsNullOrWhiteSpace(screenName)) throw new ArgumentException("screenName must be specified", "screenName");
 
-            return HttpGetAsync("users/show.json?screen_name=" + Encode(screenName)).ContinueWith<UserResponse>(t =>
-            {
-                var result = t.ToTwitterResponse<TwitterUser>();
-                if (result.StatusCode != HttpStatusCode.OK) return result;
-
-                result.Result = (TwitterUser)JsonConvert.DeserializeObject<JsonUser>(result.RawContent, new TwitterizerDateConverter());
-                return result;
-            });
+            return HttpGetAsync("users/show.json?screen_name=" + Encode(screenName)).RespondWith<TwitterUser>(content =>
+                JsonConvert.DeserializeObject<JsonUser>(content, new TwitterizerDateConverter()));
         }
     }
 }

Budgie/TwitterClient.DirectMessages.cs

 using System.Linq;
 using System.Threading.Tasks;
 using Budgie.Extensions;
+using System.Net;
+using Budgie.Json;
+using Newtonsoft.Json;
 
 namespace Budgie
 {
-    using System.Net;
-    using Budgie.Json;
-    using Newtonsoft.Json;
-    // just for brevity
-    using DirectMessagesResponse = ITwitterResponse<IEnumerable<TwitterStatus>>;
-    using DirectMessageResponse = ITwitterResponse<TwitterStatus>;
-
     partial class TwitterClient
     {
-        Task<DirectMessagesResponse> GetMessagesAsync(string relativeUri, int? count, long? since)
+        Task<ITwitterResponse<IEnumerable<TwitterStatus>>> GetMessagesAsync(string relativeUri, int? count, long? since)
         {
             relativeUri += (relativeUri.Contains("?") ? "&" : "?") + "include_entities=true&count=" + (count ?? DefaultPageSize);
 
             if (since.HasValue) relativeUri += "&since_id=" + since;
 
-            return HttpGetAsync(relativeUri).ContinueWith<DirectMessagesResponse>(t =>
-            {
-                var result = t.ToTwitterResponse<IEnumerable<TwitterStatus>>();
-                if (result.StatusCode != HttpStatusCode.OK) return result;
-
-                result.Result = JsonConvert.DeserializeObject<IEnumerable<JsonDirectMessage>>(result.RawContent, new TwitterizerDateConverter())
+            return HttpGetAsync(relativeUri).RespondWith<IEnumerable<TwitterStatus>>(content =>
+                JsonConvert.DeserializeObject<IEnumerable<JsonDirectMessage>>(content, new TwitterizerDateConverter())
                     .Select(j => (TwitterStatus)j)
-                    .ToList();
-                return result;
-            });
+                    .ToList());
         }
 
-        public Task<DirectMessagesResponse> GetDirectMessagesAsync(int? count = null, long? since = null)
+        public Task<ITwitterResponse<IEnumerable<TwitterStatus>>> GetDirectMessagesAsync(int? count = null, long? since = null)
         {
             return GetMessagesAsync("direct_messages.json", count, since);
         }
 
-        public Task<DirectMessagesResponse> GetDirectMessagesSentAsync(int? count = null, long? since = null)
+        public Task<ITwitterResponse<IEnumerable<TwitterStatus>>> GetDirectMessagesSentAsync(int? count = null, long? since = null)
         {
             return GetMessagesAsync("direct_messages/sent.json", count, since);
         }
 
-        public Task<DirectMessageResponse> GetDirectMessageAsync(long id)
+        public Task<ITwitterResponse<TwitterStatus>> GetDirectMessageAsync(long id)
         {
             var relativeUri = "direct_messages/show/" + id + ".json?include_entities=true";
 
-            return HttpGetAsync(relativeUri).ContinueWith<DirectMessageResponse>(t =>
-            {
-                var result = t.ToTwitterResponse<TwitterStatus>();
-                if (result.StatusCode != HttpStatusCode.OK) return result;
-
-                result.Result = (TwitterStatus)JsonConvert.DeserializeObject<JsonDirectMessage>(result.RawContent, new TwitterizerDateConverter());
-                return result;
-            });
+            return HttpGetAsync(relativeUri).RespondWith<TwitterStatus>(content =>
+                JsonConvert.DeserializeObject<JsonDirectMessage>(content, new TwitterizerDateConverter()));
         }
 
-        public Task<DirectMessageResponse> SendDirectMessageAsync(string screenName, string text)
+        public Task<ITwitterResponse<TwitterStatus>> SendDirectMessageAsync(string screenName, string text)
         {
             var relativeUri = "direct_messages/new.json";
-            var content = "screen_name=" + Encode(screenName) + "&text=" + Encode(text);
+            var parms = "screen_name=" + Encode(screenName) + "&text=" + Encode(text);
 
-            return HttpPostAsync(relativeUri, content).ContinueWith<DirectMessageResponse>(t =>
-            {
-                var result = t.ToTwitterResponse<TwitterStatus>();
-                if (result.StatusCode != HttpStatusCode.OK) return result;
-
-                result.Result = (TwitterStatus)JsonConvert.DeserializeObject<JsonDirectMessage>(result.RawContent, new TwitterizerDateConverter());
-                return result;
-            });
+            return HttpPostAsync(relativeUri, parms).RespondWith<TwitterStatus>(content =>
+                JsonConvert.DeserializeObject<JsonDirectMessage>(content, new TwitterizerDateConverter()));
         }
 
-        public Task<DirectMessageResponse> DeleteDirectMessageAsync(long id)
+        public Task<ITwitterResponse<TwitterStatus>> DeleteDirectMessageAsync(long id)
         {
             var relativeUri = "direct_messages/destroy/" + id + ".json?include_entities=true";
 
-            return HttpPostAsync(relativeUri).ContinueWith<DirectMessageResponse>(t =>
-            {
-                var result = t.ToTwitterResponse<TwitterStatus>();
-                if (result.StatusCode != HttpStatusCode.OK) return result;
-
-                result.Result = (TwitterStatus)JsonConvert.DeserializeObject<JsonStatus>(result.RawContent, new TwitterizerDateConverter());
-                return result;
-            });
+            return HttpPostAsync(relativeUri).RespondWith<TwitterStatus>(content =>
+                JsonConvert.DeserializeObject<JsonStatus>(content, new TwitterizerDateConverter()));
         }
     }
 }

Budgie/TwitterClient.Favorites.cs

-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
+using System.Collections.Generic;
 using System.Threading.Tasks;
 using Budgie.Extensions;
 using Budgie.Json;
 {
     partial class TwitterClient
     {
-        public Task<ITwitterResponse<IEnumerable<TwitterStatus>>> GetFavoritesAsync(int? count = null, long? since = null)
+        public Task<ITwitterResponse<IEnumerable<TwitterStatus>>> GetFavoritesAsync(int? count = null, long? since = null, long? max = null)
         {
-            return GetTimelineAsync("favorites.json", count, since);
+            return GetTimelineAsync("favorites.json", count, since, max);
         }
 
         public Task<ITwitterResponse<TwitterStatus>> FavouriteAsync(long id)
         {
-            return HttpPostAsync("favorites/create/" + id + ".json", "include_entities=true").ContinueWith<ITwitterResponse<TwitterStatus>>(t =>
-            {
-                var result = t.ToTwitterResponse<TwitterStatus>();
-                if (result.StatusCode != System.Net.HttpStatusCode.OK) return result;
-
-                result.Result = (TwitterStatus)JsonConvert.DeserializeObject<JsonStatus>(result.RawContent, new TwitterizerDateConverter());
-                return result;
-            });
+            return HttpPostAsync("favorites/create/" + id + ".json", "include_entities=true")
+                .RespondWith<TwitterStatus>(content => JsonConvert.DeserializeObject<JsonStatus>(content, new TwitterizerDateConverter()));
         }
 
         public Task<ITwitterResponse<TwitterStatus>> UnfavouriteAsync(long id)
         {
-            return HttpPostAsync("favorites/destroy/" + id + ".json").ContinueWith<ITwitterResponse<TwitterStatus>>(t =>
-            {
-                var result = t.ToTwitterResponse<TwitterStatus>();
-                if (result.StatusCode != System.Net.HttpStatusCode.OK) return result;
-
-                result.Result = (TwitterStatus)JsonConvert.DeserializeObject<JsonStatus>(result.RawContent, new TwitterizerDateConverter());
-                return result;
-            });
+            return HttpPostAsync("favorites/destroy/" + id + ".json")
+                .RespondWith<TwitterStatus>(content => JsonConvert.DeserializeObject<JsonStatus>(content, new TwitterizerDateConverter()));
         }
     }
 }

Budgie/TwitterClient.Friendships.cs

-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.Net;
+using System.Collections.Generic;
 using System.Threading.Tasks;
 using Budgie.Extensions;
 using Budgie.Json;
 
 namespace Budgie
 {
-    using IdsResponse = ITwitterResponse<IEnumerable<long>>;
-    using UserResponse = ITwitterResponse<TwitterUser>;
-
     partial class TwitterClient
     {
-        public Task<IdsResponse> GetFollowerIdsAsync()
+        public Task<ITwitterResponse<IEnumerable<long>>> GetFollowerIdsAsync()
         {
             return GetIdsByCursor("followers/ids.json");
         }
 
-        public Task<IdsResponse> GetFriendIdsAsync()
+        public Task<ITwitterResponse<IEnumerable<long>>> GetFriendIdsAsync()
         {
             return GetIdsByCursor("friends/ids.json");
         }
 
-        public Task<UserResponse> FollowAsync(string screenName)
+        public Task<ITwitterResponse<TwitterUser>> FollowAsync(string screenName)
         {
-            return HttpPostAsync("friendships/create.json", "screen_name=" + Encode(screenName)).ContinueWith<UserResponse>(t =>
-            {
-                var result = t.ToTwitterResponse<TwitterUser>();
-                if (result.StatusCode != HttpStatusCode.OK) return result;
-
-                result.Result = (TwitterUser)JsonConvert.DeserializeObject<JsonUser>(result.RawContent, new TwitterizerDateConverter());
-                return result;
-            });
+            return HttpPostAsync("friendships/create.json", "screen_name=" + Encode(screenName)).RespondWith<TwitterUser>(content =>
+                JsonConvert.DeserializeObject<JsonUser>(content, new TwitterizerDateConverter()));
         }
 
-        public Task<UserResponse> UnfollowAsync(string screenName)
+        public Task<ITwitterResponse<TwitterUser>> UnfollowAsync(string screenName)
         {
-            return HttpPostAsync("friendships/destroy.json", "screen_name=" + Encode(screenName)).ContinueWith<UserResponse>(t =>
-            {
-                var result = t.ToTwitterResponse<TwitterUser>();
-                if (result.StatusCode != HttpStatusCode.OK) return result;
-
-                result.Result = (TwitterUser)JsonConvert.DeserializeObject<JsonUser>(result.RawContent, new TwitterizerDateConverter());
-                return result;
-            });
+            return HttpPostAsync("friendships/destroy.json", "screen_name=" + Encode(screenName)).RespondWith<TwitterUser>(content =>
+                JsonConvert.DeserializeObject<JsonUser>(content, new TwitterizerDateConverter()));
         }
     }
 }

Budgie/TwitterClient.Lists.cs

-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net;
+using System.Collections.Generic;
 using System.Threading.Tasks;
-using Budgie.Extensions;
-using Budgie.Json;
-using Newtonsoft.Json;
 
 namespace Budgie
 {
-    using ListsResponse = ITwitterResponse<IEnumerable<TwitterList>>;
-
     partial class TwitterClient
     {
-        public override Task<ListsResponse> GetListsAsync(string screenName = null)
+        public override Task<ITwitterResponse<IEnumerable<TwitterList>>> GetListsAsync(string screenName = null)
         {
             return base.GetListsAsync(screenName);
         }
 
-        public Task<ListsResponse> GetUserListsAsync()
+        public Task<ITwitterResponse<IEnumerable<TwitterList>>> GetUserListsAsync()
         {
             return GetListsByCursor("lists.json");
         }
 
-        public Task<ListsResponse> GetListMembershipsAsync()
+        public Task<ITwitterResponse<IEnumerable<TwitterList>>> GetListMembershipsAsync()
         {
             return GetListsByCursor("lists/memberships.json");
         }

Budgie/TwitterClient.OAuth.cs

 using System;
+using System.Collections.Generic;
 using System.Linq;
-using System.IO;
 using System.Net;
 using System.Security.Cryptography;
 using System.Text;
-using System.Collections.Generic;
 using System.Threading.Tasks;
 using Budgie.Extensions;
+using Budgie.Json;
 using Newtonsoft.Json;
-using Budgie.Json;
 
 namespace Budgie
 {

Budgie/TwitterClient.SavedSearches.cs

-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
 using System.Linq;
-using System.Net;
 using System.Threading.Tasks;
 using Budgie.Extensions;
 using Budgie.Json;
 
 namespace Budgie
 {
-    using SavedSearchesResponse = ITwitterResponse<IEnumerable<TwitterSavedSearch>>;
-    using SavedSearchResponse = ITwitterResponse<TwitterSavedSearch>;
-
 	partial class TwitterClient
 	{
-        public Task<SavedSearchesResponse> GetSavedSearchesAsync()
+        public Task<ITwitterResponse<IEnumerable<TwitterSavedSearch>>> GetSavedSearchesAsync()
         {
-            return HttpGetAsync("saved_searches.json").ContinueWith<SavedSearchesResponse>(t =>
-            {
-                var result = t.ToTwitterResponse<IEnumerable<TwitterSavedSearch>>();
-                if (result.StatusCode != HttpStatusCode.OK) return result;
-
-                result.Result = JsonConvert.DeserializeObject<IEnumerable<JsonSavedSearch>>(result.RawContent, new TwitterizerDateConverter())
+            return HttpGetAsync("saved_searches.json").RespondWith<IEnumerable<TwitterSavedSearch>>(content =>
+                JsonConvert.DeserializeObject<IEnumerable<JsonSavedSearch>>(content, new TwitterizerDateConverter())
                     .Select(j => (TwitterSavedSearch)j)
-                    .ToList();
-                return result;
-            });
+                    .ToList());
         }
 
-        public Task<SavedSearchResponse> CreateSavedSearchAsync(string query)
+        public Task<ITwitterResponse<TwitterSavedSearch>> CreateSavedSearchAsync(string query)
         {
-            return HttpPostAsync("saved_searches/create.json", "query=" + Encode(query)).ContinueWith<SavedSearchResponse>(t =>
-            {
-                var result = t.ToTwitterResponse<TwitterSavedSearch>();
-                if (result.StatusCode != HttpStatusCode.OK) return result;
-
-                result.Result = (TwitterSavedSearch)JsonConvert.DeserializeObject<JsonSavedSearch>(result.RawContent, new TwitterizerDateConverter());
-                return result;
-            });
+            return HttpPostAsync("saved_searches/create.json", "query=" + Encode(query)).RespondWith<TwitterSavedSearch>(content =>
+                JsonConvert.DeserializeObject<JsonSavedSearch>(content, new TwitterizerDateConverter()));
         }
 
-        public Task<SavedSearchResponse> DeleteSavedSearchAsync(long id)
+        public Task<ITwitterResponse<TwitterSavedSearch>> DeleteSavedSearchAsync(long id)
         {
-            return HttpPostAsync("saved_searches/destroy/" + id + ".json").ContinueWith<SavedSearchResponse>(t =>
-            {
-                var result = t.ToTwitterResponse<TwitterSavedSearch>();
-                if (result.StatusCode != HttpStatusCode.OK) return result;
-
-                result.Result = (TwitterSavedSearch)JsonConvert.DeserializeObject<JsonSavedSearch>(result.RawContent, new TwitterizerDateConverter());
-                return result;
-            });
+            return HttpPostAsync("saved_searches/destroy/" + id + ".json").RespondWith<TwitterSavedSearch>(content =>
+                JsonConvert.DeserializeObject<JsonSavedSearch>(content, new TwitterizerDateConverter()));
         }
     }
 }

Budgie/TwitterClient.Timelines.cs

-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net;
+using System.Collections.Generic;
 using System.Threading.Tasks;
-using Budgie.Extensions;
-using Budgie.Json;
-using Newtonsoft.Json;
 
 namespace Budgie
 {
 
 	partial class TwitterClient
 	{
-        public Task<TimelineResponse> GetHomeTimelineAsync(int? count = null, long? since = null)
+        public Task<TimelineResponse> GetHomeTimelineAsync(int? count = null, long? since = null, long? max = null)
         {
-            return GetTimelineAsync("statuses/home_timeline.json", count, since);
+            return GetTimelineAsync("statuses/home_timeline.json", count, since, max);
         }
 
-        public Task<TimelineResponse> GetUserTimelineAsync(int? count = null, long? since = null)
+        public Task<TimelineResponse> GetUserTimelineAsync(int? count = null, long? since = null, long? max = null)
         {
-            return GetTimelineAsync("statuses/user_timeline.json", count, since);
+            return GetTimelineAsync("statuses/user_timeline.json", count, since, max);
         }
 
-        public Task<TimelineResponse> GetMentionsAsync(int? count = null, long? since = null)
+        public Task<TimelineResponse> GetMentionsAsync(int? count = null, long? since = null, long? max = null)
         {
-            return GetTimelineAsync("statuses/mentions.json", count, since);
+            return GetTimelineAsync("statuses/mentions.json", count, since, max);
         }
 
-        public Task<TimelineResponse> GetRetweetsByMeAsync(int? count = null, long? since = null)
+        public Task<TimelineResponse> GetRetweetsByMeAsync(int? count = null, long? since = null, long? max = null)
         {
-            return GetTimelineAsync("statuses/retweeted_by_me.json", count, since);
+            return GetTimelineAsync("statuses/retweeted_by_me.json", count, since, max);
         }
 
-        public Task<TimelineResponse> GetRetweetsToMeAsync(int? count = null, long? since = null)
+        public Task<TimelineResponse> GetRetweetsToMeAsync(int? count = null, long? since = null, long? max = null)
         {
-            return GetTimelineAsync("statuses/retweeted_to_me.json", count, since);
+            return GetTimelineAsync("statuses/retweeted_to_me.json", count, since, max);
         }
 
-        public Task<TimelineResponse> GetRetweetsOfMeAsync(int? count = null, long? since = null)
+        public Task<TimelineResponse> GetRetweetsOfMeAsync(int? count = null, long? since = null, long? max = null)
         {
-            return GetTimelineAsync("statuses/retweets_of_me.json", count, since);
+            return GetTimelineAsync("statuses/retweets_of_me.json", count, since, max);
         }
     }
 }

Budgie/TwitterClient.Tweets.cs

         {
             var relativeUri = "statuses/destroy/" + id + ".json?include_entities=true";
 
-            return HttpPostAsync(relativeUri).ContinueWith<StatusResponse>(t =>
-            {
-                var result = t.ToTwitterResponse<TwitterStatus>();
-                if (result.StatusCode != HttpStatusCode.OK) return result;
-
-                result.Result = (TwitterStatus)JsonConvert.DeserializeObject<JsonStatus>(result.RawContent, new TwitterizerDateConverter());
-                return result;
-            });
+            return HttpPostAsync(relativeUri).RespondWith<TwitterStatus>(content =>
+                JsonConvert.DeserializeObject<JsonStatus>(content, new TwitterizerDateConverter()));
         }
 
         public Task<StatusResponse> RetweetAsync(long id)
         {
             var relativeUri = "statuses/retweet/" + id + ".json?include_entities=true";
 
-            return HttpPostAsync(relativeUri).ContinueWith<StatusResponse>(t =>
-            {
-                var result = t.ToTwitterResponse<TwitterStatus>();
-                if (result.StatusCode != HttpStatusCode.OK) return result;
-
-                result.Result = (TwitterStatus)JsonConvert.DeserializeObject<JsonStatus>(result.RawContent, new TwitterizerDateConverter());
-                return result;
-            });
+            return HttpPostAsync(relativeUri).RespondWith<TwitterStatus>(content =>
+                JsonConvert.DeserializeObject<JsonStatus>(content, new TwitterizerDateConverter()));
         }
 
         public Task<StatusResponse> PostAsync(string text)
         {
             var relativeUri = "statuses/update.json";
+            var parms = "include_entities=true&status=" + Encode(text);
 
-            var content = "include_entities=true&status=" + Encode(text);
-
-            return HttpPostAsync(relativeUri, content).ContinueWith<StatusResponse>(t =>
-            {
-                var result = t.ToTwitterResponse<TwitterStatus>();
-                if (result.StatusCode != HttpStatusCode.OK) return result;
-
-                result.Result = (TwitterStatus)JsonConvert.DeserializeObject<JsonStatus>(result.RawContent, new TwitterizerDateConverter());
-                return result;
-            });
+            return HttpPostAsync(relativeUri, parms).RespondWith<TwitterStatus>(content =>
+                JsonConvert.DeserializeObject<JsonStatus>(content, new TwitterizerDateConverter()));
         }
 
         public Task<StatusResponse> ReplyToAsync(long id, string text)
         {
             var relativeUri = "statuses/update.json";
+            var parms = "include_entities=true&in_reply_to_status_id=" + id + "&status=" + Encode(text);
 
-            var content = "include_entities=true&in_reply_to_status_id=" + id + "&status=" + Encode(text);
-
-            return HttpPostAsync(relativeUri, content).ContinueWith<StatusResponse>(t =>
-            {
-                var result = t.ToTwitterResponse<TwitterStatus>();
-                if (result.StatusCode != HttpStatusCode.OK) return result;
-
-                result.Result = (TwitterStatus)JsonConvert.DeserializeObject<JsonStatus>(result.RawContent, new TwitterizerDateConverter());
-                return result;
-            });
+            return HttpPostAsync(relativeUri, parms).RespondWith<TwitterStatus>(content =>
+                JsonConvert.DeserializeObject<JsonStatus>(content, new TwitterizerDateConverter()));
         }
     }
 }

Budgie/TwitterClient.Users.cs

 using System.Collections.Generic;
 using System.Linq;
-using System.Net;
 using System.Threading.Tasks;
 using Budgie.Extensions;
 using Budgie.Json;
 
 namespace Budgie
 {
-    using UserResponse = ITwitterResponse<TwitterUser>;
-    using UsersResponse = ITwitterResponse<IEnumerable<TwitterUser>>;
-   
     partial class TwitterClient
     {
-        public Task<UsersResponse> FindUsersAsync(string query, int? count = null)
+        public Task<ITwitterResponse<IEnumerable<TwitterUser>>> FindUsersAsync(string query, int? count = null)
         {
-            return HttpGetAsync("users/search.json?per_page=" + (count ?? DefaultPageSize)).ContinueWith<UsersResponse>(t =>
-            {
-                var result = t.ToTwitterResponse<IEnumerable<TwitterUser>>();
-                if (result.StatusCode != HttpStatusCode.OK) return result;
-
-                result.Result = JsonConvert.DeserializeObject<IEnumerable<JsonUser>>(result.RawContent, new TwitterizerDateConverter())
+            return HttpGetAsync("users/search.json?per_page=" + (count ?? DefaultPageSize)).RespondWith<IEnumerable<TwitterUser>>(content =>
+                JsonConvert.DeserializeObject<IEnumerable<JsonUser>>(content, new TwitterizerDateConverter())
                     .Select(u => (TwitterUser)u)
-                    .ToList();
-                return result;
-            });
+                    .ToList());
         }
 
-        public Task<UserResponse> ReportSpammerAsync(string screenName)
+        public Task<ITwitterResponse<TwitterUser>> ReportSpammerAsync(string screenName)
         {
-            return HttpPostAsync("report_spam.json", "screen_name=" + Encode(screenName)).ContinueWith<UserResponse>(t =>
-            {
-                var result = t.ToTwitterResponse<TwitterUser>();
-                if (result.StatusCode != HttpStatusCode.OK) return result;
-
-                result.Result = (TwitterUser)JsonConvert.DeserializeObject<JsonUser>(result.RawContent, new TwitterizerDateConverter());
-                return result;
-            });
+            return HttpPostAsync("report_spam.json", "screen_name=" + Encode(screenName)).RespondWith<TwitterUser>(content =>
+                JsonConvert.DeserializeObject<JsonUser>(content, new TwitterizerDateConverter()));
         }
     }
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.