Skip to content

Commit 49f13c9

Browse files
committed
Add deactivate
1 parent 470a5d5 commit 49f13c9

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

licensing/methods.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,37 @@ def create_trial_key(token, product_id, machine_code):
8686
return (None, "Could not contact the server.")
8787

8888
return (jobj["key"], "")
89+
90+
91+
def deactivate(token, product_id, key, machine_code, floating = False):
92+
"""
93+
Calls the Deactivate method in Web API 3 and returns a tuple containing
94+
(Success, Message). If an error occurs, Success will be False. If
95+
everything went well, Sucess is true and no message will be returned.
96+
97+
More docs: https://app.cryptolens.io/docs/api/v3/Deactivate
98+
"""
99+
100+
response = ""
101+
102+
try:
103+
response = HelperMethods.send_request("key/deactivate", {"token":token,\
104+
"ProductId":product_id,\
105+
"Key" : key,\
106+
"Floating" : floating,\
107+
"MachineCode":machine_code})
108+
except Exception:
109+
return (False, "Could not contact the server.")
110+
111+
jobj = json.loads(response)
112+
113+
if jobj == None or jobj["result"] == "1":
114+
if jobj != None:
115+
return (False, jobj["message"])
116+
else:
117+
return (False, "Could not contact the server.")
118+
119+
return (True, "")
89120

90121

91122

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.8', # Start with a small number and increase it with every change you make
5+
version = '0.9', # 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_08.tar.gz', # I explain this later on
11+
download_url = 'https://github.com/Cryptolens/cryptolens-python/archive/v_09.tar.gz', # I explain this later on
1212
keywords = ['software licensing', 'licensing library', 'cryptolens'], # Keywords that define your package best
1313
install_requires=[ # I get to this in a second
1414
'pycryptodome'

0 commit comments

Comments
 (0)