package net.troja.eve.esi.api;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.ws.rs.core.GenericType;

import net.troja.eve.esi.ApiClient;
import net.troja.eve.esi.ApiException;
import net.troja.eve.esi.Pair;
import net.troja.eve.esi.auth.CharacterInfo;
import net.troja.eve.esi.auth.OAuth;

/**
 * Api to retrieve the character information from the sso.
 */
public class SsoApi {
    private static final String DATE_FORMAT = "yyyy-MM-dd'T'hh:mm:ss.sss";
    private final ApiClient apiClient;

    public SsoApi() {
        this(new ApiClient());
    }

    public SsoApi(final ApiClient apiClient) {
        this.apiClient = apiClient;
        apiClient.setBasePath(OAuth.URI_OAUTH);
        apiClient.setDateFormat(new SimpleDateFormat(DATE_FORMAT));
    }

    public CharacterInfo getCharacterInfo() throws ApiException {
        final Object localVarPostBody = null;

        final String localVarPath = "/verify";

        final List<Pair> localVarQueryParams = new ArrayList<>();
        final Map<String, String> localVarHeaderParams = new HashMap<>();
        final Map<String, Object> localVarFormParams = new HashMap<>();

        final String[] localVarAccepts = { "application/json" };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

        final String[] localVarContentTypes = {};
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

        final String[] localVarAuthNames = new String[] { "evesso" };

        final GenericType<CharacterInfo> localVarReturnType = new GenericType<CharacterInfo>() {
        };

        return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
    }
}

@@ -25,16 +25,45 @@
 i.api;%0A%0A
+import java.text.DateFormat;%0A
 import j
@@ -763,16 +763,89 @@
 Client;%0A
+    %7D%0A%0A    public CharacterInfo getCharacterInfo() throws ApiException %7B%0A
         
@@ -883,16 +883,35 @@
 _OAUTH);
+ //Set new basepath
 %0A       
@@ -974,81 +974,30 @@
 T));
-%0A    %7D%0A%0A    public CharacterInfo getCharacterInfo() throws ApiException %7B
+ //Set new date format
 %0A   
@@ -1779,24 +1779,42 @@
         %7D;%0A%0A
+        try %7B%0A    
         retu
@@ -1934,16 +1934,20 @@
         
+    
 localVar
@@ -2035,16 +2035,183 @@
 nType);%0A
+        %7D finally %7B%0A            apiClient.setBasePath(basePath); //load old basepath%0A            apiClient.setDateFormat(dateFormat); //load old date format%0A        %7D%0A
     %7D%0A%7D%0A

Fix for issue 7 (SsoApi)