Class: MangoPay::Mandate

Inherits:
Resource show all
Includes:
HTTPCalls::Fetch
Defined in:
lib/mangopay/mandate.rb

Overview

Class Method Summary collapse

Methods included from HTTPCalls::Fetch

included, parse_id_or_filters

Methods inherited from Resource

class_name, url

Class Method Details

.cancel(id) ⇒ Object



15
16
17
18
# File 'lib/mangopay/mandate.rb', line 15

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

.create(params, idempotency_key = nil) ⇒ Object



10
11
12
13
# File 'lib/mangopay/mandate.rb', line 10

def create(params, idempotency_key = nil)
  url = "#{MangoPay.api_path}/mandates/directdebit/web"
  MangoPay.request(:post, url, params, {}, idempotency_key)
end

.fetch_for_user(user_id, filters = {}) ⇒ Object



20
21
22
23
# File 'lib/mangopay/mandate.rb', line 20

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

.fetch_for_user_bank_account(user_id, bank_account_id, filters = {}) ⇒ Object



25
26
27
28
# File 'lib/mangopay/mandate.rb', line 25

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

.transactions(mandate_id, filters = {}) ⇒ Object

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 SUCCEEDED, FAILED

  • ResultCode: string representing the transaction result



36
37
38
39
# File 'lib/mangopay/mandate.rb', line 36

def transactions(mandate_id, filters = {})
  url = url(mandate_id) + '/transactions'
  MangoPay.request(:get, url, {}, filters)
end