VMCPlugin/plugins/CalculatePrice/CalculatePriceInterface.h

158 lines
6.8 KiB
C++

#ifndef CALCULATEPRICEINTERFACE_H
#define CALCULATEPRICEINTERFACE_H
#include <QtPlugin>
#include <QSettings>
#include <QString>
#include "ATBAPPplugin.h"
namespace nsCalculatePriceInterface {
enum class PLUGIN_STATE : quint8;
enum class RESULT_STATE : quint8;
enum class STEP : quint8;
}
class PriceInfo
{
public:
int priceNet; // price net in cent
int priceTax; // price tax in cent
int priceGross; // price gross in cent
int taxRate; // tax rate per mill
};
class CalculatePriceInterface : public ATBAPPplugin
{
Q_INTERFACES(ATBAPPplugin)
public:
virtual ~CalculatePriceInterface() {}
virtual nsCalculatePriceInterface::PLUGIN_STATE initCalculatePricePlugin(QObject *healthEventReceiver,
const QSettings & settings) = 0;
// for price calculation dependent on ID (AccessInformation)
virtual void requestCalculatePrice(const QString & AccessInformation,
const QString & AccessInformationType,
const QString & PermitType) = 0;
// for price calculation dependent on value (e.g. parking time)
virtual void requestCalculatePrice(const QString & AccessInformation,
const QString & AccessInformationType,
const QString & PermitType,
const QString & parktime) = 0;
// for price/time calculation on next step up/down
virtual void requestCalculatePrice(const QString & AccessInformation,
const QString & AccessInformationType,
const QString & PermitType,
nsCalculatePriceInterface::STEP step) = 0;
// for price/time calculation on next coin value
virtual void requestCalculatePrice(const QString & AccessInformation,
const QString & AccessInformationType,
const QString & PermitType,
int coinValue) = 0;
// for price calculation dependent on additonal values (e.g. parking time, card info, ...)
virtual void requestCalculatePrice(const QString & AccessInformation, // primary key e.g. a license plate, credit card number
const QString & AccessInformationType, // type of AccessInformation: LICENSEPLATE, CREDITCARD, PIN, ...
const QString & PermitType, // e.g. selected product / vehicle
const QString & parktime, // parktime in minutes
const QString & cardInfo, // additonal card info (e.g. PAN, Institusnummer, Token, ...)
const QString & transactionInfo) = 0; // kind of a transcation id, could be used for identification of transaction
virtual void requestProcessTransaction(const QString & AccessInformation,
const QString & AccessInformationType,
const QString & amount,
bool isOffline,
const QString & TransactionId,
const QString & ReceiptData,
const QString & PermitType,
const QString & PaymentType) = 0;
virtual nsCalculatePriceInterface::PLUGIN_STATE getState() = 0;
virtual quint32 getLastError() = 0;
virtual const QString & getLastErrorDescription() = 0;
// return a plugin description in JSON or XML
// -> ATBAPPplugin::getPluginInfo()
// helpers e.g. for debug / log
virtual const QString getString(nsCalculatePriceInterface::RESULT_STATE resultState) = 0;
signals:
virtual void requestCalculatePriceResult(nsCalculatePriceInterface::RESULT_STATE resultState,
const QString & accessInformation,
const QString & accessInformationType,
const QString & amountDuePeriodStart,
const QString & amountDuePeriodEnd,
const QString & amountDueNet,
const QString & amountDueTax,
const QString & gracePeriod,
const QString & errorCode,
const QString & errorDescription) = 0;
virtual void requestCalculatePriceResult(nsCalculatePriceInterface::RESULT_STATE resultState,
const QString & accessInformation,
const QString & accessInformationType,
const QString & amountDuePeriodStart,
const QString & amountDuePeriodEnd,
const PriceInfo & priceInfo,
const QString & errorCode,
const QString & errorDescription) = 0;
virtual void requestProcessTransactionResult(nsCalculatePriceInterface::RESULT_STATE resultState,
const QString & errorCode,
const QString & errorDescription) = 0;
// TODO:
/* APPLICATION_PROCESS_TYPE is a global ATB-Type:
* - BACKGROUND -> process can work in background without display
* - HMI -> display is needed
* - t.b.d
*
* PROCESS_ID is an identifier for e.g. debuging or log which process/module/library/plugin...
* caused the prevent
*
virtual void preventSuspend(APPLICATION_PROCESS_TYPE pt, PROCESS_ID pid) = 0;
virtual void allowSuspend(PROCESS_ID pid) = 0;
*/
};
Q_DECLARE_INTERFACE(CalculatePriceInterface,
"eu.atb.ptu.plugin.CalculatePriceInterface/4.0")
namespace nsCalculatePriceInterface {
enum class PLUGIN_STATE : quint8 {
NOT_INITIALIZED = 0,
INITIALIZED = 1
};
enum class RESULT_STATE : quint8 {
SUCCESS = 1, // got price and time from remote
ERROR_BACKEND = 2, // error from backand (e.g. backend replies with error)
ERROR_NETWORK = 3, // error from network (e.g. host not available)
ERROR_TIMEOUT = 4, // the operation timed out
ERROR_PROCESS = 5, // internal plugin error (e.g. bug in implementation)
ERROR_RETRY = 6, // retry operation
INFO = 7
};
enum class STEP : quint8 {
UP = 1,
DOWN = 2
};
}
#endif // CALCULATEPRICEINTERFACE_H