Skip to content

Commit 892d7de

Browse files
authored
Add DecrementIntValueToKey (#56)
* Update methods.py * Update setup.py
1 parent 49e33f6 commit 892d7de

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

licensing/methods.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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):

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
setup(
33
name = 'licensing', # How you named your package folder (MyLib)
44
packages = ['licensing'], # Chose the same as "name"
5-
version = '0.37', # Start with a small number and increase it with every change you make
5+
version = '0.38', # Start with a small number and increase it with every change you make
66
license='MIT', # Chose a license from here: https://help.github.com/articles/licensing-a-repository
77
description = 'Client library for Cryptolens licensing Web API.', # Give a short description about your library
88
author = 'Cryptolens AB', # Type in your name
99
author_email = '[email protected]', # Type in your E-Mail
1010
url = 'https://cryptolens.io', # Provide either the link to your github or to your website
11-
download_url = 'https://github.com/Cryptolens/cryptolens-python/archive/v_37.tar.gz', # I explain this later on
11+
download_url = 'https://github.com/Cryptolens/cryptolens-python/archive/v_38.tar.gz', # I explain this later on
1212
keywords = ['software licensing', 'licensing library', 'cryptolens'], # Keywords that define your package best
1313
classifiers=[
1414
#'Development Status :: 5 - Stable', # Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable" as the current state of your package

0 commit comments

Comments
 (0)