/// <summary>
        /// Create a checkout Creates a Afterpay checkout.  During the checkout process a customer can apply for credit decisioning in real-time. This means the checkout needs to represent a good picture of known customer details along with order information and the checkout entity represents this as a resource.  For more information on how to checkout with Afterpay see the #model:Z2QcrzRGHACY8wM6G guide.
        /// </summary>
        /// <exception cref="MerchantApi.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body"> (optional)</param>
        /// <returns>Checkout</returns>
        public Authentication AuthorizationCreateToken()
        {
            this.Configuration.Timeout = 15000; //15 Seconds

            var authorization = Convert.ToBase64String(Encoding.Default.GetBytes(this.Configuration.MerchantId + ":" + this.Configuration.MerchantSecretKey));

            this.Configuration.AccessToken = authorization;

            Configuration.AddApiKey("Authorization", this.Configuration.AccessToken);
            Configuration.AddApiKeyPrefix("Authorization", "Basic");

            Configuration.AddApiKey("User-Agent", this.Configuration.UserAgent);
            Configuration.AddApiKeyPrefix("User-Agent", "User-Agent");

            var authorityRequest = new AuthorityRequest(AuthorityRequest.TypeEnum.ClientCredentials,
                                                        this.Configuration.MerchantId, this.Configuration.MerchantSecretKey);

            ApiResponse <Authentication> localVarResponse = AuthorizationCreateWithHttpInfo();

            if ((System.Net.HttpStatusCode)localVarResponse.StatusCode == System.Net.HttpStatusCode.OK)
            {
                return(localVarResponse.Data);
            }

            return(null);
        }
示例#2
0
 public API(string accessToken, string host = "https://api.youneedabudget.com/v1", bool useHttps = true)
 {
     // TODO: Use this
     _useHttps = useHttps;
     _config.AddApiKey("Authorization", accessToken);
     _config.AddApiKeyPrefix("Authorization", "Bearer");
     _config.BasePath = host;
 }
        public AuthorizationService(Configuration apiConfiguration, String authorizationPrefix)
        {
            AuthorizationPrefix  = authorizationPrefix;
            ServiceConfiguration = apiConfiguration;
            ServiceConfiguration.AddApiKeyPrefix("Authorization", "Bearer");

            AccountApi = new AccountApi(apiConfiguration);
        }
示例#4
0
        /// <summary>
        /// Create a Order Creates a zipMoney Order.  During the Order process a customer can apply for credit decisioning in real-time. This means the Order needs to represent a good picture of known customer details along with order information and the Order entity represents this as a resource.  For more information on how to Order with zipMoney see the #model:Z2QcrzRGHACY8wM6G guide.
        /// </summary>
        /// <exception cref="MerchantApi.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body"> (optional)</param>
        /// <returns>Task of Order</returns>
        public async System.Threading.Tasks.Task <OrderCreateResponse> OrderCreateAsync(AccessToken accessToken = null, string idempotencyKey = null, CreateOrderRequest body = null)
        {
            Configuration.AddApiKey("Authorization", accessToken.Token);
            Configuration.AddApiKeyPrefix("Authorization", "Bearer");

            Configuration.AddApiKey("Idempotency-Key", idempotencyKey);
            Configuration.AddApiKeyPrefix("Idempotency-Key", "Idempotency-Key");

            ApiResponse <OrderCreateResponse> localVarResponse = await OrderCreateAsyncWithHttpInfo(body);

            return(localVarResponse.Data);
        }
示例#5
0
        public VoidOrder OrderVoid(AccessToken accessToken, string id, string idempotencyKey = null, CreateVoidRequest body = null)
        {
            Configuration.AddApiKey("Authorization", accessToken.Token);
            Configuration.AddApiKeyPrefix("Authorization", "Bearer");

            Configuration.AddApiKey("Idempotency-Key", idempotencyKey);
            Configuration.AddApiKeyPrefix("Idempotency-Key", "Idempotency-Key");

            ApiResponse <VoidOrder> localVarResponse = OrderVoidWithHttpInfo(id, body);

            return(localVarResponse.Data);
        }
