@@ -55,31 +55,19 @@ def read(self,
55
55
url = self ._get_url (box_id , collection_or_record , sort_by , skip , limit , query )
56
56
57
57
response = requests .get (url )
58
- if response .ok :
59
- json_data = response .json ()
60
- return json_data
61
- else :
62
- return False
58
+ return self ._check_response (response )
63
59
64
60
def write (self , data , box_id , collection = None ):
65
61
url = self ._get_url (box_id , collection )
66
62
67
63
response = requests .post (url , json = data )
68
- if response .ok :
69
- json_data = response .json ()
70
- return json_data
71
- else :
72
- return False
64
+ return self ._check_response (response )
73
65
74
66
def update (self , data , box_id , record_id ):
75
67
url = self ._get_url (box_id , record_id )
76
68
77
69
response = requests .put (url , json = data )
78
- if response .ok :
79
- json_data = response .json ()
80
- return json_data
81
- else :
82
- return False
70
+ return self ._check_response (response )
83
71
84
72
def delete (self , box_id , record_ids ):
85
73
if isinstance (record_ids , list ):
@@ -94,6 +82,9 @@ def _delete_one(self, box_id, record_id):
94
82
url = self ._get_url (box_id , record_id )
95
83
96
84
response = requests .delete (url )
85
+ return self ._check_response (response )
86
+
87
+ def _check_response (self , response ):
97
88
if response .ok :
98
89
json_data = response .json ()
99
90
return json_data
0 commit comments