fetcheable_on_api 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/lib/fetcheable_on_api/filtreable.rb +3 -0
- data/lib/fetcheable_on_api/pagineable.rb +3 -1
- data/lib/fetcheable_on_api/sortable.rb +3 -0
- data/lib/fetcheable_on_api/version.rb +1 -1
- data/lib/fetcheable_on_api.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe1436fc856be39403a098964fd749c327d478b1cd4caa23776b030fa44dbb05
|
4
|
+
data.tar.gz: 382385b75448f082476ec23adfd4d360b5aa53b8a8cdfb072de4f1dcecf94d63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 913c31f970e2a6592a0aeab78f4f2e64d37074c120782fff145a7766e1e62a1d6469cf3dc36ec20ff09ff06a98d9978ba035e6a63cebc8beccb71eb96e398e69
|
7
|
+
data.tar.gz: 9ea51948fc95741f8e751a1371de3f7cdee1ea725751cc814df1b5916ab7c9e09adbc096f84e23ef70e1a20ca3590ec3fa0f75b428a60704ef934ae3d14304b5
|
data/README.md
CHANGED
@@ -253,6 +253,13 @@ $ curl -X GET \
|
|
253
253
|
]
|
254
254
|
```
|
255
255
|
|
256
|
+
When you use pagination, additional information is returned in the Header
|
257
|
+
|
258
|
+
- `Pagination-Current-Page`: the current page number
|
259
|
+
- `Pagination-Per`: the number of records per page
|
260
|
+
- `Pagination-Total-Pages`: the total number of pages
|
261
|
+
- `Pagination-Total-Count`: the total number of records
|
262
|
+
|
256
263
|
### Filtering
|
257
264
|
|
258
265
|
The `filter` query parameter is reserved for filtering data and the controller must set the attributes allowed to be filtered.
|
@@ -45,6 +45,9 @@ module FetcheableOnApi
|
|
45
45
|
protected
|
46
46
|
|
47
47
|
def apply_filters(collection)
|
48
|
+
return collection unless valid_parameters?(params)
|
49
|
+
return collection unless valid_parameters?(params[:filter])
|
50
|
+
|
48
51
|
return collection if params[:filter].blank?
|
49
52
|
|
50
53
|
filter_params = params.require(:filter)
|
@@ -20,7 +20,9 @@ module FetcheableOnApi
|
|
20
20
|
protected
|
21
21
|
|
22
22
|
def apply_pagination(collection)
|
23
|
-
return collection
|
23
|
+
return collection unless valid_parameters?(params)
|
24
|
+
return collection unless valid_parameters?(params[:page])
|
25
|
+
return collection unless params[:page].present?
|
24
26
|
|
25
27
|
limit = params[:page].fetch(
|
26
28
|
:size,
|
data/lib/fetcheable_on_api.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fetcheable_on_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabien
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|