Example #1
0
 public async Task<bool> GetSimInfo()
 {
     Tools.Tools.SetProgressIndicator(true);
     try
     {
         Tools.Tools.SetProgressIndicator(true);
         SystemTray.ProgressIndicator.Text = "loading sims";
         var client = new VikingsApi();
         OAuthUtility.ComputeHash = (key, buffer) =>
         {
             using (var hmac = new HMACSHA1(key))
             {
                 return hmac.ComputeHash(buffer);
             }
         };
         string json = await client.GetInfo(new AccessToken((string) IsolatedStorageSettings.ApplicationSettings["tokenKey"], (string) IsolatedStorageSettings.ApplicationSettings["tokenSecret"]), client.Sim, new KeyValuePair {content = "1", name = "alias"});
         Sims = JsonConvert.DeserializeObject<Sim[]>(json);
         Tools.Tools.SetProgressIndicator(false);
         return true;
     }
     catch (Exception)
     {
         Message.ShowToast("Could not load sim information, please try again later");
         return false;
     }
 }
        public async Task <bool> GetData(string msisdn)
        {
            try
            {
                Tools.Tools.SetProgressIndicator(true);
                SystemTray.ProgressIndicator.Text = "fetching data";
                var client = new VikingsApi();
                OAuthUtility.ComputeHash = (key, buffer) =>
                {
                    using (var hmac = new HMACSHA1(key))
                    {
                        return(hmac.ComputeHash(buffer));
                    }
                };
                string json = await client.GetInfo(new AccessToken((string)IsolatedStorageSettings.ApplicationSettings["tokenKey"], (string)IsolatedStorageSettings.ApplicationSettings["tokenSecret"]), client.Balance, new KeyValuePair { name = "msisdn", content = msisdn });

                if (Error.HandleError(json, "there seems to be no connection"))
                {
                    return(false);
                }
                Tools.Tools.SetProgressIndicator(false);
                Balance = new UserBalance(json);
                return(true);
            }
            catch (Exception)
            {
                Message.ShowToast("Could not load bundle info, please try again later");
                return(false);
            }
        }
Example #3
0
 public async Task<bool> GetData(string msisdn)
 {
     try
     {
         Tools.Tools.SetProgressIndicator(true);
         SystemTray.ProgressIndicator.Text = "fetching data";
         var client = new VikingsApi();
         OAuthUtility.ComputeHash = (key, buffer) =>
         {
             using (var hmac = new HMACSHA1(key))
             {
                 return hmac.ComputeHash(buffer);
             }
         };
         string json = await client.GetInfo(new AccessToken((string) IsolatedStorageSettings.ApplicationSettings["tokenKey"], (string) IsolatedStorageSettings.ApplicationSettings["tokenSecret"]), client.Balance, new KeyValuePair {name = "msisdn", content = msisdn});
         if (Error.HandleError(json, "there seems to be no connection"))
             return false;
         Tools.Tools.SetProgressIndicator(false);
         Balance = new UserBalance(json);
         return true;
     }
     catch (Exception)
     {
         Message.ShowToast("Could not load bundle info, please try again later");
         return false;
     }
 }
        public async Task <bool> GetSimInfo()
        {
            Tools.Tools.SetProgressIndicator(true);
            try
            {
                Tools.Tools.SetProgressIndicator(true);
                SystemTray.ProgressIndicator.Text = "loading sims";
                var client = new VikingsApi();
                OAuthUtility.ComputeHash = (key, buffer) =>
                {
                    using (var hmac = new HMACSHA1(key))
                    {
                        return(hmac.ComputeHash(buffer));
                    }
                };
                string json = await client.GetInfo(new AccessToken((string)IsolatedStorageSettings.ApplicationSettings["tokenKey"], (string)IsolatedStorageSettings.ApplicationSettings["tokenSecret"]), client.Sim, new KeyValuePair { content = "1", name = "alias" });

                Sims = JsonConvert.DeserializeObject <Sim[]>(json);
                Tools.Tools.SetProgressIndicator(false);
                return(true);
            }
            catch (Exception)
            {
                Message.ShowToast("Could not load sim information, please try again later");
                return(false);
            }
        }
        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);
        }
Example #6
0
        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> GetSimInfo()
 {
     Tools.Tools.SetProgressIndicator(true);
     SystemTray.ProgressIndicator.Text = AppResources.ProgressLoadingSims;
     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);
 }
 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> GetUsage(DateTime fromDate, DateTime untilDate, int page = 1)
        {
            if (page == 1)
            {
                _page  = page;
                _date1 = fromDate;
                _date2 = untilDate;
                Usage  = null;
            }
            var pair = new[]
            {
                new KeyValuePair {
                    Content = Msisdn, Name = VikingApi.Json.Usage.Msisdn
                },
                new KeyValuePair {
                    Content = fromDate.ToVikingApiTimeFormat(), Name = VikingApi.Json.Usage.FromDate
                },
                new KeyValuePair {
                    Content = untilDate.ToVikingApiTimeFormat(), Name = VikingApi.Json.Usage.UntilDate
                },
                new KeyValuePair {
                    Content = "100", Name = VikingApi.Json.Usage.PageSize
                },
                new KeyValuePair {
                    Content = page, Name = VikingApi.Json.Usage.Page
                },
            };

            Tools.Tools.SetProgressIndicator(true);
            SystemTray.ProgressIndicator.Text = AppResources.ProgressRetrievingUsage;
            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.Usage, pair, Cts);

            return(true);
        }