// Path: src/main/java/cz/tomasdvorak/eet/client/config/SubmissionType.java
// @Deprecated
// public enum SubmissionType {
//     FIRST_ATTEMPT(true),
//     REPEATED_ATTEMPT(false);
// 
//     private final boolean isFirstSubmission;
// 
//     SubmissionType(final boolean isFirstSubmission) {
//         this.isFirstSubmission = isFirstSubmission;
//     }
// 
//     public boolean isFirstSubmission() {
//         return isFirstSubmission;
//     }
// }
// 
// Path: src/main/java/cz/tomasdvorak/eet/client/dto/SubmitResult.java
// public class SubmitResult extends OdpovedType {
// 
//     private final TrzbaType request;
// 
//     public SubmitResult(final TrzbaType request, final OdpovedType response) {
//         super();
//         setChyba(response.getChyba());
//         setHlavicka(response.getHlavicka());
//         setPotvrzeni(response.getPotvrzeni());
//         withVarovani(response.getVarovani());
//         this.request = request;
//     }
// 
//     /**
//      * Get the original request to this response
//      */
//     public TrzbaType getRequest() {
//         return request;
//     }
// 
//     /**
//      * Convert the current request to a String representation. Useful for persisting and/or logging purposes.
//      * @return String representation of current request.
//      */
//     public String serializeRequest()  {
//         return RequestSerializer.toString(request);
//     }
// 
//     /**
//      * Utility method for easier access to BKP (Taxpayer's Security Code) security code
//      * @return BKP code from the request
//      */
//     public String getBKP() {
//         return request.getKontrolniKody().getBkp().getValue();
//     }
// 
//     /**
//      * Utility method for easier access to PKP (Taxpayer's Signature Code) security code
//      * @return PKP code, encoded as Base64, suitable for printing on the receipt in case of communication failure.
//      */
//     public String getPKP() {
//         return StringUtils.toBase64(request.getKontrolniKody().getPkp().getValue());
//     }
// 
//     /**
//      * Utility method for easier access to FIK (Fiscal Identification Code)
//      * @return FIK code from the response. May be {@code null}, if the response contains errors
//      */
//     public String getFik() {
//         return getPotvrzeni() == null ? null : getPotvrzeni().getFik();
//     }
// }


import cz.etrzby.xml.TrzbaDataType;
import cz.etrzby.xml.TrzbaType;
import cz.tomasdvorak.eet.client.config.CommunicationMode;
import cz.tomasdvorak.eet.client.config.EndpointType;
import cz.tomasdvorak.eet.client.config.SubmissionType;
import cz.tomasdvorak.eet.client.dto.ResponseCallback;
import cz.tomasdvorak.eet.client.dto.SubmitResult;
import cz.tomasdvorak.eet.client.exceptions.DataSigningException;
import cz.tomasdvorak.eet.client.exceptions.CommunicationException;
import java.util.concurrent.Future;
package cz.tomasdvorak.eet.client;



/**
 * EET client implementation, handling computation of security codes, signing of requests, validation of responses.
 */
public interface EETClient {

    /**
     * Prepare request for <strong>first submit</strong> to EET Service.
     * @param receiptData Receipt data like price, VAT or Tax ID.
     * @param mode test or real communication (will be encoded in header
     * @return complete request, including computed security codes, added random message UUID, current date.
     * @throws DataSigningException if problem with signing occurs. Should be related to client key in that case
     */
    TrzbaType prepareFirstRequest(final TrzbaDataType receiptData, final CommunicationMode mode) throws DataSigningException;

    /**
     * Prepare request for <strong>second or every other</strong> submit to EET service.
     * @param request the original request, which has been already constructed and sent to EET servers.
     * @return Updated request, re-generated message UUID, send date, set first-submission flag to false, recomputed
     * security codes if they change meanwhile (new client certificate used for this submission)
     * @throws DataSigningException if problem with signing occurs. Should be related to client key in that case
     */
    TrzbaType prepareRepeatedRequest(final TrzbaType request) throws DataSigningException;

