drinks
get status and dispense for coffee/beer for VIS members
View readme on GitLab
drinks.proto
syntax = "proto3";
package drinks;
// An API key must be provided in an "authorization" header in GRPC metadata.
// Usernames are always ETH "nethz" usernames (like "flbuetle"),
// view from outside: every person existing in the people database exists here, that means if one makes a request to this api with a
// rfid, which has not been registered yet on the vis website (mapped to a nethz), the api returns as if the user has not consumed anything yet.
// still the rfid-mapping is not saved in the database of drinks (obviously)
service Drinks {
// User
// GetUserDetails : returns all information the api holds for the given user
rpc GetUserDetails (GetUserRequest) returns (User);
// ModifyUser : update the rfid to a given nethz; also used to insert a new nethz-rfid mapping
rpc ModifyUser (ModifyUserRequest) returns (Empty);
// GetUserStatus : returns remaining credits of the given rfid
rpc GetUserStatus (GetUserStatusRequest) returns (RemainingCredits);
// DispenseCoffee : returns remaining credits of the given rfid and saves the dispense in the database
rpc DispenseCoffee (DispenseCoffeeRequest) returns (RemainingCredits);
// DispenseBeer : returns remaining credits of the given rfid and saves the dispense in the database
rpc DispenseBeer (DispenseBeerRequest) returns (RemainingCredits);
}
// give as argument EITHER nethz OR rfid but NOT BOTH
message GetUserRequest {
string nethz = 1;
//XOR (only one)
int32 rfid = 2;
}
// give as arguement BOTH nethz AND rfid
// if there exists no nethz-rfid mapping and the user is a vis member, the mapping is added
// if the mapping exists the rfid is updated by the given rfid
message ModifyUserRequest {
string nethz = 1;
int32 rfid = 2;
}
// the remaining_coffee and remaining_beer values have to be understood to be the number of remaining coffees OR the number of remaining beers but NOT BOTH together
message User {
string nethz = 1;
int32 rfid = 2;
int32 limit = 3;
bool no_delay = 4 [deprecated = true];
DrinksStatus beer = 5;
DrinksStatus coffee = 6;
}
message DrinksStatus {
int32 remaining = 1;
int32 total_consumed = 2;
bool canDispenseNow = 3;
}
// expected format: <5To7digits>@rfid.ethz.ch
message GetUserStatusRequest {
string rfid = 1;
}
// expected format: <5To7digits>@rfid.ethz.ch
message DispenseCoffeeRequest {
string rfid = 1;
}
// expected format: <5To7digits>@rfid.ethz.ch
message DispenseBeerRequest {
string rfid = 1;
}
message RemainingCredits {
int32 remaining_credits = 1;
}
message Empty {}