@@ -8,34 +8,38 @@ class AlmaAPIException(Exception):
88
99class AlmaAPI :
1010
11- def __init__ (self , api , api_key , query_params = None ):
11+ def __init__ (self , api , api_key ):
1212 self .api_url = 'https://api-eu.hosted.exlibrisgroup.com/almaws/v1/' + api + '/'
1313 self .api_key = '?apikey=' + api_key
14- self .query_params = ''
1514
15+ def get (self , mms_id , query_params = None ):
16+ __query_params__ = ''
1617 if query_params is not None :
1718 for key , value in query_params .items ():
18- self . query_params += '&' + key + '=' + value
19+ __query_params__ += '&' + key + '=' + value
1920
20- def get (self , mms_id ):
21- url = self .api_url + mms_id + self .api_key + self .query_params
21+ url = self .api_url + mms_id + self .api_key + __query_params__
2222
2323 (response , content ) = http .Http ().request (url )
2424
25- if response .status != '200' :
26- # print(response)
25+ if response .status != 200 :
2726 root = ElementTree .ElementTree (ElementTree .fromstring (content )).getroot ()
2827 error_message = root [1 ][0 ][1 ].text
2928 raise AlmaAPIException (str (response .status ) + ': ' + error_message )
3029
3130 return content .decode ('utf8' )
3231
33- def put (self , mms_id , body ):
34- url = self .api_url + mms_id + self .api_key + self .query_params
32+ def put (self , mms_id , body , query_params = None ):
33+ __query_params__ = ''
34+ if query_params is not None :
35+ for key , value in query_params .items ():
36+ __query_params__ += '&' + key + '=' + value
37+
38+ url = self .api_url + mms_id + self .api_key + __query_params__
3539 headers = {'Content-type' : 'application/xml' }
3640
3741 (response , content ) = http .Http ().request (url , 'PUT' , headers = headers , body = body )
38- if response .status != ' 200' :
42+ if response .status != 200 :
3943 root = ElementTree .ElementTree (ElementTree .fromstring (content )).getroot ()
4044 error_message = root [1 ][0 ][1 ].text
4145 raise AlmaAPIException (str (response .status ) + ': ' + error_message )
0 commit comments