Ejemplo n.º 1
0
        public void UserRegisterVerification(String phoneNumber, String password)
        {
            List<KeyValuePair<String, String>> postParams = new List<KeyValuePair<String, String>> ();
            postParams.Add (new KeyValuePair<string, string> (PHONE_NUMBER, phoneNumber));
            postParams.Add (new KeyValuePair<string, string> (USER_PASSWORD, password));
            String responseResult;
            System.Net.HttpStatusCode status = new SimpleHttpClient.HttpClientHelper().HttpRequest (URL.PHONE_VERIFICATION_URL, postParams, out responseResult);

            if (status == System.Net.HttpStatusCode.OK) {
                UserRegisterResponse userRegistrationResponse = JsonConvert.DeserializeObject<UserRegisterResponse> (responseResult);
                switch (userRegistrationResponse.status) {
                    // User complete registration action
                    // Save phone number and password
                  	case (int)RegistrationStatusCode.registration_complete:{
                        SavePhoneNumberToPref (phoneNumber);
                        SaveUserPassword (password);
                        if (userRegistrationComplete != null)
                            userRegistrationComplete (userRegistrationResponse,status);
                        break;
                    }
                    // User is already registered
                    case (int)RegistrationStatusCode.alredy_registered:{
                        if (userAlredyRegistered != null)
                            userAlredyRegistered (userRegistrationResponse, status);
                        break;
                    }
                    //Add another case with specific status code
                    default: {
                        if (messageReceived != null)
                            messageReceived (userRegistrationResponse, status);
                        break;
                    };
                }
            }
        }
Ejemplo n.º 2
0
        public void SMSTokenVerification(string token, string phoneNumber)
        {
            List<KeyValuePair<String,String>> postParams = new List<KeyValuePair<String,String>> ();
            postParams.Add (new KeyValuePair<string,string>(TOKEN, token));
            postParams.Add (new KeyValuePair<string, string> (PHONE_NUMBER, phoneNumber));
            String responseResult;
            System.Net.HttpStatusCode status = new SimpleHttpClient.HttpClientHelper().HttpRequest (URL.TOKEN_VERIFICATION_URL, postParams, out responseResult);

            if (status == System.Net.HttpStatusCode.OK) {
                SMSTokenResponse smsTokenResponse = JsonConvert.DeserializeObject<SMSTokenResponse> (responseResult);
                switch (smsTokenResponse.status) {
                    // SMS token verification complete
                    // Save token ans set user success registered
                    case (int)SMSTokenStatusCode.verification_success:{
                        SaveTokenToPref (token);
                        SetUserSuccessAuthorised ();
                        if (tokenVerificationComplete != null)
                            tokenVerificationComplete (smsTokenResponse, status);
                        break;
                    }
                    //Add another case with specific status code
                    default: break;
                }
            }
        }