// Path: src/main/java/me/pagar/util/JSONUtils.java
// public class JSONUtils {
// 
//     public static final Gson getInterpreter() {
//         return getNewDefaultGsonBuilder().create();
//     }
// 
//     public static <T> T getAsObject(JsonObject json, Class<T> clazz) {
//         return getNewDefaultGsonBuilder().create().fromJson(json, clazz);
//     }
// 
//     public static <T> T getAsObject(JsonObject json, DateTimeAdapter adapter, Class<T> clazz) {
//         GsonBuilder builder = getNewDefaultGsonBuilder().registerTypeAdapter(DateTime.class, adapter);
//         return builder.create().fromJson(json, clazz);
//     }
// 
//     public static <T> Collection<T> getAsList(JsonArray json, Type listType) {
//         return getNewDefaultGsonBuilder().create().fromJson(json, listType);
//     }
// 
//     public static <T> Collection<T> getAsList(JsonArray json, DateTimeAdapter adapter, Type listType) {
//         GsonBuilder builder = getNewDefaultGsonBuilder().registerTypeAdapter(DateTime.class, adapter);
//         return builder.create().fromJson(json, listType);
//     }
// 
//     public static String getAsJson(Object object) {
//         return getNewDefaultGsonBuilder().create().toJson(object);
//     }
// 
//     public static String getAsJson(Object object, DateTimeAdapter adapter) {
//         GsonBuilder builder = getNewDefaultGsonBuilder().registerTypeAdapter(DateTime.class, adapter);
//         return builder.create().toJson(object);
//     }
// 
//     public static Map<String, Object> objectToMap(Object object) {
//         GsonBuilder builder = getNewDefaultGsonBuilder();
//         final String json = builder.create().toJson(object);
//         return builder.create().fromJson(json, new TypeToken<HashMap<String, Object>>() {
//         }.getType());
//     }
// 
//     public static Map<String, Object> objectToMap(Object object, DateTimeAdapter adapter) {
//         GsonBuilder builder = getNewDefaultGsonBuilder().registerTypeAdapter(DateTime.class, adapter);
//         final String json = builder.create().toJson(object);
//         return builder.create().fromJson(json, new TypeToken<HashMap<String, Object>>() {
//         }.getType());
//     }
// 
//     public static JsonObject treeToJson(Object object) {
//         return getNewDefaultGsonBuilder().create().toJsonTree(object).getAsJsonObject();
//     }
// 
//     private static GsonBuilder getNewDefaultGsonBuilder(){
//         return new GsonBuilder()
//             .excludeFieldsWithoutExposeAnnotation()
//             .registerTypeAdapter(DateTime.class, new DateTimeIsodateAdapter())
//             .registerTypeAdapter(LocalDate.class, new LocalDateAdapter())
//             .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
//             .setExclusionStrategies(new ExclusionStrategy(){
// 
//                 public boolean shouldSkipClass(Class<?> clazz) {
//                     return false;
//                 }
// 
//                 public boolean shouldSkipField(FieldAttributes fieldAttrs) {
//                     return fieldAttrs.equals(null);
//                 }
//                 
//             });
//     }
// }


import com.google.gson.JsonObject;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import me.pagar.util.JSONUtils;
import javax.ws.rs.HttpMethod;
import java.util.Map;
import java.util.HashMap;
package me.pagar.model;




public class CompaniesTemporary extends PagarMeModel<Integer>{

    @Expose
    @SerializedName("api_key")
    private Map<String, Object> apiKey;

    public String getTemporaryCompanyApiKey(String apiVersion) {
        try {
            final PagarMeRequest request = new PagarMeRequest(HttpMethod.POST, "/companies/temporary");
            request.setParameters(buildApiVersionParameter(apiVersion));
            CompaniesTemporary company = JSONUtils.getAsObject((JsonObject) request.execute(), CompaniesTemporary.class);

            return company.apiKey.get("test").toString();

        } catch (PagarMeException exception) {
            throw new UnsupportedOperationException(exception);
        }
    }

