Skip to content

Commit

Permalink
updated sorting endpoints, improved documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lmmendes committed Jan 11, 2017
1 parent 6cce4b9 commit 1ecc4e2
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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)

Expand Down
68 changes: 61 additions & 7 deletions v2/sections/sorting.md
Expand Up @@ -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 |
Expand Down Expand Up @@ -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.

0 comments on commit 1ecc4e2

Please sign in to comment.