/// <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);
        }
        /// <summary>
        /// Create a checkout Creates a zipMoney 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 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>Checkout</returns>
        public AccessToken AuthorizationCreateToken(string apiIdentifier)
        {
            this.Configuration.Timeout = 15000; //15 Seconds
            this.Configuration.DefaultHeader.Add("Content-Type", "application/json");

            var authorityRequest = new AuthorityRequest(AuthorityRequest.TypeEnum.ClientCredentials, apiIdentifier,
                                                        this.Configuration.ClientId, this.Configuration.ClientSecret);

            ApiResponse <AccessToken> localVarResponse = AuthorizationCreateWithHttpInfo(authorityRequest);

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

            return(localVarResponse.Data);
        }
 public void AuthorityInstanceTest()
 {
     instance = new AuthorityRequest(AuthorityRequest.TypeEnum.ClientCredentials, "MerchantId", "MerchantSecretKey");
     Assert.IsInstanceOf<AuthorityRequest> (instance, "variable 'instance' is a Authority");
 }
        /// <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>Task of ApiResponse (Checkout)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <Authentication> > AuthorizationCreateAsyncWithHttpInfo(AuthorityRequest body = null)
        {
            var    localVarPath         = "configuration";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new Dictionary <String, String>();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "*/*"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            localVarPathParams.Add("format", "json");
            if (body != null && body.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter
            }
            else
            {
                localVarPostBody = body; // byte array
            }

            // authentication (Authorization) required
            if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("Authorization")))
            {
                localVarHeaderParams["Authorization"] = Configuration.GetApiKeyWithPrefix("Authorization");
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                       Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                       localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("AuthorizationCreate", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <Authentication>(localVarStatusCode,
                                                    localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                    (Authentication)Configuration.ApiClient.Deserialize(localVarResponse, typeof(Authentication))));
        }
        /// <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>Task of Checkout</returns>
        public async System.Threading.Tasks.Task <Authentication> AuthorizationCreateAsync(AuthorityRequest body = null)
        {
            ApiResponse <Authentication> localVarResponse = await AuthorizationCreateAsyncWithHttpInfo(body);

            return(localVarResponse.Data);
        }