require_relative '../service'
module Adyen

  # NOTE: This class is auto generated by OpenAPI Generator
  # Ref: https://openapi-generator.tech
  #
  # Do not edit the class manually.
  class ModificationsApi < Service
    attr_accessor :service, :version

    def initialize(client, version = DEFAULT_VERSION)
      super(client, version, 'Checkout')
    end

    # Cancel an authorised payment
    def cancel_authorised_payment(request, headers: {})
      endpoint = '/cancels'.gsub(/{.+?}/, '%s')
      endpoint = endpoint.gsub(%r{^/}, '')
      endpoint = format(endpoint)
      
      action = { method: 'post', url: endpoint }
      @client.call_adyen_api(@service, action, request, headers, @version)
    end

    # Cancel an authorised payment
    def cancel_authorised_payment_by_psp_reference(request, payment_psp_reference, headers: {})
      endpoint = '/payments/{paymentPspReference}/cancels'.gsub(/{.+?}/, '%s')
      endpoint = endpoint.gsub(%r{^/}, '')
      endpoint = format(endpoint, payment_psp_reference)
      
      action = { method: 'post', url: endpoint }
      @client.call_adyen_api(@service, action, request, headers, @version)
    end

    # Capture an authorised payment
    def capture_authorised_payment(request, payment_psp_reference, headers: {})
      endpoint = '/payments/{paymentPspReference}/captures'.gsub(/{.+?}/, '%s')
      endpoint = endpoint.gsub(%r{^/}, '')
      endpoint = format(endpoint, payment_psp_reference)
      
      action = { method: 'post', url: endpoint }
      @client.call_adyen_api(@service, action, request, headers, @version)
    end

    # Refund a captured payment
    def refund_captured_payment(request, payment_psp_reference, headers: {})
      endpoint = '/payments/{paymentPspReference}/refunds'.gsub(/{.+?}/, '%s')
      endpoint = endpoint.gsub(%r{^/}, '')
      endpoint = format(endpoint, payment_psp_reference)
      
      action = { method: 'post', url: endpoint }
      @client.call_adyen_api(@service, action, request, headers, @version)
    end

    # Refund or cancel a payment
    def refund_or_cancel_payment(request, payment_psp_reference, headers: {})
      endpoint = '/payments/{paymentPspReference}/reversals'.gsub(/{.+?}/, '%s')
      endpoint = endpoint.gsub(%r{^/}, '')
      endpoint = format(endpoint, payment_psp_reference)
      
      action = { method: 'post', url: endpoint }
      @client.call_adyen_api(@service, action, request, headers, @version)
    end

    # Update an authorised amount
    def update_authorised_amount(request, payment_psp_reference, headers: {})
      endpoint = '/payments/{paymentPspReference}/amountUpdates'.gsub(/{.+?}/, '%s')
      endpoint = endpoint.gsub(%r{^/}, '')
      endpoint = format(endpoint, payment_psp_reference)
      
      action = { method: 'post', url: endpoint }
      @client.call_adyen_api(@service, action, request, headers, @version)
    end

  end
end
