Exemple #1
0
        private async Task<string> OAuthRequest(ICredential credentials, OAuthToken oAuthToken, string oauthUri)
        {
            try
            {
                string outUrl;
                string querystring;
                var nonce = GenerateNonce();
                var timeStamp = GenerateTimeStamp();
                var sig = GenerateSignature(new Uri(oauthUri),
                    credentials.ConsumerKey,
                    credentials.ConsumerSecret,
                    oAuthToken.TokenKey,
                    oAuthToken.TokenSecret,
                    "GET",
                    timeStamp,
                    nonce,
                    out outUrl,
                    out querystring);

                return await OAuthResponseGet(querystring, sig, outUrl);
            }
            catch (Exception e)
            {
                if (e is OAuthException)
                    throw;
                return string.Empty;
            }
        }
Exemple #2
0
 public async Task<Balance> GetSimBalance(string msisdn, OAuthToken token)
 {
     string response;
     using (var oauth = new OAuth())
     {
         var parameters = new List<QueryParameter> { new QueryParameter("msisdn", WebUtility.UrlEncode(msisdn)) };
         response = await oauth.OAuthRequest(Credentials.GetInstance(), token, BaseUrl + "sim_balance.json", parameters);
     }
     //TODO: finish this
     if (response != null && !string.IsNullOrWhiteSpace(response))
         return JsonConvert.DeserializeObject<Balance>(response);
     return new Balance();
 }
Exemple #3
0
 public async Task<List<Msisdn>> GetMsisdnList(OAuthToken token)
 {
     string response;
     using (var oauth = new OAuth())
     {
         var parameters = new List<QueryParameter> { new QueryParameter("alias", "1") };
         response = await oauth.OAuthRequest(Credentials.GetInstance(), token, BaseUrl + "msisdn_list.json", parameters);
     }
     //TODO: finish this
     if(response != null && !string.IsNullOrWhiteSpace(response))
         return JsonConvert.DeserializeObject<List<Msisdn>>(response);
     return new List<Msisdn>();
 }
 public Task<Balance> GetSimBalance(string msisdn, OAuthToken token)
 {
     return _api.GetSimBalance(msisdn, token);
 }
 public Task<List<Msisdn>> GetMsisdnList(OAuthToken token)
 {
     return _api.GetMsisdnList(token);
 }
Exemple #6
0
 public async Task<string> OAuthRequest(ICredential credentials, OAuthToken oAuthToken, string oauthUri, IList<QueryParameter> parameters)
 {
     var uri = oauthUri + "?" + NormalizeRequestParameters(parameters);
     return await OAuthRequest(credentials, oAuthToken, uri);
 }
Exemple #7
0
 public async Task MyTestInitialize()
 {
     if(_token == null)
         _token = await VikingServiceFactory.GetInstance().Login("test", "test");
 }