    public Map<String, Object> buildApiVersionParameter(String apiVersion) {
        Map<String, Object> version = new HashMap<String, Object>();
        Map<String, Object> type = new HashMap<String, Object>();
        type.put("test", apiVersion);
        type.put("live", apiVersion);

        version.put("api_version", type);

// Path: src/main/java/me/pagar/util/JSONUtils.java
// public class JSONUtils {
// 
//     public static final Gson getInterpreter() {
//         return getNewDefaultGsonBuilder().create();
//     }
// 
//     public static <T> T getAsObject(JsonObject json, Class<T> clazz) {
//         return getNewDefaultGsonBuilder().create().fromJson(json, clazz);
//     }
// 
//     public static <T> T getAsObject(JsonObject json, DateTimeAdapter adapter, Class<T> clazz) {
//         GsonBuilder builder = getNewDefaultGsonBuilder().registerTypeAdapter(DateTime.class, adapter);
//         return builder.create().fromJson(json, clazz);
//     }
// 
//     public static <T> Collection<T> getAsList(JsonArray json, Type listType) {
//         return getNewDefaultGsonBuilder().create().fromJson(json, listType);
//     }
// 
//     public static <T> Collection<T> getAsList(JsonArray json, DateTimeAdapter adapter, Type listType) {
//         GsonBuilder builder = getNewDefaultGsonBuilder().registerTypeAdapter(DateTime.class, adapter);
//         return builder.create().fromJson(json, listType);
//     }
// 
//     public static String getAsJson(Object object) {
//         return getNewDefaultGsonBuilder().create().toJson(object);
//     }
// 
//     public static String getAsJson(Object object, DateTimeAdapter adapter) {
//         GsonBuilder builder = getNewDefaultGsonBuilder().registerTypeAdapter(DateTime.class, adapter);
//         return builder.create().toJson(object);
//     }
// 
//     public static Map<String, Object> objectToMap(Object object) {
//         GsonBuilder builder = getNewDefaultGsonBuilder();
//         final String json = builder.create().toJson(object);
//         return builder.create().fromJson(json, new TypeToken<HashMap<String, Object>>() {
//         }.getType());
//     }
// 
//     public static Map<String, Object> objectToMap(Object object, DateTimeAdapter adapter) {
//         GsonBuilder builder = getNewDefaultGsonBuilder().registerTypeAdapter(DateTime.class, adapter);
//         final String json = builder.create().toJson(object);
//         return builder.create().fromJson(json, new TypeToken<HashMap<String, Object>>() {
//         }.getType());
//     }
// 
//     public static JsonObject treeToJson(Object object) {
//         return getNewDefaultGsonBuilder().create().toJsonTree(object).getAsJsonObject();
//     }
// 
//     private static GsonBuilder getNewDefaultGsonBuilder(){
//         return new GsonBuilder()
//             .excludeFieldsWithoutExposeAnnotation()
//             .registerTypeAdapter(DateTime.class, new DateTimeIsodateAdapter())
//             .registerTypeAdapter(LocalDate.class, new LocalDateAdapter())
//             .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
//             .setExclusionStrategies(new ExclusionStrategy(){
// 
//                 public boolean shouldSkipClass(Class<?> clazz) {
//                     return false;
//                 }
// 
//                 public boolean shouldSkipField(FieldAttributes fieldAttrs) {
//                     return fieldAttrs.equals(null);
//                 }
//                 
//             });
//     }
// }


// Path: src/main/java/me/pagar/model/CompaniesTemporary.java
import com.google.gson.JsonObject;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import me.pagar.util.JSONUtils;
import javax.ws.rs.HttpMethod;
import java.util.Map;
import java.util.HashMap;

package me.pagar.model;




public class CompaniesTemporary extends PagarMeModel<Integer>{

    @Expose
    @SerializedName("api_key")
    private Map<String, Object> apiKey;

    public String getTemporaryCompanyApiKey(String apiVersion) {
        try {
            final PagarMeRequest request = new PagarMeRequest(HttpMethod.POST, "/companies/temporary");
            request.setParameters(buildApiVersionParameter(apiVersion));
            CompaniesTemporary company = JSONUtils.getAsObject((JsonObject) request.execute(), CompaniesTemporary.class);

            return company.apiKey.get("test").toString();

        } catch (PagarMeException exception) {
            throw new UnsupportedOperationException(exception);
        }
    }

    public Map<String, Object> buildApiVersionParameter(String apiVersion) {
        Map<String, Object> version = new HashMap<String, Object>();
        Map<String, Object> type = new HashMap<String, Object>();
        type.put("test", apiVersion);
        type.put("live", apiVersion);

        version.put("api_version", type);

        return version;