@@ -9,6 +9,7 @@ class NetLicensing:
99 def __init__ (self , nlic_apikey , nlic_baseurl = NLIC_API_URL ):
1010 self .nlic_apikey = nlic_apikey
1111 self .nlic_baseurl = nlic_baseurl
12+
1213 # https://requests.readthedocs.io/en/master/user/advanced/
1314 requests_session = requests .Session ()
1415 requests_adapters = requests .adapters .HTTPAdapter (max_retries = 3 )
@@ -35,14 +36,23 @@ def __init__(self, code=None, reason=None):
3536
3637 @staticmethod
3738 def get_response (response ):
39+ verbose = True
40+ if verbose :
41+ print ('NetLicensing response:' )
42+ print (response .url )
43+ print (response .headers )
44+ print (response .status_code )
45+ print (response .elapsed )
46+
3847 if response .status_code != requests .codes .ok :
3948 raise NetLicensing .HttpError (response .status_code , response .reason )
4049 result = response .json ()
41- if result ['code' ] != 0 :
42- raise NetLicensing .ResponseError (
43- result .get ('code' ), result .get ('message' )
44- )
45- return result .get ('response' )
50+
51+ if verbose :
52+ print ('NetLicensing result:' )
53+ print (result )
54+
55+ return result
4656
4757 def _get (self , url , payload = None ):
4858 response = self .requests_session .get (url , params = payload )
@@ -56,20 +66,10 @@ def _delete(self, url, payload=None):
5666 response = self .requests_session .delete (url , data = payload )
5767 return self .get_response (response )
5868
59- def validate (self , licensee_uid ):
60- url = f'{ self .nlic_baseurl } licensee/{ licensee_uid } /validate'
61- payload = {'licensee_uid' : licensee_uid }
62- return self ._post (url , payload )
69+ def validate (self , licensee_number ):
70+ url = f'{ self .nlic_baseurl } licensee/{ licensee_number } /validate'
71+ return self ._post (url )
6372
64- def get_licensee (self , licensee_uid ):
65- url = f'{ self .imp_url } licensee/{ licensee_uid } '
73+ def get_licensee (self , licensee_number ):
74+ url = f'{ self .nlic_baseurl } licensee/{ licensee_number } '
6675 return self ._get (url )
67-
68- def get_licensee (self , ** kwargs ):
69- customer_uid = kwargs .get ('customer_uid' )
70- url = f'{ self .imp_url } licensee/{ customer_uid } '
71- return self ._get (url )
72-
73- def delete_licensee (self , licensee_uid ):
74- url = f'{ self .imp_url } licensee/{ licensee_uid } '
75- return self ._delete (url )
0 commit comments