Exemple #1
0
        public static async Task <ZZAccount> Login(ProperHttpClient client, string number, string password)
        {
            var loginParams = new Dictionary <string, string>()
            {
                { "grant_type", "password" },
                { "scope", "userpriceplans%20accountinformation%20userbucketbalance" },                         // Pietiekams atlikuma noskaidrošanai.
                // Pilns scope, kuru izmanto Android lietotne: temporarypassword%20balanceprolongation%20voucherrefill%20userpriceplans%20priceplanordering%20offeredpriceplans%20userservices%20serviceordering%20offerings%20registergcmtoken%20accountinformation%20subscription%20userbucketbalance%20billinglanguage%20whois
                { "client_id", ClientId },
                { "client_secret", ClientSecret },
                { "username", number },
                { "password", password },
                { "auth_by_IP", "false" },
                { "version_no", ClientVersion }
            };

            var oauth = await client.PostAsync <OAuthToken>("https://app.zeltazivtina.lv/thin/rest/Auth", new HttpFormUrlEncodedContent(loginParams));

            if (oauth == null)
            {
                return(null);
            }
            System.Diagnostics.Debug.WriteLine("ZZ access token " + oauth.access_token);
            var account = new ZZAccount(null);

            account.SetTokens(oauth);
            return(account);
        }
Exemple #2
0
        public static Account GetAccount(string id)
        {
            var values = ApplicationData.Current.LocalSettings.Values;
            var value  = (ApplicationDataCompositeValue)values[id];

            if (value == null)
            {
                return(null);
            }

            Account account;

            switch ((Carrier)(byte)value["CR"])
            {
            case Carrier.ZZ:
                account = new ZZAccount(id);
                break;

            case Carrier.Bite:
                account = new BiteAccount(id);
                break;

            case Carrier.OKarte:
                account = new OAccount(id);
                break;

            default: return(null);
            }

            account.Caption         = (string)value["CN"];
            account.RefreshInterval = TimeSpan.FromMinutes((double)value["RI"]);

            LoadBalances(account);
            return(account);
        }