context: using System;
  using System.IO;
  using System.Collections.Generic;
  using System.Collections.ObjectModel;
  using System.Linq;
  using RestSharp;
  using epay3.Web.Api.Sdk.Client;
  using epay3.Web.Api.Sdk.Model;
  
  namespace epay3.Web.Api.Sdk.Api
  {
      
      /// <summary>
      /// Represents a collection of functions to interact with the API endpoints
      /// </summary>
      public interface IPaymentSchedulesApi
      {
          /// <summary>
          /// Cancels an active payment schedule.
          /// </summary>
          /// <remarks>
          /// 
          /// </remarks>
          /// <exception cref="epay3.Web.Api.Sdk.Client.ApiException">Thrown when fails to make API call</exception>
          /// <param name="id">The public Id of the payment schedule.</param>
          /// <param name="impersonationAccountKey">The key that allows impersonation of another account for which the transaction(s) will be processed. Only specify a value if the account being impersonated is different from the account that is submitting this request. (optional, default to )</param>
          /// <returns></returns>
          bool PaymentSchedulesCancel (string id, string impersonationAccountKey = null);
    
          /// <summary>
          /// Retrieves the details of a payment schedule.
          /// </summary>
          /// <remarks>
          /// 
          /// </remarks>
          /// <exception cref="epay3.Web.Api.Sdk.Client.ApiException">Thrown when fails to make API call</exception>
          /// <param name="id">The unique identifier of the payment schedule.</param>
          /// <param name="impersonationAccountKey">The key that allows impersonation of another account for which the token is being processed. Only specify a value if the account being impersonated is different from the account that is submitting this request. (optional, default to )</param>
          /// <returns>GetPaymentScheduleResponseModel</returns>
          GetPaymentScheduleResponseModel PaymentSchedulesGet (string id, string impersonationAccountKey = null);
    
          /// <summary>
          /// Creates a payment schedule for a delayed payment or recurring payments.
          /// </summary>
          /// <remarks>
          /// 
          /// </remarks>
          /// <exception cref="epay3.Web.Api.Sdk.Client.ApiException">Thrown when fails to make API call</exception>
          /// <param name="postPaymentScheduleRequestModel">Contains the parameters for the payment schedule.</param>
          /// <param name="impersonationAccountKey">The key that allows impersonation of another account for which the transaction(s) will be processed. Only specify a value if the account being impersonated is different from the account that is submitting this request. (optional, default to )</param>
          /// <returns></returns>
          string PaymentSchedulesPost (PostPaymentScheduleRequestModel postPaymentScheduleRequestModel, string impersonationAccountKey = null);
      }
    
      /// <summary>
      /// Represents a collection of functions to interact with the API endpoints
      /// </summary>
      public class PaymentSchedulesApi : IPaymentSchedulesApi
      {
          /// <summary>
          /// Initializes a new instance of the <see cref="PaymentSchedulesApi"/> class.
          /// </summary>
          /// <returns></returns>
          public PaymentSchedulesApi(String basePath)
          {
              this.Configuration = new Configuration(new ApiClient(basePath));
  
              // ensure API client has configuration ready
              if (Configuration.ApiClient.Configuration == null)
              {
                  this.Configuration.ApiClient.Configuration = this.Configuration;
              }
          }
      
          /// <summary>
          /// Initializes a new instance of the <see cref="PaymentSchedulesApi"/> class
          /// using Configuration object
          /// </summary>
          /// <param name="configuration">An instance of Configuration</param>
          /// <returns></returns>
          public PaymentSchedulesApi(Configuration configuration = null)
          {
              if (configuration == null) // use the default one in Configuration
                  this.Configuration = Configuration.Default; 
              else
                  this.Configuration = configuration;
  
              // ensure API client has configuration ready
              if (Configuration.ApiClient.Configuration == null)
              {
                  this.Configuration.ApiClient.Configuration = this.Configuration;
              }
          }
  
          /// <summary>
          /// Gets the base path of the API client.
          /// </summary>
          /// <value>The base path</value>
          public String GetBasePath()
          {
              return this.Configuration.ApiClient.RestClient.BaseUrl.ToString();
          }
  
          /// <summary>
          /// Sets the base path of the API client.
          /// </summary>
          /// <value>The base path</value>
          [Obsolete("SetBasePath is deprecated, please do 'Configuraiton.ApiClient = new ApiClient(\"http://new-path\")' instead.")]
          public void SetBasePath(String basePath)
          {
              // do nothing
          }
      
          /// <summary>
          /// Gets or sets the configuration object
          /// </summary>
          /// <value>An instance of the Configuration</value>
          public Configuration Configuration {get; set;}
  
          /// <summary>
          /// Cancels an active payment schedule. 
          /// </summary>
          /// <exception cref="epay3.Web.Api.Sdk.Client.ApiException">Thrown when fails to make API call</exception>
          /// <param name="id">The public Id of the payment schedule.</param> 
          /// <param name="impersonationAccountKey">The key that allows impersonation of another account for which the transaction(s) will be processed. Only specify a value if the account being impersonated is different from the account that is submitting this request. (optional, default to )</param> 
          /// <returns></returns>
          public bool PaymentSchedulesCancel(string id, string impersonationAccountKey = null)
          {
              if (id == null)
                  throw new ApiException(400, "Missing required parameter 'id' when calling PaymentSchedulesApi->PaymentSchedulesCancel");
  
              var localVarPath = string.Format("/api/v1/paymentSchedules/{0}/cancel", id);
              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", "text/json", "application/xml", "text/xml", "application/x-www-form-urlencoded"
              };
              String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);
  
              // to determine the Accept header
              String[] localVarHttpHeaderAccepts = new String[] {
                  "application/json", "text/json", "application/xml", "text/xml"
              };
              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 (impersonationAccountKey != null) localVarHeaderParams.Add("impersonationAccountKey", Configuration.ApiClient.ParameterToString(impersonationAccountKey)); // header parameter
  
              // make the HTTP request
              IRestResponse localVarResponse = (IRestResponse)Configuration.ApiClient.CallApi(localVarPath,
                  Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                  localVarPathParams, localVarHttpContentType);
  
              int localVarStatusCode = (int)localVarResponse.StatusCode;
  
              if (localVarStatusCode == 400)
              {
                  var errorResponseModel = Newtonsoft.Json.JsonConvert.DeserializeObject<ErrorResponseModel>(localVarResponse.Content);
  
                  throw new ApiException(localVarStatusCode, errorResponseModel != null ? errorResponseModel.Message : null);
              }
              else if (localVarStatusCode >= 400)
              {
                  var errorResponseModel = Newtonsoft.Json.JsonConvert.DeserializeObject<ErrorResponseModel>(localVarResponse.Content);
  
                  throw new ApiException(localVarStatusCode, errorResponseModel != null ? errorResponseModel.Message : null);
              }
              else if (localVarStatusCode == 0)
                  throw new ApiException(localVarStatusCode, localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);
  
              return true;
          }
  
          /// <summary>
          /// Retrieves the details of a payment schedule. 
          /// </summary>
          /// <exception cref="epay3.Web.Api.Sdk.Client.ApiException">Thrown when fails to make API call</exception>
          /// <param name="id">The unique identifier of the payment schedule.</param> 
          /// <param name="impersonationAccountKey">The key that allows impersonation of another account for which the token is being processed. Only specify a value if the account being impersonated is different from the account that is submitting this request. (optional, default to )</param> 
          /// <returns>GetPaymentScheduleResponseModel</returns>
          public GetPaymentScheduleResponseModel PaymentSchedulesGet (string id, string impersonationAccountKey = null)
          {
              // verify the required parameter 'id' is set
              if (id == null)
                  throw new ApiException(400, "Missing required parameter 'id' when calling PaymentSchedulesApi->PaymentSchedulesGet");
  
              var localVarPath = "/api/v1/paymentSchedules/{id}";
  
              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[] {
  
              };
              String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);
  
              // to determine the Accept header
              String[] localVarHttpHeaderAccepts = new String[] {
  
gt:                 "application/json", "text/json", "application/xml", "text/xml"