Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Events + Get Keys #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions licensing/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
12 changes: 12 additions & 0 deletions licensing/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
7 changes: 5 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""

from licensing.models import *
from licensing.methods import Key, Helpers
from licensing.methods import Key, Helpers, AI

pubKey = "<RSAKeyValue><Modulus>sGbvxwdlDbqFXOMlVUnAF5ew0t0WpPW7rFpI5jHQOFkht/326dvh7t74RYeMpjy357NljouhpTLA3a6idnn4j6c3jmPWBkjZndGsPL4Bqm+fwE48nKpGPjkj4q/yzT4tHXBTyvaBjA8bVoCTnu+LiC4XEaLZRThGzIn5KQXKCigg6tQRy0GXE13XYFVz/x1mjFbT9/7dS8p85n8BuwlY5JvuBIQkKhuCNFfrUxBWyu87CFnXWjIupCD2VO/GbxaCvzrRjLZjAngLCMtZbYBALksqGPgTUN7ZM24XbPWyLtKPaXF2i4XRR9u6eTj5BfnLbKAU5PIVfjIS+vNYYogteQ==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>"

Expand Down Expand Up @@ -40,4 +40,7 @@
print("Feature 1: " + str(license_key.f1))
print("License expires: " + str(license_key.expires))

print(Helpers.GetMachineCode())
print(Helpers.GetMachineCode())


#a = AI.get_events("WyIyOTk0Iiwid1ZZUUU4bVEyd2Z1VCtGL05aREpQb0p4VEkxYThRbEw1aGRpUHg3ZiJd")