Last active
December 21, 2015 05:18
-
-
Save gmvi/6255721 to your computer and use it in GitHub Desktop.
Specs for VendTTP Client-to-Server Communication
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Specs for VendTTP Client-to-Server Communication | |
revision 3.3 | |
============================================================== | |
Notes: | |
* <"asdf"|"uiop"> means either "asdf" or "uiop" | |
* ( ) means attibute may be null | |
* ~ prefix means non-literal placeholder value | |
* all requests should be shorter than 512 characters (this may be removed in the future) | |
* the client should not send a request before receiving the response to a previous non-stand-alone request | |
new guest log-in request (stand-alone): | |
{ | |
"type" : "guest" | |
} | |
When logged in as guest, any rfid login response will be ignored, because logging out of guest requires user to confirm donation of guest balance. | |
#rfid login "response" (stand-alone): | |
{ | |
"type" : "log in", | |
"username" : ~"George Matter", | |
"balance" : ~5 | |
} | |
#inventory request with key-exchange (a null key is treated like an expired key) | |
{ | |
"type" : "inventory", | |
("key" : ~"asdf") | |
} | |
#inventory response ("categories" attribute will be null if key was valid) | |
{ | |
"type" : "inventory", | |
"inventory" : {"key" : ~"uiop", | |
("categories" : [ | |
{ | |
"name" : ~"cat1", | |
"items" : [ | |
{ | |
"vendId" : ~"00", | |
"price" : ~.75, | |
"quantity" : ~12, | |
"name" : ~"Fruit Snacks" | |
}, | |
... | |
] | |
}, | |
... | |
]) | |
} | |
} | |
#logout request (stand-alone): | |
{ | |
"type" : "log out" | |
} | |
#vend request | |
{ | |
"type" : "vend", | |
"vendId" : ~"00" | |
} | |
#vending succeeded | |
{ | |
"type" : "vend success", | |
"vendId" : ~"00", | |
"balance" : ~4.25 | |
} | |
#vending failed because user had insufficient funds, item was sold out, or item was not found in database, or an error occurred. | |
{ | |
"type" : "vend failure", | |
"vendId" : ~"00", | |
"reason" : <"balance"|"quantity"|"vendId"|"error"> | |
} | |
#when user inserts cash (stand-alone): | |
{ | |
"type" : "balance update", | |
"balance" : ~5.25 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment