Sha256: d4a1903db1bd712ab9335963155a5a676cc4b8f5cd7af3c0a6c5b046377f5d56

Contents?: true

Size: 999 Bytes

Versions: 3

Compression:

Stored size: 999 Bytes

Contents

module MangoPay

  # See https://docs.mangopay.com/api-references/mandates/
  class Mandate < Resource
    include HTTPCalls::Fetch

    class << self

      # +params+: hash; see https://docs.mangopay.com/api-references/mandates/
      def create(params, idempotency_key = nil)
        url = "#{MangoPay.api_path}/mandates/directdebit/web"
        MangoPay.request(:post, url, params, {}, idempotency_key)
      end

      def cancel(id)
        url = "#{MangoPay.api_path}/mandates/#{id}/cancel"
        MangoPay.request(:put, url)
      end

      def fetch_for_user(user_id, filters = {})
        url = "#{MangoPay.api_path}/users/#{user_id}/mandates"
        MangoPay.request(:get, url, {}, filters)
      end

      def fetch_for_user_bank_account(user_id, bank_account_id, filters = {})
        url = "#{MangoPay.api_path}/users/#{user_id}/bankaccounts/#{bank_account_id}/mandates"
        MangoPay.request(:get, url, {}, filters)
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mangopay-3.0.25 lib/mangopay/mandate.rb
mangopay-3.0.23 lib/mangopay/mandate.rb
mangopay-3.0.21 lib/mangopay/mandate.rb