// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/exception/AllegroExecutor.java
// public class AllegroExecutor {
// 
//     private static final AllegroExceptionConventer aec = new AllegroExceptionConventer();
// 
//     public static <T> T execute(Supplier<T> task) {
//         try {
//             return task.get();
//         } catch (SOAPFaultException e) {
//             throw aec.convertException(e.getFault().getFaultCode(), e);
//         }
//     }
// }
// 
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/AbstractService.java
// public class AbstractService {
// 
//     protected ServicePort allegro;
//     protected Credentials cred;
//     protected Configuration conf;
// 
//     public AbstractService() {
//     }
// 
//     public AbstractService(ServicePort allegro, Credentials cred, Configuration conf) {
//         this.allegro = allegro;
//         this.cred = cred;
//         this.conf = conf;
//     }
// 
// }
// 
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/AllegroSession.java
// public class AllegroSession {
// 
//     private String sessionId;
//     private long userId;
//     private Date lastLoginDate;
// 
//     private AllegroSession(Builder builder) {
//         sessionId = builder.sessionId;
//         userId = builder.userId;
//     }
// 
//     public String getSessionId() {
//         if (sessionId == null) {
//             throw new IllegalStateException("Session was not initalized. You need to use .login() first");
//         }
//         return sessionId;
//     }
//     public long getUserId() {
//         return userId;
//     }
// 
//     public Date getLastLoginDate() {
//         return lastLoginDate;
//     }
// 
//     public static final class Builder {
//         private String sessionId;
//         private long userId;
//         private Date lastLoginDate;
// 
//         public Builder() {
//         }
// 
//         public Builder sessionId(String sessionId) {
//             this.sessionId = sessionId;
//             return this;
//         }
// 
//         public Builder userId(long userId) {
//             this.userId = userId;
//             return this;
//         }
// 
//         public Builder lastLoginDate(Date lastLoginDate) {
//             this.lastLoginDate = lastLoginDate;
//             return this;
//         }
// 
//         public AllegroSession build() {
//             return new AllegroSession(this);
//         }
//     }
// }
// 
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/Configuration.java
// public class Configuration {
// 
//     private int countryId;
// 
//     public Configuration(int countryId) {
//         this.countryId = countryId;
//     }
// 
//     public int getCountryId() {
//         return countryId;
//     }
// }
// 
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/util/VersionUtil.java
// public class VersionUtil {
// 
//     public static long getVersion(ServicePort allegro, int countryId, String key) {
//         DoQueryAllSysStatusRequest request = new DoQueryAllSysStatusRequest(countryId, key);
//         return allegro.doQueryAllSysStatus(request)
//                 .getSysCountryStatus()
//                 .getItem()
//                 .stream()
//                 .filter(type -> type.getCountryId() == countryId)
//                 .findAny()
//                 .get()
//                 .getVerKey();
//     }
// 
// }


import com.apwglobal.nice.exception.AllegroExecutor;
import com.apwglobal.nice.service.AbstractService;
import com.apwglobal.nice.service.AllegroSession;
import com.apwglobal.nice.service.Configuration;
import com.apwglobal.nice.util.VersionUtil;
import pl.allegro.webapi.DoLoginEncRequest;
import pl.allegro.webapi.DoLoginEncResponse;
import pl.allegro.webapi.ServicePort;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import java.util.Date;
package com.apwglobal.nice.login;



public class LoginService extends AbstractService {

    private static final String SHA_256 = "SHA-256";

    public LoginService(ServicePort allegro, Credentials cred, Configuration conf) {
        super(allegro, cred, conf);
    }

// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/exception/AllegroExecutor.java
// public class AllegroExecutor {
// 
//     private static final AllegroExceptionConventer aec = new AllegroExceptionConventer();
// 
//     public static <T> T execute(Supplier<T> task) {
//         try {
//             return task.get();
//         } catch (SOAPFaultException e) {
//             throw aec.convertException(e.getFault().getFaultCode(), e);
//         }
//     }
// }
// 
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/AbstractService.java
// public class AbstractService {
// 
//     protected ServicePort allegro;
//     protected Credentials cred;
//     protected Configuration conf;
// 
//     public AbstractService() {
//     }
// 
//     public AbstractService(ServicePort allegro, Credentials cred, Configuration conf) {
//         this.allegro = allegro;
//         this.cred = cred;
//         this.conf = conf;
//     }
// 
// }
// 
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/AllegroSession.java
// public class AllegroSession {
// 
//     private String sessionId;
//     private long userId;
//     private Date lastLoginDate;
// 
//     private AllegroSession(Builder builder) {
//         sessionId = builder.sessionId;
//         userId = builder.userId;
//     }
// 
//     public String getSessionId() {
//         if (sessionId == null) {
//             throw new IllegalStateException("Session was not initalized. You need to use .login() first");
//         }
//         return sessionId;
//     }
//     public long getUserId() {
//         return userId;
//     }
// 
//     public Date getLastLoginDate() {
//         return lastLoginDate;
//     }
// 
//     public static final class Builder {
//         private String sessionId;
//         private long userId;
//         private Date lastLoginDate;
// 
//         public Builder() {
//         }
// 
//         public Builder sessionId(String sessionId) {
//             this.sessionId = sessionId;
//             return this;
//         }
// 
//         public Builder userId(long userId) {
//             this.userId = userId;
//             return this;
//         }
// 
//         public Builder lastLoginDate(Date lastLoginDate) {
//             this.lastLoginDate = lastLoginDate;
//             return this;
//         }
// 
//         public AllegroSession build() {
//             return new AllegroSession(this);
//         }
//     }
// }
// 
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/service/Configuration.java
// public class Configuration {
// 
//     private int countryId;
// 
//     public Configuration(int countryId) {
//         this.countryId = countryId;
//     }
// 
//     public int getCountryId() {
//         return countryId;
//     }
// }
// 
// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/util/VersionUtil.java
// public class VersionUtil {
// 
//     public static long getVersion(ServicePort allegro, int countryId, String key) {
//         DoQueryAllSysStatusRequest request = new DoQueryAllSysStatusRequest(countryId, key);
//         return allegro.doQueryAllSysStatus(request)
//                 .getSysCountryStatus()
//                 .getItem()
//                 .stream()
//                 .filter(type -> type.getCountryId() == countryId)
//                 .findAny()
//                 .get()
//                 .getVerKey();
//     }
// 
// }


// Path: allegro-nice-api/src/main/java/com/apwglobal/nice/login/LoginService.java
import com.apwglobal.nice.exception.AllegroExecutor;
import com.apwglobal.nice.service.AbstractService;
import com.apwglobal.nice.service.AllegroSession;
import com.apwglobal.nice.service.Configuration;
import com.apwglobal.nice.util.VersionUtil;
import pl.allegro.webapi.DoLoginEncRequest;
import pl.allegro.webapi.DoLoginEncResponse;
import pl.allegro.webapi.ServicePort;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import java.util.Date;

package com.apwglobal.nice.login;



public class LoginService extends AbstractService {

    private static final String SHA_256 = "SHA-256";

    public LoginService(ServicePort allegro, Credentials cred, Configuration conf) {
        super(allegro, cred, conf);
    }

    public AllegroSession login() {