/// <summary>
        /// Issues a refund for a previously processed payment. You must issue
        /// a refund within 60 days of the associated payment.
        /// You cannot issue a partial refund for a split tender payment. You must
        /// instead issue a full or partial refund for a particular tender, by
        /// providing the applicable tender id to the V1CreateRefund endpoint.
        /// Issuing a full refund for a split tender payment refunds all tenders
        /// associated with the payment.
        /// Issuing a refund for a card payment is not reversible. For development
        /// purposes, you can create fake cash payments in Square Point of Sale and
        /// refund them.
        /// </summary>
        /// <param name="locationId">Required parameter: The ID of the original payment's associated location.</param>
        /// <param name="body">Required parameter: An object containing the fields to POST for the request.  See the corresponding object definition for field details.</param>
        /// <return>Returns the Models.V1Refund response from the API call</return>
        public Models.V1Refund CreateRefund(string locationId, Models.V1CreateRefundRequest body)
        {
            Task <Models.V1Refund> t = CreateRefundAsync(locationId, body);

            ApiHelper.RunTaskSynchronously(t);
            return(t.Result);
        }
        /// <summary>
        /// Issues a refund for a previously processed payment. You must issue
        /// a refund within 60 days of the associated payment.
        /// You cannot issue a partial refund for a split tender payment. You must
        /// instead issue a full or partial refund for a particular tender, by
        /// providing the applicable tender id to the V1CreateRefund endpoint.
        /// Issuing a full refund for a split tender payment refunds all tenders
        /// associated with the payment.
        /// Issuing a refund for a card payment is not reversible. For development
        /// purposes, you can create fake cash payments in Square Point of Sale and
        /// refund them.
        /// </summary>
        /// <param name="locationId">Required parameter: The ID of the original payment's associated location.</param>
        /// <param name="body">Required parameter: An object containing the fields to POST for the request.  See the corresponding object definition for field details.</param>
        /// <return>Returns the Models.V1Refund response from the API call</return>
        public async Task <Models.V1Refund> CreateRefundAsync(string locationId, Models.V1CreateRefundRequest body, CancellationToken cancellationToken = default)
        {
            //the base uri for api requests
            string _baseUri = config.GetBaseUri();

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);

            _queryBuilder.Append("/v1/{location_id}/refunds");

            //process optional template parameters
            ApiHelper.AppendUrlWithTemplateParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "location_id", locationId }
            });

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", userAgent },
                { "accept", "application/json" },
                { "content-type", "application/json; charset=utf-8" },
                { "Square-Version", config.SquareVersion }
            };

            //append body params
            var _body = ApiHelper.JsonSerialize(body);

            //prepare the API call request to fetch the response
            HttpRequest _request = GetClientInstance().PostBody(_queryBuilder.ToString(), _headers, _body);

            if (HttpCallBack != null)
            {
                HttpCallBack.OnBeforeHttpRequestEventHandler(GetClientInstance(), _request);
            }

            _request = await authManagers["global"].ApplyAsync(_request).ConfigureAwait(false);

            //invoke request and get response
            HttpStringResponse _response = await GetClientInstance().ExecuteAsStringAsync(_request, cancellationToken).ConfigureAwait(false);

            HttpContext _context = new HttpContext(_request, _response);

            if (HttpCallBack != null)
            {
                HttpCallBack.OnAfterHttpResponseEventHandler(GetClientInstance(), _response);
            }

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);

            var _responseModel = ApiHelper.JsonDeserialize <Models.V1Refund>(_response.Body);

            _responseModel.Context = _context;
            return(_responseModel);
        }