Sha256: 7249ee61eab8882636cbc63bcb0dcd7b6dd10a4f660338ae3470b24eb4b2f6d6

Contents?: true

Size: 1.93 KB

Versions: 6

Compression:

Stored size: 1.93 KB

Contents

# typed: false
# frozen_string_literal: true

module Mercadopago
  ###
  # Access to Advanced Payments

  class AdvancedPayment < MPBase
    def search(filters: nil, request_options: nil)
      raise TypeError, 'Param filters must be a Hash' unless filters.nil? || filters.is_a?(Hash)

      _get(uri: '/v1/advanced_payments/search', filters: filters, request_options: request_options)
    end

    def get(advanced_payment_id, request_options: nil)
      _get(uri: "/v1/advanced_payments/#{advanced_payment_id}", request_options: request_options)
    end

    def create(advanced_payment_data, request_options: nil)
      raise TypeError, 'Param advanced_payment_data must be a Hash' unless advanced_payment_data.is_a?(Hash)

      _post(uri: '/v1/advanced_payments', data: advanced_payment_data, request_options: request_options)
    end

    def capture(advanced_payment_id, request_options: nil)
      capture_data = { capture: true }
      _put(uri: "/v1/advanced_payments/#{advanced_payment_id}", data: capture_data, request_options: request_options)
    end

    def update(advanced_payment_id, advanced_payment_data, request_options: nil)
      raise TypeError, 'Param advanced_payment_data must be a Hash' unless advanced_payment_data.is_a?(Hash)

      _put(uri: "/v1/advanced_payments/#{advanced_payment_id}", data: advanced_payment_data,
           request_options: request_options)
    end

    def cancel(advanced_payment_id, request_options: nil)
      cancel_data = { status: 'cancelled' }
      _put(uri: "/v1/advanced_payments/#{advanced_payment_id}", data: cancel_data, request_options: request_options)
    end

    def update_release_date(advanced_payment_id, release_date, request_options: nil)
      disbursement_data = { money_release_date: release_date.strftime('%Y-%m-%d %H:%M:%S.%f') }
      _post(uri: "/v1/advanced_payments/#{advanced_payment_id}/disburses", data: disbursement_data,
            request_options: request_options)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mercadopago-sdk-2.2.1 lib/mercadopago/resources/advanced_payment.rb
mercadopago-sdk-2.2.0 lib/mercadopago/resources/advanced_payment.rb
mercadopago-sdk-2.1.0 lib/mercadopago/resources/advanced_payment.rb
mercadopago-sdk-2.0.3 lib/mercadopago/resources/advanced_payment.rb
mercadopago-sdk-2.0.2 lib/mercadopago/resources/advanced_payment.rb
mercadopago-sdk-2.0.1 lib/mercadopago/resources/advanced_payment.rb