コード例 #1
0
        public APICredential FinishPINRegistration(String email, String pincode, String password, String secretQuestion, String answer, String firstName, String lastName, String keyDescription)
        {
            Endpoint p = ConnectionStrings.Endpoints["finishPINRegistration"].Clone();

            FinishRegistrationRequest req = new FinishRegistrationRequest();

            req.Email     = email;
            req.PinCode   = pincode;
            req.Password  = password;
            req.Question  = secretQuestion;
            req.Answer    = answer;
            req.FirstName = firstName;
            req.LastName  = lastName;

            StandardResponse response = connection.Send <StandardResponse>(p, req);

            if (response.Response == APIResponse.PASSWORD_COMPLEXITY)
            {
                throw new InsufficientPasswordComplexityException(response.Message);
            }
            else if (response.Response == APIResponse.TOKEN_EXPIRED)
            {
                throw new TokenExpiredException(response.Message);
            }
            else if (response.Response == APIResponse.PIN_RESEND)
            {
                throw new PINRefreshException(response.Message);
            }
            else if (response.Response == APIResponse.INVALID_TOKEN)
            {
                throw new InvalidTokenException(response.Message);
            }
            else if (response.Response != APIResponse.SUCCESS)
            {
                throw new ActionFailedException(response.Response.ToString(), response.Message);
            }

            p = ConnectionStrings.Endpoints["generateKey"].Clone();
            GenerateKeyRequest keyReq = new GenerateKeyRequest();

            keyReq.Email          = email;
            keyReq.Password       = password;
            keyReq.KeyDescription = keyDescription;

            GenerateAPIKeyResponse response2 = connection.Send <GenerateAPIKeyResponse>(p, keyReq);

            if (response2.Response != APIResponse.SUCCESS)
            {
                throw new ActionFailedException(response2.Response.ToString(), response2.Message);
            }

            APICredential key = new APICredential();

            key.APIKey    = response2.APIKey;
            key.APISecret = response2.APISecret;

            return(key);
        }
コード例 #2
0
        public APICredential OAuthGenerateAPIKey(string oauthToken, string keyDescription)
        {
            var p = ConnectionStrings.Endpoints["oauthRegistration"].Clone();

            p.Path = p.Path.Replace("{token}", oauthToken);

            var req = new FinishRegistrationRequest
            {
                KeyDescription = keyDescription
            };

            var response = _connection.Send <GenerateAPIKeyResponse>(p, req);

            switch (response.Response)
            {
            case APIResponse.USER_ALREADY_EXISTS:
                throw new DuplicateUserException(response.Message);

            case APIResponse.AUTH_FORBIDDEN:
                throw new RegistrationNotAllowedException(response.Message);

            case APIResponse.AUTHENTICATION_FAILED:
                throw new InvalidCredentialsException(response.Message);

            default:
            {
                if (response.Response != APIResponse.SUCCESS)
                {
                    throw new ActionFailedException(response.Response.ToString(), response.Message);
                }

                break;
            }
            }

            var key = new APICredential
            {
                APIKey    = response.APIKey,
                APISecret = response.APISecret
            };

            return(key);
        }
コード例 #3
0
        public APICredential OAuthGenerateAPIKey(String oauthToken, String keyDescription)
        {
            Endpoint p = ConnectionStrings.Endpoints["oauthRegistration"].Clone();

            p.Path = p.Path.Replace("{token}", oauthToken);

            FinishRegistrationRequest req = new FinishRegistrationRequest();

            req.KeyDescription = keyDescription;

            GenerateAPIKeyResponse response = connection.Send <GenerateAPIKeyResponse>(p, req);

            if (response.Response == APIResponse.USER_ALREADY_EXISTS)
            {
                throw new DuplicateUserException(response.Message);
            }
            else if (response.Response == APIResponse.AUTH_FORBIDDEN)
            {
                throw new RegistrationNotAllowedException(response.Message);
            }
            else if (response.Response == APIResponse.AUTHENTICATION_FAILED)
            {
                throw new InvalidCredentialsException(response.Message);
            }
            else if (response.Response != APIResponse.SUCCESS)
            {
                throw new ActionFailedException(response.Response.ToString(), response.Message);
            }

            APICredential key = new APICredential();

            key.APIKey    = response.APIKey;
            key.APISecret = response.APISecret;

            return(key);
        }
コード例 #4
0
        public APICredential FinishPINRegistration(string email, string pincode, string password, string secretQuestion, string answer, string firstName, string lastName, string keyDescription)
        {
            var p = ConnectionStrings.Endpoints["finishPINRegistration"].Clone();

            var req = new FinishRegistrationRequest
            {
                Email     = email,
                PinCode   = pincode,
                Password  = password,
                Question  = secretQuestion,
                Answer    = answer,
                FirstName = firstName,
                LastName  = lastName
            };

            var response = _connection.Send <StandardResponse>(p, req);

            switch (response.Response)
            {
            case APIResponse.PASSWORD_COMPLEXITY:
                throw new InsufficientPasswordComplexityException(response.Message);

            case APIResponse.TOKEN_EXPIRED:
                throw new TokenExpiredException(response.Message);

            case APIResponse.PIN_RESEND:
                throw new PINRefreshException(response.Message);

            case APIResponse.INVALID_TOKEN:
                throw new InvalidTokenException(response.Message);

            default:
            {
                if (response.Response != APIResponse.SUCCESS)
                {
                    throw new ActionFailedException(response.Response.ToString(), response.Message);
                }

                break;
            }
            }

            p = ConnectionStrings.Endpoints["generateKey"].Clone();
            var keyReq = new GenerateKeyRequest
            {
                Email          = email,
                Password       = password,
                KeyDescription = keyDescription
            };

            var response2 = _connection.Send <GenerateAPIKeyResponse>(p, keyReq);

            if (response2.Response != APIResponse.SUCCESS)
            {
                throw new ActionFailedException(response2.Response.ToString(), response2.Message);
            }

            var key = new APICredential
            {
                APIKey    = response2.APIKey,
                APISecret = response2.APISecret
            };

            return(key);
        }