    /**
     * Submit synchronously a receipt to EET servers.
     * @param request prepared by calling one of {@link #prepareFirstRequest(TrzbaDataType, CommunicationMode)} or {@link #prepareRepeatedRequest(TrzbaType)} method.
     * @param endpointType real or test endpoint
     * @return result provided by EET servers.
     * @throws CommunicationException if something fails. It may be timeout, not accessible servers, invalid message, invalid signature of response.
     */
// Path: src/main/java/cz/tomasdvorak/eet/client/config/SubmissionType.java
// @Deprecated
// public enum SubmissionType {
//     FIRST_ATTEMPT(true),
//     REPEATED_ATTEMPT(false);
// 
//     private final boolean isFirstSubmission;
// 
//     SubmissionType(final boolean isFirstSubmission) {
//         this.isFirstSubmission = isFirstSubmission;
//     }
// 
//     public boolean isFirstSubmission() {
//         return isFirstSubmission;
//     }
// }
// 
// Path: src/main/java/cz/tomasdvorak/eet/client/dto/SubmitResult.java
// public class SubmitResult extends OdpovedType {
// 
//     private final TrzbaType request;
// 
//     public SubmitResult(final TrzbaType request, final OdpovedType response) {
//         super();
//         setChyba(response.getChyba());
//         setHlavicka(response.getHlavicka());
//         setPotvrzeni(response.getPotvrzeni());
//         withVarovani(response.getVarovani());
//         this.request = request;
//     }
// 
//     /**
//      * Get the original request to this response
//      */
//     public TrzbaType getRequest() {
//         return request;
//     }
// 
//     /**
//      * Convert the current request to a String representation. Useful for persisting and/or logging purposes.
//      * @return String representation of current request.
//      */
//     public String serializeRequest()  {
//         return RequestSerializer.toString(request);
//     }
// 
//     /**
//      * Utility method for easier access to BKP (Taxpayer's Security Code) security code
//      * @return BKP code from the request
//      */
//     public String getBKP() {
//         return request.getKontrolniKody().getBkp().getValue();
//     }
// 
//     /**
//      * Utility method for easier access to PKP (Taxpayer's Signature Code) security code
//      * @return PKP code, encoded as Base64, suitable for printing on the receipt in case of communication failure.
//      */
//     public String getPKP() {
//         return StringUtils.toBase64(request.getKontrolniKody().getPkp().getValue());
//     }
// 
//     /**
//      * Utility method for easier access to FIK (Fiscal Identification Code)
//      * @return FIK code from the response. May be {@code null}, if the response contains errors
//      */
//     public String getFik() {
//         return getPotvrzeni() == null ? null : getPotvrzeni().getFik();
//     }
// }


// Path: src/main/java/cz/tomasdvorak/eet/client/EETClient.java
import cz.etrzby.xml.TrzbaDataType;
import cz.etrzby.xml.TrzbaType;
import cz.tomasdvorak.eet.client.config.CommunicationMode;
import cz.tomasdvorak.eet.client.config.EndpointType;
import cz.tomasdvorak.eet.client.config.SubmissionType;
import cz.tomasdvorak.eet.client.dto.ResponseCallback;
import cz.tomasdvorak.eet.client.dto.SubmitResult;
import cz.tomasdvorak.eet.client.exceptions.DataSigningException;
import cz.tomasdvorak.eet.client.exceptions.CommunicationException;
import java.util.concurrent.Future;

package cz.tomasdvorak.eet.client;



/**
 * EET client implementation, handling computation of security codes, signing of requests, validation of responses.
 */
public interface EETClient {

    /**
     * Prepare request for <strong>first submit</strong> to EET Service.
     * @param receiptData Receipt data like price, VAT or Tax ID.
     * @param mode test or real communication (will be encoded in header
     * @return complete request, including computed security codes, added random message UUID, current date.
     * @throws DataSigningException if problem with signing occurs. Should be related to client key in that case
     */
    TrzbaType prepareFirstRequest(final TrzbaDataType receiptData, final CommunicationMode mode) throws DataSigningException;

    /**
     * Prepare request for <strong>second or every other</strong> submit to EET service.
     * @param request the original request, which has been already constructed and sent to EET servers.
     * @return Updated request, re-generated message UUID, send date, set first-submission flag to false, recomputed
     * security codes if they change meanwhile (new client certificate used for this submission)
     * @throws DataSigningException if problem with signing occurs. Should be related to client key in that case
     */
    TrzbaType prepareRepeatedRequest(final TrzbaType request) throws DataSigningException;

    /**
     * Submit synchronously a receipt to EET servers.
     * @param request prepared by calling one of {@link #prepareFirstRequest(TrzbaDataType, CommunicationMode)} or {@link #prepareRepeatedRequest(TrzbaType)} method.
     * @param endpointType real or test endpoint
     * @return result provided by EET servers.
     * @throws CommunicationException if something fails. It may be timeout, not accessible servers, invalid message, invalid signature of response.
     */
    SubmitResult sendSync(final TrzbaType request, final EndpointType endpointType) throws CommunicationException;