2 Author: Mitchell Pomery (bobgeorge33)
4 Dispense is an abstract class that allows easy configuration between different systems. Anything that is
5 intended to talk to OpenDispense or similar should comply with this class. Using this class in particular
6 will cause you a lot of problems.
9 class DispenseInterface(object):
12 Create a new dispense object.
13 @param username The username to connect to dispense with
14 @param secret The secret to use for Auth
16 def __init__(self, username=None, secret=None):
20 Create a new dispense interface as the supplied user.
21 @param username The userid of the person authing to dispense
24 def authUsernamePin(self, userId, pin):
28 Create a new dispense interface as the supplied user.
29 @param cardId The card that someone is connecting to Dispense with
31 def authMifare(self, cardId):
35 Add a MIFARE card for this user
36 @param cardId Card to add to a user account
37 @return 1 if added successfully, anything else otherwise
39 def addCard(self, cardId):
43 Check if creating the user worked correctly.
44 @return True if currently logged in as a user, false otherwise
50 Get the current users username.
51 @return The username of the current user. An empty string if not currently logged in.
53 def getUsername(self):
57 Get the current users balance.
58 @return the users balance. None if not logged in.
64 Get the name and price of an item.
65 @param itemId The number entered into the vending machine
66 @return (itemname, price)
68 def getItemInfo(itemId):
72 Check if the user is disabled.
73 @return True if the user is disabled
79 Dispense an item for the current user.
80 @param itemId The number entered into the vending machine
82 def dispenseItem(self, itemId):
86 Log the current user out