File tree Expand file tree Collapse file tree 1 file changed +31
-2
lines changed Expand file tree Collapse file tree 1 file changed +31
-2
lines changed Original file line number Diff line number Diff line change 1
1
import requests
2
+ from urllib import parse
2
3
3
4
4
5
class JsonBox :
@@ -7,14 +8,42 @@ class JsonBox:
7
8
def __init__ (self , service_host = "https://jsonbox.io" ):
8
9
self .service_host = service_host
9
10
10
- def _get_url (self , box_id , collection_or_record = None , sort_by = None ):
11
+ def _get_url (self ,
12
+ box_id ,
13
+ collection_or_record = None ,
14
+ sort_by = None ,
15
+ skip = None ,
16
+ limit = None ,
17
+ query_key = None ,
18
+ query_value = None ,
19
+ query_type = None ):
11
20
url = "{0}/{1}" .format (self .service_host , box_id )
12
21
13
22
if collection_or_record :
14
23
url = "{0}/{1}" .format (url , collection_or_record )
15
24
25
+ params = {}
16
26
if sort_by :
17
- url = "{0}?sort={1}" .format (url , sort_by )
27
+ params ["sort" ] = sort_by
28
+
29
+ if skip :
30
+ params ["skip" ] = skip
31
+
32
+ if limit :
33
+ params ["limit" ] = limit
34
+
35
+ if query_key :
36
+ params ["query_key" ] = query_key
37
+
38
+ if query_value :
39
+ params ["query_value" ] = query_value
40
+
41
+ if query_type :
42
+ params ["query_type" ] = query_type
43
+
44
+ if len (params .keys ()) > 0 :
45
+ param_str = parse .urlencode (params )
46
+ url = "{0}?{1}" .format (url , param_str )
18
47
19
48
return url
20
49
You can’t perform that action at this time.
0 commit comments