Exemplo n.º 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;
            }
        }
Exemplo n.º 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();
 }
Exemplo n.º 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>();
 }
Exemplo n.º 4
0
 public Task<Balance> GetSimBalance(string msisdn, OAuthToken token)
 {
     return _api.GetSimBalance(msisdn, token);
 }
Exemplo n.º 5
0
 public Task<List<Msisdn>> GetMsisdnList(OAuthToken token)
 {
     return _api.GetMsisdnList(token);
 }
Exemplo n.º 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);
 }
Exemplo n.º 7
0
 public async Task MyTestInitialize()
 {
     if(_token == null)
         _token = await VikingServiceFactory.GetInstance().Login("test", "test");
 }