示例#6
0
        /// <summary>
        /// Retrieve a Order Retrieves a previously created Order by id.
        /// </summary>
        /// <exception cref="MerchantApi.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="id"></param>
        /// <returns>Order</returns>
        public CheckoutOrder OrderGet(AccessToken accessToken, string id)
        {
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new ApiException(400, "Missing required parameter 'id' when calling OrdersApi->OrderGet");
            }

            Configuration.AddApiKey("Authorization", accessToken.Token);
            Configuration.AddApiKeyPrefix("Authorization", "Bearer");

            ApiResponse <CheckoutOrder> localVarResponse = OrderGetWithHttpInfo(id);

            return(localVarResponse.Data);
        }
示例#7
0
        /// <summary>
        /// Creates API accessor.
        /// </summary>
        /// <typeparam name="TApiAccessor">
        /// The API accessor type.
        /// </typeparam>
        /// <param name="accessToken">
        /// The access token.
        /// </param>
        /// <returns>
        /// The API accessor.
        /// </returns>
        private static TApiAccessor CreateApiAccessor <TApiAccessor>(string accessToken)
            where TApiAccessor : IApiAccessor, new()
        {
            // A generic method create api accessor generated by codegen.
            const string AuthorizationHeaderKey = "Authorization";

            // Version suffix should be ommited in path.
            var configuration = new Configuration(new ApiClient(ResourceServerEndpointAddressBase));

            // Add 'Bearer' token authorization.
            configuration.AddApiKeyPrefix(AuthorizationHeaderKey, "Bearer");
            configuration.AddApiKey(AuthorizationHeaderKey, accessToken);

            return(new TApiAccessor {
                Configuration = configuration
            });
        }
        private static Configuration GetConfig()
        {
            VerifyAuthentication();

            var config = new Configuration();

            /*
             * The generated ApiClient still does not understand the use of the Bearer token,
             * it's trying to use Basic Auth.  This workaround exists to explicitly set the Authorization
             * header
             */
            config.AddApiKey(AuthScheme, BearerToken);
            config.AddApiKeyPrefix(AuthScheme, BearerPrefix);
            config.DefaultHeaders[AuthorizationHeader] = config.GetApiKeyWithPrefix(AuthScheme);

            return(config);
        }
示例#9
0
        public Configuration Configuration()
        {
            Configuration conf       = new Configuration();
            AuthApi       authApi    = new AuthApi(conf);
            var           requestEup = new WasteRegisterPublicApiApiModelsRequestsAuthV1EupRequest();

            requestEup.ClientId             = "a9b06fba-e707-47ef-b21a-c9f25932e17c";
            requestEup.ClientSecret         = "f67194ff2f5643b08634a0c006ca7cab7095db4394b149daaa93254199790969";
            requestEup.PaginationParameters = new WasteRegisterPublicApiApiModelsRequestsAuthV1AuthPaginationParameters()
            {
                Order = new WasteRegisterPublicApiApiModelsRequestsAuthV1Aorder()
                {
                    IsAscending = true
                },
                Page = new WasteRegisterPublicApiApiModelsRequestsAuthV1Apage()
                {
                    Index = 1, Size = 10
                },
            };

            var responseEup = authApi.GetEupList(requestEup);

            var requestToken = new WasteRegisterPublicApiApiModelsRequestsAuthV1JwtRequest();

            requestToken.EupId        = responseEup.Items[0].EupId.ToString();
            requestToken.ClientId     = "a9b06fba-e707-47ef-b21a-c9f25932e17c";
            requestToken.ClientSecret = "f67194ff2f5643b08634a0c006ca7cab7095db4394b149daaa93254199790969";

            var responseToken = authApi.GenerateEupAccessToken(requestToken);

            conf.AccessToken = responseToken.AccessToken;
            conf.Password    = "******";
            conf.Username    = "******";
            conf.AddApiKey("Authorization", conf.AccessToken);
            conf.AddApiKeyPrefix("Authorization", "Bearer");

            return(conf);
        }
        public async Task <bool> CanBearerTokenUsed(string bearerToken)
        {
            var tmpConfiguration = new Configuration
            {
                BasePath = AccountApi.Configuration.BasePath
                           //DefaultHeader = {["Authorization"] = string.Concat(AuthorizationPrefix, bearerToken)},
            };

            tmpConfiguration.AddApiKeyPrefix("Authorization", "Bearer");
            tmpConfiguration.AddApiKey("Authorization", bearerToken);

            var testApi = new UsersApi(tmpConfiguration);

            try
            {
                var test = await testApi.UsersGetCurrentUserAsync();

                return(test != null);
            }
            catch (Exception)
            {
                return(false);
            }
        }