diff --git a/CHANGELOG.md b/CHANGELOG.md index 96dee69..6816f81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ changes here when sending pull requests. Also send corrections if you spot any m ## v0.6.0 (2017-01-11) +* Documentation + - Added more sorting endpoints and improved documentation based on sophatar comments (lmmendes) + +## v0.6.1 (2017-01-11) + * Documentation - Added sorting documentation (lmmendes) diff --git a/v2/sections/sorting.md b/v2/sections/sorting.md index 275a773..a8cca52 100644 --- a/v2/sections/sorting.md +++ b/v2/sections/sorting.md @@ -8,6 +8,8 @@ Here is an example searching for a Coupon campaign with the name equal (name_eq) GET https://api.passworks.io/v2/coupons/?q[name_eq]=Una Salus Victus ``` +> You can ignore the trailing slash in the end of the URL. + The following predicates are also available: | Sort predicate | Description | @@ -45,24 +47,76 @@ GET https://api.passworks.io/v2/coupons/?q[s]=created_at+asc To request ordering from a given attribute with a direction (ascending or descending) you need to to use the `q[s]=` following the attribute that you wish to order `created_at` following with a plus (+) signal and the direction of sorting `asc` or `desc` -So sorting the for the attribute name in descending order whould be doing the following: +So sorting the for the attribute name in descending order would be doing the following: ``` https://api.passworks.io/v2/coupons/?q[s]=name+desc ``` +### Sorting multiple with parameters ordering and using pagination at the same time + +You can append one or more filters to the query string then event apply the desired sort and finally specify a given page to be retrieved. + +See the following example filtering for two parameters "name" (equal) and "redeem_count" (equal) and then asking for the results sorted by "created_at" in descending order and finally asking for the second page (page=2) of the results displaying 4 results per page (per_page=4). + +``` +GET https://api.passworks.io/v2/coupons/?q[name_eq]=Una Salus Victus&q[redeem_count_eq]=0&q[s]=created_at+desc&page=2&per_page=4 +``` + +You can mix and match the query parameters the order doesn't matter. + + ### Sortable endpoints -You can sort and order the attributes inside the following endpoints +You can sort and order the attributes inside the following endpoints: + +Sort campaign collection attributes - https://api.passworks.io/v2/coupons/ - https://api.passworks.io/v2/event_tickets/ - https://api.passworks.io/v2/generics/ - https://api.passworks.io/v2/store_cards/ - https://api.passworks.io/v2/boarding_passes/ -- https://api.passworks.io/v2/coupons/campaign id/passes -- https://api.passworks.io/v2/event_tickets/campaign id/passes -- https://api.passworks.io/v2/generics/campaign id/passes -- https://api.passworks.io/v2/store_cards/campaign id/passes -- https://api.passworks.io/v2/boarding_passes/campaign id/passes + +Sort passes collection side a specific campaign + +- https://api.passworks.io/v2/coupons/campaign_id/passes +- https://api.passworks.io/v2/event_tickets/campaign_id/passes +- https://api.passworks.io/v2/generics/campaign_id/passes +- https://api.passworks.io/v2/store_cards/campaign_id/passes +- https://api.passworks.io/v2/boarding_passes/campaign_id/passes + +Sort registrations collection inside a specific campaign + +- https://api.passworks.io/v2/coupons/campaign_id/registrations +- https://api.passworks.io/v2/event_tickets/campaign_id/registrations +- https://api.passworks.io/v2/generics/campaign_id/registrations +- https://api.passworks.io/v2/store_cards/campaign_id/registrations +- https://api.passworks.io/v2/boarding_passes/campaign_id/registrations + +Sort redeems collection inside a specific campaign + +- https://api.passworks.io/v2/coupons/campaign_id/redeems +- https://api.passworks.io/v2/event_tickets/campaign_id/redeems +- https://api.passworks.io/v2/generics/campaign_id/redeems +- https://api.passworks.io/v2/store_cards/campaign_id/redeems +- https://api.passworks.io/v2/boarding_passes/campaign_id/redeems + +Sort registrations collection inside a specific campaign and pass + +- https://api.passworks.io/v2/coupons/campaign_id/passes/pass_id/registrations +- https://api.passworks.io/v2/event_tickets/campaign_id/passes/pass_id/registrations +- https://api.passworks.io/v2/generics/campaign_id/passes/pass_id/registrations +- https://api.passworks.io/v2/store_cards/campaign_id/passes/pass_id/registrations +- https://api.passworks.io/v2/boarding_passes/campaign_id/passes/pass_id/registrations + +Sort redeems collection inside a specific campaign and pass + +- https://api.passworks.io/v2/coupons/campaign_id/passes/pass_id/redeems +- https://api.passworks.io/v2/event_tickets/campaign_id/passes/pass_id/redeems +- https://api.passworks.io/v2/generics/campaign_id/passes/pass_id/redeems +- https://api.passworks.io/v2/store_cards/campaign_id/passes/pass_id/redeems +- https://api.passworks.io/v2/boarding_passes/campaign_id/passes/pass_id/redeems + +> Please replace the `campaign_id` and `pass_id` with the appropriate resource ID from your side.