Skip to content

Commit

Permalink
Added method to update apiContext. (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
OGKevin committed Jul 16, 2018
1 parent 5d723db commit e09ff27
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions BunqSdk/Context/BunqContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@ public static class BunqContext
public static ApiContext ApiContext {
get
{
if (apiContext == null)
{
throw new BunqException(ErrorApicontextHasNotBeenLoaded);
}
else
{
return apiContext;
}
AssertApiContextIsLoaded();

return apiContext;
}
private set => apiContext = value ?? throw new ArgumentNullException(nameof(value));
}

private static void AssertApiContextIsLoaded()
{
if (apiContext == null)
{
throw new BunqException(ErrorApicontextHasNotBeenLoaded);
}
}

public static UserContext UserContext
{
get
Expand All @@ -47,5 +50,12 @@ public static void LoadApiContext(ApiContext apiContextToLoad)
UserContext = new UserContext(apiContextToLoad.SessionContext.UserId);
UserContext.InitPrimaryMonetaryAccount();
}

public static void UpdateApiContext(ApiContext apiContext)
{
AssertApiContextIsLoaded();

BunqContext.apiContext = apiContext;
}
}
}

0 comments on commit e09ff27

Please sign in to comment.