Skip to content

Commit 523cae2

Browse files
committed
Update to ModelVersion=3, closes #40
1 parent 20a7621 commit 523cae2

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

licensing/methods.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def activate(token, rsa_pub_key, product_id, key, machine_code, fields_to_return
4444
"FloatingTimeInterval": floating_time_interval,\
4545
"MaxOverdraft": max_overdraft,\
4646
"FriendlyName" : friendly_name,\
47-
"ModelVersion": 2 ,\
47+
"ModelVersion": 3 ,\
4848
"Sign":"True",\
4949
"SignMethod":1}))
5050
except HTTPError as e:
@@ -89,6 +89,7 @@ def get_key(token, rsa_pub_key, product_id, key, fields_to_return = 0,\
8989
"metadata":metadata,\
9090
"FloatingTimeInterval": floating_time_interval,\
9191
"Sign":"True",\
92+
"ModelVersion": 3 ,\
9293
"SignMethod":1}))
9394
except HTTPError as e:
9495
response = Response.from_string(e.read())

licensing/models.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,39 @@
1414
from licensing.internal import HelperMethods
1515

1616
class ActivatedMachine:
17-
def __init__(self, IP, Mid, Time, FriendlyName=""):
17+
def __init__(self, IP, Mid, Time, FriendlyName="", FloatingExpires = ""):
1818
self.IP = IP
1919
self.Mid = Mid
2020

2121
# TODO: check if time is int, and convert to datetime in this case.
2222
self.Time = Time
2323
self.FriendlyName = FriendlyName
24+
self.FloatingExpires = FloatingExpires
25+
26+
class Reseller:
27+
28+
"""
29+
Information about the reseller.
30+
"""
31+
32+
def __init__(self, Id, InviteId, ResellerUserId, Created, Name, Url, Email, Phone, Description):
33+
self.Id = Id
34+
self.InviteId = InviteId
35+
self.ResellerUserId = ResellerUserId
36+
self.Created = Created
37+
self.Name = Name
38+
self.Url = Url
39+
self.Email = Email
40+
self.Phone = Phone
41+
self.Description = Description
42+
2443

2544
class LicenseKey:
2645

2746
def __init__(self, ProductId, ID, Key, Created, Expires, Period, F1, F2,\
2847
F3, F4, F5, F6, F7, F8, Notes, Block, GlobalId, Customer, \
2948
ActivatedMachines, TrialActivation, MaxNoOfMachines, \
30-
AllowedMachines, DataObjects, SignDate, RawResponse):
49+
AllowedMachines, DataObjects, SignDate, Reseller, RawResponse):
3150

3251
self.product_id = ProductId
3352
self.id = ID
@@ -53,6 +72,7 @@ def __init__(self, ProductId, ID, Key, Created, Expires, Period, F1, F2,\
5372
self.allowed_machines = AllowedMachines
5473
self.data_objects = DataObjects
5574
self.sign_date = SignDate
75+
self.reseller = Reseller
5676
self.raw_response = RawResponse
5777

5878
@staticmethod
@@ -63,13 +83,18 @@ def from_response(response):
6383

6484
obj = json.loads(base64.b64decode(response.license_key).decode('utf-8'))
6585

86+
reseller = None
87+
88+
if "Reseller" in obj and obj["Reseller"] != None:
89+
reseller = Reseller(**obj["Reseller"])
90+
6691
return LicenseKey(obj["ProductId"], obj["ID"], obj["Key"], datetime.datetime.fromtimestamp(obj["Created"]),\
6792
datetime.datetime.fromtimestamp(obj["Expires"]), obj["Period"], obj["F1"], obj["F2"], \
6893
obj["F3"], obj["F4"],obj["F5"],obj["F6"], obj["F7"], \
6994
obj["F8"], obj["Notes"], obj["Block"], obj["GlobalId"],\
7095
obj["Customer"], LicenseKey.__load_activated_machines(obj["ActivatedMachines"]), obj["TrialActivation"], \
7196
obj["MaxNoOfMachines"], obj["AllowedMachines"], obj["DataObjects"], \
72-
datetime.datetime.fromtimestamp(obj["SignDate"]), response)
97+
datetime.datetime.fromtimestamp(obj["SignDate"]),reseller, response)
7398

7499
def save_as_string(self):
75100
"""

0 commit comments

Comments
 (0)