Skip to content

Commit

Permalink
[Procurement-PoE#1140,1141,1142,1144,1146,1147,1148] Temporary fix fo…
Browse files Browse the repository at this point in the history
…r "Error downloading account name".
  • Loading branch information
Omga4000 committed Dec 22, 2022
1 parent 0ac32e5 commit d8c2e2f
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
5 changes: 3 additions & 2 deletions POEApi.Model/POEModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public bool Authenticate(string email, SecureString password, bool offline, stri
return true;
}

public string GetAccountName(string realm)
public string GetAccountName(string username, string realm)
{
try
{
Expand All @@ -71,7 +71,8 @@ public string GetAccountName(string realm)
return string.Empty;
}

var account = GetProperObjectFromTransport<Account>(Transport.GetAccountName(realm));
var account = GetProperObjectFromTransport<Account>(Transport.GetAccountName(username, realm));
account.AccountName = username;

if (string.IsNullOrEmpty(account?.AccountName))
{
Expand Down
4 changes: 2 additions & 2 deletions POEApi.Transport/CachedTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public bool Authenticate(string email, SecureString password)
return _innerTranport.Authenticate(email, password);
}

public Stream GetAccountName(string realm)
public Stream GetAccountName(string username, string realm)
{
return _innerTranport.GetAccountName(realm);
return _innerTranport.GetAccountName(username, realm);
}

public Stream GetStash(int index, string league, string accountName, string realm, bool refresh)
Expand Down
6 changes: 3 additions & 3 deletions POEApi.Transport/HttpTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected enum HttpMethod { GET, POST }

private const string LoginURL = @"https://www.pathofexile.com/login";
private const string AccountURL = @"https://www.pathofexile.com/my-account";
private const string AccountNameURL = @"https://www.pathofexile.com/character-window/get-account-name?realm={0}";
private const string AccountNameURL = @"https://api.poe.watch/char?name={0}&realm={1}";
private const string CharacterURL = @"https://www.pathofexile.com/character-window/get-characters?&realm={0}";
private const string StashURL = @"https://www.pathofexile.com/character-window/get-stash-items?league={0}&tabs=1&tabIndex={1}&accountName={2}&realm={3}";
private const string InventoryURL = @"https://www.pathofexile.com/character-window/get-items?character={0}&accountName={1}&realm={2}";
Expand Down Expand Up @@ -219,9 +219,9 @@ public Stream GetCharacters(string realm )
return PerformHttpRequest(HttpMethod.GET, string.Format(CharacterURL, realm));
}

public Stream GetAccountName(string realm )
public Stream GetAccountName(string username, string realm )
{
return PerformHttpRequest(HttpMethod.GET, string.Format(AccountNameURL, realm));
return PerformHttpRequest(HttpMethod.GET, string.Format(AccountNameURL, username, realm));
}

// TODO(20180928): Throttle performing these requests?
Expand Down
2 changes: 1 addition & 1 deletion POEApi.Transport/ITransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace POEApi.Transport
public interface ITransport
{
bool Authenticate(string email, SecureString password);
Stream GetAccountName(string realm);
Stream GetAccountName(string username, string realm);
Stream GetStash(int index, string league, string accountName, string realm);
Stream GetStash(int index, string league, string accountName, string realm, bool refresh);
Stream GetImage(string url);
Expand Down
3 changes: 1 addition & 2 deletions Procurement/Procurement.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject>
</StartupObject>
<StartupObject>Procurement.App</StartupObject>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Images\Procurement.ico</ApplicationIcon>
Expand Down
2 changes: 1 addition & 1 deletion Procurement/ViewModel/LoginWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void Login(bool offline)
if (!offline)
{
_statusController.DisplayMessage("Fetching account name...");
ApplicationState.AccountName = ApplicationState.Model.GetAccountName(ApplicationState.CurrentRealm);
ApplicationState.AccountName = ApplicationState.Model.GetAccountName(Email, ApplicationState.CurrentRealm);
_statusController.Ok();
if (ForceRefresh)
{
Expand Down
4 changes: 2 additions & 2 deletions Tests/POEApi.Model.Tests/PoeModelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ public void GetAccountNameTest()

using (var stream = GenerateStreamFromString(fakeAccountNameResponse))
{
_mockTransport.Setup(m => m.GetAccountName(Realm.PC)).Returns(stream);
_mockTransport.Setup(m => m.GetAccountName("fakeAccountName", Realm.PC)).Returns(stream);

var account = _model.GetAccountName(Realm.PC);
var account = _model.GetAccountName("fakeAccountName", Realm.PC);

Assert.AreEqual("fakeAccountName", account);
}
Expand Down

0 comments on commit d8c2e2f

Please sign in to comment.