module MangoPay::HTTPCalls::Fetch::ClassMethods
Public Instance Methods
-
Fetching single_entity by
id
:MangoPay::User.fetch(“user-id”) # => {“FirstName”=>“Mango”, “LastName”=>“Pay”, …}
-
or fetching multiple_entities with optional
filters
hash, including pagination and sorting paramspage
,per_page
,sort
(see docs.mangopay.com/api-references/pagination/):MangoPay::User.fetch() # => [{…}, …]: list of user data hashes (10 per page by default) MangoPay::User.fetch({'page' => 2, 'per_page' => 3}) # => list of 3 hashes from 2nd page
MangoPay::BankAccount.fetch
(user_id, {'sort' => 'CreationDate:desc'}) # => bank accounts by user, sorting by date descending (with default pagination)MangoPay::BankAccount.fetch
(user_id, {'sort' => 'CreationDate:desc', 'page' => 2, 'per_page' => 3}) # both sorting and pagination params provided -
For paginated queries the
filters
param will be supplemented bytotal_pages
andtotal_items
info:MangoPay::User.fetch(filter = {'page' => 2, 'per_page' => 3}) filter # => {“page”=>2, “per_page”=>3, “total_pages”=>1969, “total_items”=>5905}
# File lib/mangopay/http_calls.rb, line 55 def fetch(id_or_filters = nil, idempotency_key = nil) id, filters = HTTPCalls::Fetch.parse_id_or_filters(id_or_filters) response = MangoPay.request(:get, url(id), {}, filters, idempotency_key) end