Module: MangoApi::Mandates

Extended by:
UriProvider
Defined in:
lib/mangopay/api/service/mandates.rb

Overview

Provides API method delegates concerning the Mandate entity

Class Method Summary collapse

Methods included from UriProvider

provide_uri

Class Method Details

.all {|filter_request = FilterRequest.new| ... } ⇒ Array

Retrieves mandate entity pages. Allows configuration of paging and sorting parameters by yielding a filtering object to a provided block. When no filters are specified, will retrieve the first page of 10 newest results.

Allowed FilterRequest params:

  • page

  • per_page

  • sort_field and sort_direction

  • before_date

  • after_date

to provided filters

Yields:

Returns:

  • (Array)

    array of hashed mandate entities corresponding



63
64
65
66
67
68
69
# File 'lib/mangopay/api/service/mandates.rb', line 63

def all
  uri = provide_uri(:get_mandates)
  filter_request = nil
  yield filter_request = FilterRequest.new if block_given?
  results = HttpClient.get(uri, filter_request)
  parse_results results
end

.cancel(id) ⇒ Mandate

Cancels a mandate.

Parameters:

  • +id+ (String)

    ID of the mandate to cancel

Returns:

  • (Mandate)

    the updated Mandate entity object



43
44
45
46
47
# File 'lib/mangopay/api/service/mandates.rb', line 43

def cancel(id)
  uri = provide_uri(:cancel_mandate, id)
  response = HttpClient.put(uri)
  parse response
end

.create(mandate, id_key = nil) ⇒ Mandate

Creates a new mandate entity.

Mandate properties:

  • Required

    • bank_account_id

    • culture

    • return_url

  • Optional

    • tag

Parameters:

  • +mandate+ (Mandate)

    model object of mandate to be created

  • +id_key+ (String)

    idempotency key for future response replication

Returns:

  • (Mandate)

    the newly-created Mandate entity object



23
24
25
26
27
# File 'lib/mangopay/api/service/mandates.rb', line 23

def create(mandate, id_key = nil)
  uri = provide_uri(:create_mandate)
  response = HttpClient.post(uri, mandate, id_key)
  parse response
end

.get(id) ⇒ Mandate

Retrieves a mandate entity.

Parameters:

  • +id+ (String)

    ID of the mandate to retrieve

Returns:

  • (Mandate)

    the requested Mandate entity object



33
34
35
36
37
# File 'lib/mangopay/api/service/mandates.rb', line 33

def get(id)
  uri = provide_uri(:get_mandate, id)
  response = HttpClient.get(uri)
  parse response
end

.of_bank_account(user_id, account_id) {|filter_request = FilterRequest.new| ... } ⇒ Array

Retrieves pages of mandate entities belonging to a certain bank account. Allows configuration of paging and sorting parameters by yielding a filtering object to a provided block. When no filters are specified, will retrieve the first page of 10 newest results

Allowed FilterRequest params:

  • page

  • per_page

  • sort_field and sort_direction

  • before_date

  • after_date

to retrieve to provided filters

Parameters:

  • +user_id+ (String)

    ID of the user owning the bank account

  • +account_id+ (String)

    ID of the bank account whose mandates

Yields:

Returns:

  • (Array)

    array of hashed mandate entities corresponding



111
112
113
114
115
116
117
# File 'lib/mangopay/api/service/mandates.rb', line 111

def (user_id, )
  uri = provide_uri(:get_accounts_mandates, user_id, )
  filter_request = nil
  yield filter_request = FilterRequest.new if block_given?
  results = HttpClient.get(uri, filter_request)
  parse_results results
end

.of_user(id) {|filter_request = FilterRequest.new| ... } ⇒ Array

Retrieves pages of mandate entities belonging to a certain user. Allows configuration of paging and sorting parameters by yielding a filtering object to a provided block. When no filters are specified, will retrieve the first page of 10 newest results

Allowed FilterRequest params:

  • page

  • per_page

  • sort_field and sort_direction

  • before_date

  • after_date

to provided filters

Parameters:

  • +id+ (String)

    ID of the user whose mandates to retrieve

Yields:

Returns:

  • (Array)

    array of hashed mandate entities corresponding



86
87
88
89
90
91
92
# File 'lib/mangopay/api/service/mandates.rb', line 86

def of_user(id)
  uri = provide_uri(:get_users_mandates, id)
  filter_request = nil
  yield filter_request = FilterRequest.new if block_given?
  results = HttpClient.get(uri, filter_request)
  parse_results results
end