Skip to content

Commit

Permalink
Add DecrementIntValueToKey (#56)
Browse files Browse the repository at this point in the history
* Update methods.py

* Update setup.py
  • Loading branch information
artemlos authored Dec 16, 2022
1 parent 49e33f6 commit 892d7de
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
42 changes: 41 additions & 1 deletion licensing/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,47 @@ def increment_int_value_to_key(token, product_id, key, object_id,\
return (None, "Could not contact the server.")

return (jobj, "")


@staticmethod
def decrement_int_value_to_key(token, product_id, key, object_id,\
int_value=0, enable_bound=False, bound=0):

"""
This method will decrement the int value of a data object associated with a license key.
When creating an access token to this method, remember to include "DecrementIntValue" permission and
set the "Lock to key" value to -1.
More docs: https://app.cryptolens.io/docs/api/v3/DecrementIntValue (see parameters under Method 2)
"""

try:
response = HelperMethods.send_request("/data/DecrementIntValueToKey/",\
{"token":token,\
"ProductId" : product_id,\
"Key" : key,\
"Id" : object_id,\
"IntValue": int_value ,\
"EnableBound": str(enable_bound),\
"Bound" : bound
})
except HTTPError as e:
response = e.read()
except URLError as e:
return (None, "Could not contact the server. Error message: " + str(e))
except Exception:
return (None, "Could not contact the server.")

jobj = json.loads(response)

if jobj == None or not("result" in jobj) or jobj["result"] == 1:
if jobj != None:
return (None, jobj["message"])
else:
return (None, "Could not contact the server.")

return (jobj, "")

@staticmethod
def add_data_object_to_key(token, product_id, key, name = "", string_value="",\
int_value=0, check_for_duplicates=False):
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
setup(
name = 'licensing', # How you named your package folder (MyLib)
packages = ['licensing'], # Chose the same as "name"
version = '0.37', # Start with a small number and increase it with every change you make
version = '0.38', # Start with a small number and increase it with every change you make
license='MIT', # Chose a license from here: https://help.github.com/articles/licensing-a-repository
description = 'Client library for Cryptolens licensing Web API.', # Give a short description about your library
author = 'Cryptolens AB', # Type in your name
author_email = '[email protected]', # Type in your E-Mail
url = 'https://cryptolens.io', # Provide either the link to your github or to your website
download_url = 'https://github.com/Cryptolens/cryptolens-python/archive/v_37.tar.gz', # I explain this later on
download_url = 'https://github.com/Cryptolens/cryptolens-python/archive/v_38.tar.gz', # I explain this later on
keywords = ['software licensing', 'licensing library', 'cryptolens'], # Keywords that define your package best
classifiers=[
#'Development Status :: 5 - Stable', # Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable" as the current state of your package
Expand Down

0 comments on commit 892d7de

Please sign in to comment.