Skip to content

Commit

Permalink
#83. #88, #94
Browse files Browse the repository at this point in the history
  • Loading branch information
a-legotin committed Nov 15, 2017
1 parent d279fbf commit c1cd172
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
10 changes: 0 additions & 10 deletions InstaSharper.Tests/Utils/TestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@ namespace InstaSharper.Tests.Utils
{
public class TestHelpers
{
public static IInstaApi GetDefaultInstaApiInstance(string username)
{
var apiInstance = InstaApiBuilder.CreateBuilder()
.SetUserName(username)
.UseLogger(new DebugLogger(LogLevel.All))
.SetSignatureKey("b4946d296abf005163e72346a6d33dd083cadde638e6ad9c5eb92e381b35784a")
.Build();
return apiInstance;
}

public static IInstaApi GetDefaultInstaApiInstance(UserSessionData user)
{
var apiInstance = InstaApiBuilder.CreateBuilder()
Expand Down
23 changes: 16 additions & 7 deletions InstaSharper/API/InstaApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,6 @@ public async Task<IResult<InstaUserShortList>> GetUserFollowersAsync(string user
followers.AddRange(
followersResponse.Value.Items.Select(ConvertersFabric.GetUserShortConverter)
.Select(converter => converter.Convert()));
if (!followersResponse.Value.IsBigList) return Result.Success(followers);
var pages = 1;
while (!string.IsNullOrEmpty(followersResponse.Value.NextMaxId) && pages < maxPages)
{
Expand Down Expand Up @@ -593,7 +592,15 @@ public async Task<IResult<InstaUserShortList>> GetUserFollowingAsync(string user
public async Task<IResult<InstaUserShortList>> GetCurrentUserFollowersAsync(int maxPages = 0)
{
ValidateUser();
return await GetUserFollowersAsync(_user.UserName, maxPages);
try
{
return await GetUserFollowersAsync(_user.UserName, maxPages);
}
catch (Exception exception)
{
LogException(exception);
return Result.Fail<InstaUserShortList>(exception);
}
}

/// <summary>
Expand Down Expand Up @@ -1714,13 +1721,15 @@ private async Task<IResult<InstaUserListShortResponse>> GetUserListByURIAsync(Ur
var request = HttpHelper.GetDefaultRequest(HttpMethod.Get, uri, _deviceInfo);
var response = await _httpRequestProcessor.SendAsync(request);
var json = await response.Content.ReadAsStringAsync();
if (response.StatusCode == HttpStatusCode.OK)
if (response.StatusCode != HttpStatusCode.OK)
return Result.UnExpectedResponse<InstaUserListShortResponse>(response, json);
var instaUserListResponse = JsonConvert.DeserializeObject<InstaUserListShortResponse>(json);
if (!instaUserListResponse.IsOk())
{
var instaUserListResponse = JsonConvert.DeserializeObject<InstaUserListShortResponse>(json);
if (!instaUserListResponse.IsOk()) Result.Fail("", (InstaUserListShortResponse) null);
return Result.Success(instaUserListResponse);
var status = ErrorHandlingHelper.GetBadStatusFromJsonString(json);
Result.Fail(new ResultInfo(status.Message), (InstaUserListShortResponse) null);
}
return Result.UnExpectedResponse<InstaUserListShortResponse>(response, json);
return Result.Success(instaUserListResponse);
}
catch (Exception exception)
{
Expand Down

0 comments on commit c1cd172

Please sign in to comment.