diff --git a/licensing/methods.py b/licensing/methods.py index f88e5fa..c181d52 100644 --- a/licensing/methods.py +++ b/licensing/methods.py @@ -10,6 +10,57 @@ import sys from licensing.internal import HelperMethods from licensing.models import * +import json + +class AI: + + def get_events(token, limit=10, starting_after=None): + + """ + This method will retrieve events that were registered using Register event method. + + :param limit: Specifies how many events should be returned (default 10, max 100). + :param starting_after: Works as a cursor (for pagination). If the last element had the id=125, then setting this to 125 will return all events coming after 125. + """ + + + response = HelperMethods.send_request("ai/getevents", \ + {"token":token,\ + "limit":limit, \ + "startingafter":starting_after}) + + jobj = json.loads(response) + + if jobj == None or jobj["result"] == "1": + return None + + arr = [] + + for item in jobj["events"]: + arr.append(Event(**item)) + + + return arr + + +""" +class Product: + + def get_keys(token, product_id, page = 1, order_by = "ID ascending", search_query = ""): + + response = HelperMethods.send_request("product/getkeys", \ + {"token":token,\ + "productId": product_id, \ + "orderby":order_by, \ + "searchquery": search_query}) + + jobj = json.loads(response) + + if jobj == None or jobj["result"] == "1": + return None + +""" + class Key: diff --git a/licensing/models.py b/licensing/models.py index 4478f50..37b0de1 100644 --- a/licensing/models.py +++ b/licensing/models.py @@ -127,6 +127,18 @@ def __load_activated_machines(obj): arr.append(ActivatedMachine(**item)) return arr + +class Event: + + def __init__(self, currency, eventName, featureName, id, key, machineCode, productId, time, value): + self.currency = currency + self.event_name = eventName + self.feature_name = featureName + self.id = id + self.machine_code = machineCode + self.product_id = productId + self.time = time + self.value = value class Response: diff --git a/test.py b/test.py index 0523363..11d1364 100644 --- a/test.py +++ b/test.py @@ -6,7 +6,7 @@ """ from licensing.models import * -from licensing.methods import Key, Helpers +from licensing.methods import Key, Helpers, AI pubKey = "sGbvxwdlDbqFXOMlVUnAF5ew0t0WpPW7rFpI5jHQOFkht/326dvh7t74RYeMpjy357NljouhpTLA3a6idnn4j6c3jmPWBkjZndGsPL4Bqm+fwE48nKpGPjkj4q/yzT4tHXBTyvaBjA8bVoCTnu+LiC4XEaLZRThGzIn5KQXKCigg6tQRy0GXE13XYFVz/x1mjFbT9/7dS8p85n8BuwlY5JvuBIQkKhuCNFfrUxBWyu87CFnXWjIupCD2VO/GbxaCvzrRjLZjAngLCMtZbYBALksqGPgTUN7ZM24XbPWyLtKPaXF2i4XRR9u6eTj5BfnLbKAU5PIVfjIS+vNYYogteQ==AQAB" @@ -40,4 +40,7 @@ print("Feature 1: " + str(license_key.f1)) print("License expires: " + str(license_key.expires)) -print(Helpers.GetMachineCode()) \ No newline at end of file +print(Helpers.GetMachineCode()) + + +#a = AI.get_events("WyIyOTk0Iiwid1ZZUUU4bVEyd2Z1VCtGL05aREpQb0p4VEkxYThRbEw1aGRpUHg3ZiJd") \ No newline at end of file