diff --git a/src/InstaSharp.Tests/Relationships.cs b/src/InstaSharp.Tests/Relationships.cs index 071f3d3..c6906d5 100644 --- a/src/InstaSharp.Tests/Relationships.cs +++ b/src/InstaSharp.Tests/Relationships.cs @@ -25,6 +25,15 @@ public async Task Follows_Id() Assert.IsTrue(result.Data.Count > 0); } + [TestMethod, TestCategory("Relationships.Follows")] + public async Task Follows_NextCursor() + { + //This test will fail if testing with an account with less than one page of follows + var result = await relationships.Follows(); + result = await relationships.Follows(null, result.Pagination.NextCursor); + Assert.IsTrue(result.Data.Count > 0); + } + [TestMethod, TestCategory("Relationships.FollowedBy")] public async Task FollowedBy() { @@ -39,6 +48,15 @@ public async Task FollowedBy_Id() Assert.IsTrue(result.Data.Count > 0); } + [TestMethod, TestCategory("Relationships.FollowedBy")] + public async Task FollowedBy_NextCursor() + { + //This test will fail if testing with an account with less than one page of followers + var result = await relationships.FollowedBy(); + result = await relationships.FollowedBy(null, result.Pagination.NextCursor); + Assert.IsTrue(result.Data.Count > 0); + } + [TestMethod, TestCategory("Relationships.RequestedBy")] public async Task RequestedBy() { diff --git a/src/InstaSharp.Tests/Users.cs b/src/InstaSharp.Tests/Users.cs index 0387fc0..288c719 100644 --- a/src/InstaSharp.Tests/Users.cs +++ b/src/InstaSharp.Tests/Users.cs @@ -31,6 +31,13 @@ public async Task Get_Id() Assert.IsTrue(result.Data.Username == "nasagoddard", "Parameters: userId"); } + [TestMethod, TestCategory("Users.Get")] + public async Task Get_Self() + { + var result = await users.GetSelf(); + Assert.IsNotNull(result); + } + [TestMethod, TestCategory("Users.Feed")] public async Task Feed() { diff --git a/src/InstaSharp/Endpoints/Relationships.cs b/src/InstaSharp/Endpoints/Relationships.cs index ad8e56c..b1a3e16 100644 --- a/src/InstaSharp/Endpoints/Relationships.cs +++ b/src/InstaSharp/Endpoints/Relationships.cs @@ -35,9 +35,15 @@ public Relationships(InstagramConfig config, OAuthResponse auth) /// /// /// The list of users that this user id is following. - public Task Follows(int? userId = null) { + /// The next cursor id + public Task Follows(int? userId = null, string cursor = null) + { var request = base.Request("{id}/follows"); request.AddUrlSegment("id", userId.HasValue ? userId.ToString() : base.OAuthResponse.User.Id.ToString()); + if (cursor != null) + { + request.AddParameter("cursor", cursor); + } return base.Client.ExecuteAsync(request); } @@ -51,8 +57,13 @@ public Task Follows(int? userId = null) { /// /// /// The id of the user to get the followers of. - public Task FollowedBy(int? userId = null) { + /// The next cursor id + public Task FollowedBy(int? userId = null, string cursor = null) { var request = base.Request(string.Format("{0}/followed-by", userId.HasValue ? userId.ToString() : OAuthResponse.User.Id.ToString())); + if (cursor != null) + { + request.AddParameter("cursor", cursor); + } return base.Client.ExecuteAsync(request); } diff --git a/src/InstaSharp/Endpoints/Users.cs b/src/InstaSharp/Endpoints/Users.cs index 0dbae54..61da047 100644 --- a/src/InstaSharp/Endpoints/Users.cs +++ b/src/InstaSharp/Endpoints/Users.cs @@ -32,6 +32,13 @@ public Task Get(string userId = null) { return Client.ExecuteAsync(request); } + public Task GetSelf() + { + var request = base.Request("self"); + + return Client.ExecuteAsync(request); + } + /// /// See the authenticated user's feed. /// diff --git a/src/InstaSharp/Models/Pagination.cs b/src/InstaSharp/Models/Pagination.cs index de00453..d829413 100644 --- a/src/InstaSharp/Models/Pagination.cs +++ b/src/InstaSharp/Models/Pagination.cs @@ -8,6 +8,8 @@ namespace InstaSharp.Models { public class Pagination { [JsonProperty("next_url")] public string NextUrl { get; set; } + [JsonProperty("next_cursor")] + public string NextCursor { get; set; } [JsonProperty("next_max_id")] public string NextMaxId { get; set; } [JsonProperty("next_min_id")] diff --git a/src/InstaSharp/Models/Responses/UsersResponse.cs b/src/InstaSharp/Models/Responses/UsersResponse.cs index 25cb363..31563ae 100644 --- a/src/InstaSharp/Models/Responses/UsersResponse.cs +++ b/src/InstaSharp/Models/Responses/UsersResponse.cs @@ -7,5 +7,6 @@ namespace InstaSharp.Models.Responses { public class UsersResponse : IResponse { public Models.Meta Meta { get; set; } public List Data { get; set; } + public Pagination Pagination { get; set; } } }