Exemplo n.º 1
0
 /// <summary>
 /// Get client instance
 /// </summary>
 /// <returns></returns>
 public static BouncerAPIClient GetClient()
 {
     lock (clientSync)
     {
         if (client == null)
         {
             client = new BouncerAPIClient();
         }
         return(client);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a reference to the Bouncer API SDK Client
        /// <para>This method automatically authenticates with the Bouncer REST API</para>
        /// </summary>
        /// <returns></returns>
        public static BouncerAPIClient getBouncerApiSdkClient()
        {
            var client = new BouncerAPIClient();

            if (string.IsNullOrWhiteSpace(Configuration.ACCESS_TOKEN))
            {
                var login_request = new LoginToBouncerAPIRequest
                {
                    Username  = TEST_USER,
                    Password  = TEST_USER_PASSWORD,
                    GrantType = "password"
                };
                var login_response = client.UsersLoginRegistration.LoginToBouncerAPI(login_request);
                Configuration.ACCESS_TOKEN = login_response.AccessToken;
            }

            return(client);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Register a new User with the Bouncer REST API
        /// <para>NOTE: The REST API must be started with --testing parameter to support User Registration</para>
        /// </summary>
        public static void registerNewUser()
        {
            var client = new BouncerAPIClient();

            try
            {
                var register_request = new RegisterNewUserRequest
                {
                    Username = TEST_USER,
                    Password = TEST_USER_PASSWORD
                };
                var register_response = client.UsersLoginRegistration.RegisterNewUser(register_request);
                Console.WriteLine($"Use Registered Successfully :- {register_response.Message}");
            }
            catch (APIException exception)
            {
                printException("Register New User =>", exception);
            }
        }