@@ -16,9 +16,10 @@ class APIResource(object):
1616 @classmethod
1717 def _get (cls , uri , params = {}, object_hook = None ):
1818 headers = {
19- "Authorization" : "ApiKey " + warrant .api_key ,
2019 "User-Agent" : warrant .user_agent
2120 }
21+ if warrant .api_key != "" :
22+ headers ["Authorization" ] = "ApiKey " + warrant .api_key
2223 resp = requests .get (url = warrant .api_endpoint + uri , headers = headers , params = params )
2324 if resp .status_code == 200 :
2425 return resp .json (object_hook = object_hook )
@@ -28,9 +29,10 @@ def _get(cls, uri, params={}, object_hook=None):
2829 @classmethod
2930 def _post (cls , uri , json = {}, object_hook = None ):
3031 headers = {
31- "Authorization" : "ApiKey " + warrant .api_key ,
3232 "User-Agent" : warrant .user_agent
3333 }
34+ if warrant .api_key != "" :
35+ headers ["Authorization" ] = "ApiKey " + warrant .api_key
3436 resp = requests .post (url = warrant .api_endpoint + uri , headers = headers , json = json )
3537 if resp .status_code == 200 :
3638 return resp .json (object_hook = object_hook )
@@ -40,9 +42,10 @@ def _post(cls, uri, json={}, object_hook=None):
4042 @classmethod
4143 def _put (cls , uri , json = {}, object_hook = None ):
4244 headers = {
43- "Authorization" : "ApiKey " + warrant .api_key ,
4445 "User-Agent" : warrant .user_agent
4546 }
47+ if warrant .api_key != "" :
48+ headers ["Authorization" ] = "ApiKey " + warrant .api_key
4649 resp = requests .put (url = warrant .api_endpoint + uri , headers = headers , json = json )
4750 if resp .status_code == 200 :
4851 resp .json (object_hook = object_hook )
@@ -52,9 +55,10 @@ def _put(cls, uri, json={}, object_hook=None):
5255 @classmethod
5356 def _delete (cls , uri , params = {}, json = {}):
5457 headers = {
55- "Authorization" : "ApiKey " + warrant .api_key ,
5658 "User-Agent" : warrant .user_agent
5759 }
60+ if warrant .api_key != "" :
61+ headers ["Authorization" ] = "ApiKey " + warrant .api_key
5862 resp = requests .delete (url = warrant .api_endpoint + uri , headers = headers , params = params , json = json )
5963 if resp .status_code != 200 :
6064 raise WarrantException (msg = resp .text , status_code = resp .status_code )
0 commit comments