private async void Login() { if (string.IsNullOrWhiteSpace(UserName.Text)) { Tools.Message.ShowToast(AppResources.ToastUserName); return; } if (string.IsNullOrWhiteSpace(PassWord.Password)) { Tools.Message.ShowToast(AppResources.ToastPassword); return; } Tools.Tools.SetProgressIndicator(true); SystemTray.ProgressIndicator.Text = AppResources.ProgressRequestingAccess; using (var client = new VikingsApi()) { if (await client.Authorize(UserName.Text, PassWord.Password)) { var finished = new ApiBrowserEventArgs { Success = true }; OnLoginFinished(finished); Visibility = Visibility.Collapsed; } else { Tools.Message.ShowToast(AppResources.ToastLoginUnsuccessful); } } }
public async Task<bool> GetTopUps(DateTime fromDate, DateTime untilDate, int page = 1) { if (page == 1) { _page = page; _date1 = fromDate; _date2 = untilDate; } var pair = new[] { new KeyValuePair{Content = Msisdn, Name = "msisdn"}, new KeyValuePair{Content = fromDate.ToVikingApiTimeFormat(), Name = "from_date"}, new KeyValuePair{Content = untilDate.ToVikingApiTimeFormat(), Name = "until_date"}, new KeyValuePair{Content = "100", Name = "page_size"}, new KeyValuePair{Content = page, Name = "page"} }; Tools.Tools.SetProgressIndicator(true); SystemTray.ProgressIndicator.Text = AppResources.ProgressRetrievingTopups; using (var client = new VikingsApi()) { client.GetInfoFinished += client_GetInfoFinished; OAuthUtility.ComputeHash = (key, buffer) => { using (var hmac = new HMACSHA1(key)) { return hmac.ComputeHash(buffer); } }; await client.GetInfo(new AccessToken((string)IsolatedStorageSettings.ApplicationSettings["tokenKey"], (string)IsolatedStorageSettings.ApplicationSettings["tokenSecret"]), client.TopUp, pair, Cts); } return true; }
public async Task<bool> GetReferrals(int page = 1) { if (page == 1) { _page = page; } var pair = new[] { new KeyValuePair{Content = "100", Name = "page_size"}, new KeyValuePair{Content = page, Name = "page"} }; Tools.Tools.SetProgressIndicator(true); SystemTray.ProgressIndicator.Text = AppResources.ProgressRetrievingReferrals; using (var client = new VikingsApi()) { client.GetInfoFinished += client_GetReferralFinished; OAuthUtility.ComputeHash = (key, buffer) => { using (var hmac = new HMACSHA1(key)) { return hmac.ComputeHash(buffer); } }; await client.GetInfo(new AccessToken((string)IsolatedStorageSettings.ApplicationSettings["tokenKey"], (string)IsolatedStorageSettings.ApplicationSettings["tokenSecret"]), client.Referrals, pair, Cts); } return true; }
public async Task<bool> GetData(string msisdn) { Tools.Tools.SetProgressIndicator(true); SystemTray.ProgressIndicator.Text = AppResources.ProgressFetchingData; using (var client = new VikingsApi()) { client.GetInfoFinished += client_GetDataFinished; OAuthUtility.ComputeHash = (key, buffer) => { using (var hmac = new HMACSHA1(key)) { return hmac.ComputeHash(buffer); } }; await client.GetInfo(new AccessToken((string)IsolatedStorageSettings.ApplicationSettings["tokenKey"], (string)IsolatedStorageSettings.ApplicationSettings["tokenSecret"]), client.Balance, new KeyValuePair { Name = "msisdn", Content = msisdn }, Cts); } return true; }
public async Task<bool> GetSimInfo(CancellationTokenSource cts) { Tools.Tools.SetProgressIndicator(true); SystemTray.ProgressIndicator.Text = "loading sims"; using (var client = new VikingsApi()) { client.GetInfoFinished += client_GetSimInfoFinished; OAuthUtility.ComputeHash = (key, buffer) => { using (var hmac = new HMACSHA1(key)) { return hmac.ComputeHash(buffer); } }; await client.GetInfo(new AccessToken((string)IsolatedStorageSettings.ApplicationSettings["tokenKey"], (string)IsolatedStorageSettings.ApplicationSettings["tokenSecret"]), client.Sim, new KeyValuePair { Content = "1", Name = "alias" }, _cts); } return true; }
public async Task<bool> GetLinks() { Tools.Tools.SetProgressIndicator(true); SystemTray.ProgressIndicator.Text = AppResources.ProgressFetchingLinks; using (var client = new VikingsApi()) { client.GetInfoFinished += client_GetLinksFinished; OAuthUtility.ComputeHash = (key, buffer) => { using (var hmac = new HMACSHA1(key)) { return hmac.ComputeHash(buffer); } }; await client.GetInfo(new AccessToken((string)IsolatedStorageSettings.ApplicationSettings["tokenKey"], (string)IsolatedStorageSettings.ApplicationSettings["tokenSecret"]), client.Links, Cts); } return true; }