#ifndef KEYZY_TYPES_H
#define KEYZY_TYPES_H

#include <string>
#include <ctime>

namespace Keyzy
{
    /** @struct ProductData
     *
     *  @var ProductData::_appId
     *  Member 'appId' contains Id for authentication to Keyzy
     *  @var ProductData::_apiKey
     *  Member 'apiKey' contains Key for authentication to Keyzy

     *  @var ProductData::_productCode
     *  Member '_productCode' contains product identifier that is defined on Keyzy Dashboard

     *  @var ProductData::_cryptionKey
     *  Member '_cryptionKey' contains cryption key uses for offline license verificaiton

     *  @var ProductData::_useHostIdInOffilneActivation
     *  Member '_useHostIdInOffilneActivation' if set true, the host_id will be used to mix with _cryptionKey, so as a result a license file will be device specific
    */
    struct ProductData
    {
        ProductData() : _useHostIdInOffilneActivation(true) {}
        
        ProductData(std::string appId, std::string apiKey, std::string productCode,
                    std::string cryptionKey, bool useHostIdInOfflineActivation = true)
        : _appId(appId)
        , _apiKey(apiKey)
        , _productCode(productCode)
        , _cryptionKey(cryptionKey)
        , _useHostIdInOffilneActivation(useHostIdInOfflineActivation) {}

        std::string _appId;
        std::string _apiKey;
        std::string _productCode;
        std::string _cryptionKey;
        bool _useHostIdInOffilneActivation;
    };

    /** @struct LicenseInfo
     *
     *  Contains license information
     *
     *  @var LicenseInfo::_skuNumber
     *  Contains the unique SKU number of the sku
     *
     *  @var LicenseInfo::_productCode
     *  Contains the unique product code of the product
     *
     *  @var LicenseInfo::_licenseeName
     *  Contains the name of the licensee
     *
     *  @var LicenseInfo::_licenseeEmail
     *  Contains the email of the licensee
     *
     *  @var LicenseInfo::_versionCode
     *  Contains the version code of the product that is connected to the SKU
     *
     *  @var LicenseInfo::_licenseType
     *  Contains the type of the license. It's "trial"
     *
     *  @var LicenseInfo::_startTime
     *  Contains the start time of the trial license in unix timestamp format.\n
     *  Default time is 315522000.\n
     *  It's only used for trial and subscription license types.\n
     *
     *  @var LicenseInfo::_endTime
     *  Contains the end time of the trial license in unix timestamp format.\n
     *  Default time is 315522000.\n
     *  It's used for trial and subscription license types as end time.\n
     *  It's used for perpetual license type as offline_license_life.
     *
     *  @var LicenseInfo::_info
     *  Contains the text for the license if any text is applied before the deposit process
     *
     *  @var LicenseInfo::_serialNumber
     *  Contains the serial number of the license
     *
    */
    struct LicenseInfo
    {
        std::string _skuNumber;
        std::string _productCode;
        std::string _licenseeName;
        std::string _licenseeEmail;
        std::string _versionCode;
        std::string _licenseType;
        std::int64_t _startTime = 315522000;
        std::int64_t _endTime = 315522000;
        std::string _info;
        std::string _serialNumber;
    };

    /*!
    * List of available status for licenses
    * VALID and ACTIVATION_DELETED are Successful. Others are Error.
    */
    enum class LicenseStatus
    {
        VALID,
        EXPIRED,
        INVALID,
        NOT_AUTHORIZED, // Server
        SERIAL_INVALID, // Server
        PRODUCT_NOT_EXIST, // Server
        PRODUCT_NOT_EXIST_FOR_USER, // Server
        PRODUCT_NOT_ACTIVE, // Server
        SKU_NOT_EXIST, // Server
        SKU_NOT_ACTIVE, // Server
        REACHED_MAX_NUMBER_OF_HOST, // Server
        PRODUCT_NOT_EXIST_FOR_SKU, // Server
        ACTIVATION_DEACTIVATED, // Server
        SUBSCRIPTION_LICENSE_EXPIRED, // Server
        SUBSCRIPTION_LICENSE_NOT_STARTED, // Server
        TRIAL_LICENSE_EXPIRED, // Server
        TRIAL_LICENSE_NOT_STARTED, // Server
        CANNOT_KEEP_SERIAL, // Client Online Activation
        CANNOT_KEEP_LICENSE_FILE, // Client Offline Activation
        ACTIVATION_DELETED, // Server
        CLIENT_SERIAL_DOES_NOT_EXIST, // Client
        CONNECTION_ERROR, // Network or Firewall error. Internet connection is intermittent Or Firewall On. Client
        TOO_MANY_REQUESTS, // The client sends too many requests. Server
        NO_ACTIVE_SUBSCRIPTION, // The account holder has a subscription issue in KEYZY
        CURRENT_LICENSE_DOES_NOT_EXIST, // Server - Upgrade license
        UPGRADE_LICENSE_DOES_NOT_EXIST, // Server - Upgrade license
        UPGRADE_LICENSE_DOES_NOT_MATCH, // Server - Upgrade license
        ANOTHER_TRIAL_LICENSE_ALREADY_ACTIVATED, // Server
        SKU_NUMBER_VALIDATION, // Server
        PRODUCT_CODE_VALIDATION, // Server
        NAME_VALIDATION, // Server
        EMAIL_VALIDATION, // Server
        NO_FREE_LICENSES, // Server
        NAME_OR_EMAIL_VALIDATION, // Server - Register Offline Distributed License
        LICENSE_NOT_EXIST_NOT_ASSIGNED_DEALER_ALREADY_DEPOSITED // Server - Register Offline Distributed License
    };

    /*!
    * List of available types for licenses
    */
    enum class LicenseType
    {
        NOTYPE,
        PERPETUAL,
        TRIAL,
        SUBSCRIPTION
    };

}; // Keyzy

#endif // KEYZY_TYPES_H
