-
Notifications
You must be signed in to change notification settings - Fork 0
/
HttpBuyTransaction.h
64 lines (54 loc) · 1.53 KB
/
HttpBuyTransaction.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* "Drinks" RFID Terminal
* Buy sodas with your company badge!
*
* Benoit Blanchon 2014 - MIT License
* https://github.com/bblanchon/DrinksRfidTerminal
*/
#ifndef _HTTPBUYTRANSACTION_H
#define _HTTPBUYTRANSACTION_H
#include "HttpClient.h"
class HttpBuyTransaction
{
public:
HttpBuyTransaction(HttpClient& http)
:http(http)
{
}
bool perform(char* badge, int product, unsigned long time)
{
return send(badge, product, time) && parse() && validate();
}
bool performLocker(char* badge, unsigned long time)
{
return sendForLocker(badge, time) && parse() && validate();
}
bool getBalance(char* badge, unsigned long time)
{
return sendForBalance(badge, time) && parse() && validate();
}
bool getUser(char* badge, unsigned long time)
{
return sendForUser(badge, time) && parse() && validate();
}
const char* getMelody() { return melody; }
const char* getError() { return error; }
//const char* getMessage(int i) { return messages[i]; }
std::vector<std::string> getMessage() { return messages; };
private:
bool send(char*, int, unsigned long);
bool sendForLocker(char*, unsigned long);
bool sendForBalance(char*, unsigned long);
bool sendForUser(char*, unsigned long);
bool parse();
bool validate();
HttpClient& http;
char buffer[150];
const char* hash;
//const char* messages[2];
std::vector<std::string> messages;
const char* melody;
const char* time;
const char* error;
};
#endif