@@ -698,7 +698,47 @@ def increment_int_value_to_key(token, product_id, key, object_id,\
698698 return (None , "Could not contact the server." )
699699
700700 return (jobj , "" )
701-
701+
702+ @staticmethod
703+ def decrement_int_value_to_key (token , product_id , key , object_id ,\
704+ int_value = 0 , enable_bound = False , bound = 0 ):
705+
706+ """
707+ This method will decrement the int value of a data object associated with a license key.
708+
709+ When creating an access token to this method, remember to include "DecrementIntValue" permission and
710+ set the "Lock to key" value to -1.
711+
712+ More docs: https://app.cryptolens.io/docs/api/v3/DecrementIntValue (see parameters under Method 2)
713+ """
714+
715+ try :
716+ response = HelperMethods .send_request ("/data/DecrementIntValueToKey/" ,\
717+ {"token" :token ,\
718+ "ProductId" : product_id ,\
719+ "Key" : key ,\
720+ "Id" : object_id ,\
721+ "IntValue" : int_value ,\
722+ "EnableBound" : str (enable_bound ),\
723+ "Bound" : bound
724+ })
725+ except HTTPError as e :
726+ response = e .read ()
727+ except URLError as e :
728+ return (None , "Could not contact the server. Error message: " + str (e ))
729+ except Exception :
730+ return (None , "Could not contact the server." )
731+
732+ jobj = json .loads (response )
733+
734+ if jobj == None or not ("result" in jobj ) or jobj ["result" ] == 1 :
735+ if jobj != None :
736+ return (None , jobj ["message" ])
737+ else :
738+ return (None , "Could not contact the server." )
739+
740+ return (jobj , "" )
741+
702742 @staticmethod
703743 def add_data_object_to_key (token , product_id , key , name = "" , string_value = "" ,\
704744 int_value = 0 , check_for_duplicates = False ):
0 commit comments