@@ -699,6 +699,78 @@ def increment_int_value_to_key(token, product_id, key, object_id,\
699699
700700 return (jobj , "" )
701701
702+ @staticmethod
703+ def add_data_object_to_key (token , product_id , key , name = "" , string_value = "" ,\
704+ int_value = 0 , check_for_duplicates = False ):
705+
706+ """
707+ This method will add a new Data Object to a license key.
708+
709+ More docs: https://app.cryptolens.io/docs/api/v3/AddDataObject (see parameters under Method 2)
710+ """
711+
712+ try :
713+ response = HelperMethods .send_request ("/data/AddDataObjectToKey/" ,\
714+ {"token" :token ,\
715+ "ProductId" : product_id ,\
716+ "Key" : key ,\
717+ "Name" : name ,\
718+ "IntValue" : int_value ,\
719+ "StringValue" : string_value ,\
720+ "CheckForDuplicates" : str (check_for_duplicates )
721+ })
722+ except HTTPError as e :
723+ response = e .read ()
724+ except URLError as e :
725+ return (None , "Could not contact the server. Error message: " + str (e ))
726+ except Exception :
727+ return (None , "Could not contact the server." )
728+
729+ jobj = json .loads (response )
730+
731+ if jobj == None or not ("result" in jobj ) or jobj ["result" ] == 1 :
732+ if jobj != None :
733+ return (None , jobj ["message" ])
734+ else :
735+ return (None , "Could not contact the server." )
736+
737+ return (jobj , "" )
738+
739+ @staticmethod
740+ def remove_data_object_to_key (token , product_id , key , object_id = 0 , name = "" ):
741+
742+ """
743+ This method will add a new Data Object to a license key.
744+
745+ Note: either an object_id or name (provided there are no duplicates) is required.
746+
747+ More docs: https://app.cryptolens.io/docs/api/v3/RemoveDataObject (see parameters under Method 2)
748+ """
749+
750+ try :
751+ response = HelperMethods .send_request ("/data/RemoveDataObjectToKey/" ,\
752+ {"token" :token ,\
753+ "ProductId" : product_id ,\
754+ "Key" : key ,\
755+ "Name" : name ,\
756+ "Id" : object_id })
757+ except HTTPError as e :
758+ response = e .read ()
759+ except URLError as e :
760+ return (None , "Could not contact the server. Error message: " + str (e ))
761+ except Exception :
762+ return (None , "Could not contact the server." )
763+
764+ jobj = json .loads (response )
765+
766+ if jobj == None or not ("result" in jobj ) or jobj ["result" ] == 1 :
767+ if jobj != None :
768+ return (None , jobj ["message" ])
769+ else :
770+ return (None , "Could not contact the server." )
771+
772+ return (jobj , "" )
773+
702774
703775class PaymentForm :
704776
0 commit comments