module MangoApi::Mandates
Provides API method delegates concerning the Mandate
entity
Public Class Methods
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
@return [Array] array of hashed mandate entities corresponding to provided filters
# 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
Cancels a mandate.
@param id
[String] ID of the mandate to cancel @return [Mandate] the updated Mandate entity object
# 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
Creates a new mandate entity.
Mandate
properties:
-
Required
-
bank_account_id
-
culture
-
return_url
-
-
Optional
-
tag
-
@param mandate
[Mandate] model object of mandate to be created @param id_key
[String] idempotency key for future response replication @return [Mandate] the newly-created Mandate entity object
# 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
Retrieves a mandate entity.
@param id
[String] ID of the mandate to retrieve @return [Mandate] the requested Mandate entity object
# 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
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
@param user_id
[String] ID of the user owning the bank account @param account_id
[String] ID of the bank account whose mandates to retrieve @return [Array] array of hashed mandate entities corresponding to provided filters
# File lib/mangopay/api/service/mandates.rb, line 111 def of_bank_account(user_id, account_id) uri = provide_uri(:get_accounts_mandates, user_id, account_id) filter_request = nil yield filter_request = FilterRequest.new if block_given? results = HttpClient.get(uri, filter_request) parse_results results end
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
@param id
[String] ID of the user whose mandates to retrieve @return [Array] array of hashed mandate entities corresponding to provided filters
# 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
Private Class Methods
Parses a JSON-originating hash into the corresponding Mandate entity object.
@param response
[Hash] JSON-originating data hash @return [Mandate] corresponding Mandate entity object
# File lib/mangopay/api/service/mandates.rb, line 137 def parse(response) MangoModel::Mandate.new.dejsonify response end
Parses an array of JSON-originating hashes into the corresponding Mandate entity objects.
@param results
[Array] JSON-originating data hashes @return [Array] parsed Mandate entity objects
# File lib/mangopay/api/service/mandates.rb, line 126 def parse_results(results) results.collect do |entity| parse entity end end