// 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 java.util.ArrayList;
import java.util.Collection;
import com.google.gson.reflect.TypeToken;
import org.joda.time.LocalDate;
import me.pagar.util.JSONUtils;
import javax.ws.rs.HttpMethod;

    public enum Type {
        @SerializedName("individual")
        INDIVIDUAL,

        @SerializedName("corporation")
        CORPORATION
    }

    public Customer save() throws PagarMeException {

        final Customer saved = super.save(getClass());
        copy(saved);

        return saved;
    }

    public Customer find(int id) throws PagarMeException {

        final PagarMeRequest request = new PagarMeRequest(HttpMethod.GET,
                String.format("/%s/%s", getClassName(), id));

        final Customer other = JSONUtils.getAsObject((JsonObject) request.execute(), Customer.class);
        copy(other);
        flush();

        return other;
    }

    public Collection<Customer> findCollection(int totalPerPage, int page) throws PagarMeException {
// 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/Customer.java
import com.google.gson.JsonObject;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
import java.util.Collection;
import com.google.gson.reflect.TypeToken;
import org.joda.time.LocalDate;
import me.pagar.util.JSONUtils;
import javax.ws.rs.HttpMethod;


    public enum Type {
        @SerializedName("individual")
        INDIVIDUAL,

        @SerializedName("corporation")
        CORPORATION
    }

    public Customer save() throws PagarMeException {

        final Customer saved = super.save(getClass());
        copy(saved);

        return saved;
    }

    public Customer find(int id) throws PagarMeException {

        final PagarMeRequest request = new PagarMeRequest(HttpMethod.GET,
                String.format("/%s/%s", getClassName(), id));

        final Customer other = JSONUtils.getAsObject((JsonObject) request.execute(), Customer.class);
        copy(other);
        flush();

        return other;
    }

    public Collection<Customer> findCollection(int totalPerPage, int page) throws PagarMeException {
        return JSONUtils.getAsList(super.paginate(totalPerPage, page), new TypeToken<Collection<Customer>>() {