Sha256: afcb4fb092892a03ebde84642441d284aaabfa263e7f9bd11243534ee339e145

Contents?: true

Size: 1.48 KB

Versions: 40

Compression:

Stored size: 1.48 KB

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

      # Fetches list of transactions belonging to given +mandate_id+.
      #
      # Optional +filters+ is a hash accepting following keys:
      # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
      # - +Status+: TransactionStatus {CREATED, SUCCEEDED, FAILED}
      # - +ResultCode+: string representing the transaction result
      def transactions(mandate_id, filters = {})
        url = url(mandate_id) + '/transactions'
        MangoPay.request(:get, url, {}, filters)
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
mangopay-3.28.0 lib/mangopay/mandate.rb
mangopay-3.27.0 lib/mangopay/mandate.rb
mangopay-3.26.1 lib/mangopay/mandate.rb
mangopay-3.26.0 lib/mangopay/mandate.rb
mangopay-3.25.1 lib/mangopay/mandate.rb
mangopay-3.25.0 lib/mangopay/mandate.rb
mangopay-3.24.1 lib/mangopay/mandate.rb
mangopay-3.24.0 lib/mangopay/mandate.rb
mangopay-3.23.0 lib/mangopay/mandate.rb
mangopay-3.22.0 lib/mangopay/mandate.rb
mangopay-3.21.0 lib/mangopay/mandate.rb
mangopay-3.20.0 lib/mangopay/mandate.rb
mangopay-3.19.0 lib/mangopay/mandate.rb
mangopay-3.18.0 lib/mangopay/mandate.rb
mangopay-3.17.0 lib/mangopay/mandate.rb
mangopay-3.16.0 lib/mangopay/mandate.rb
mangopay-3.15.0 lib/mangopay/mandate.rb
mangopay-3.14.0 lib/mangopay/mandate.rb
mangopay-3.13.2 lib/mangopay/mandate.rb
mangopay-3.12.0 lib/mangopay/mandate.rb