Module: MangoPay::HTTPCalls::Fetch::ClassMethods
- Defined in:
- lib/mangopay/http_calls.rb
Instance Method Summary collapse
-
#fetch(id_or_filters = nil, idempotency_key = nil) ⇒ Object
-
Fetching single_entity by
id
:.
-
Instance Method Details
#fetch(id_or_filters = nil, idempotency_key = nil) ⇒ Object
-
Fetching single_entity by
id
:MangoPay::User.fetch(“user-id”) # => “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(=> 2, ‘per_page’ => 3) # => list of 3 hashes from 2nd page MangoPay::BankAccount.fetch(user_id, => ‘CreationDate:desc’) # => bank accounts by user, sorting by date descending (with default pagination) MangoPay::BankAccount.fetch(user_id, => ‘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 = => 2, ‘per_page’ => 3) filter # => “per_page”=>3, “total_pages”=>1969, “total_items”=>5905
55 56 57 58 |
# 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 |