#pragma once
#include <Arduino.h>
#include <HTTPClient.h>

unsigned long cooldownSecondsRemaining(unsigned long timeout, unsigned long timer);
String byteArrayAsHexString(byte* buffer, byte bufferSize);
String cardLink(WiFiClient* wifi, HTTPClient* http, const String& apiUrl, const String& cardId, const String& reader);
String cardBalance(WiFiClient* wifi, HTTPClient* http, const String& apiUrl, const String& cardId, const String& reader);
String cardTransaction(WiFiClient* wifi, HTTPClient* http, const String& apiUrl, const String& cardId, const String& amount, const String& reader);
String splitString(const String& data, char separator, int index);
String cardIdDisplay(const String& id);

enum e_state {
	STATE_IDLE,
	STATE_TRANSACT_CARDSCAN,
	STATE_TRANSACT_VERIFY,
	STATE_LINK_CARD_SCAN,
	STATE_LINK_CARD_RESCAN,
	STATE_LINK_VERIFY,
	STATE_BALANCE_CARDSCAN,
	STATE_BALANCE_VERIFY,
	STATE_RESULT_SUCCESS,
	STATE_RESULT_FAILURE,
	STATE_RESULT_DISPLAY,
};

enum e_scanstate {
	SCANSTATE_IDLE,
	SCANSTATE_ACTIVE,
};
