Sha256: 7be36592ce1feda0c50176202e6721b3de9ac05c07db66804a1707959b8846c1

Contents?: true

Size: 967 Bytes

Versions: 7

Compression:

Stored size: 967 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

7 entries across 7 versions & 1 rubygems

Version Path
mangopay-3.0.30.1 lib/mangopay/mandate.rb
mangopay-3.0.30 lib/mangopay/mandate.rb
mangopay-3.0.29 lib/mangopay/mandate.rb
mangopay-3.0.28 lib/mangopay/mandate.rb
mangopay-3.0.27 lib/mangopay/mandate.rb
mangopay-3.0.26 lib/mangopay/mandate.rb
mangopay-3.0.25.pre.alpha.pre.20 lib/mangopay/mandate.rb