All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.criteo.api.marketingsolutions.v2024_01.JSON Maven / Gradle / Ivy

/*
 * Criteo API
 * Criteo API - MarketingSolutions
 *
 * The version of the OpenAPI document: 2024-01
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


package com.criteo.api.marketingsolutions.v2024_01;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.bind.util.ISO8601Utils;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.google.gson.JsonElement;
import io.gsonfire.GsonFireBuilder;
import io.gsonfire.TypeSelector;

import okio.ByteString;

import java.io.IOException;
import java.io.StringReader;
import java.lang.reflect.Type;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.HashMap;

/*
 * A JSON utility class
 *
 * NOTE: in the future, this class may be converted to static, which may break
 *       backward-compatibility
 */
public class JSON {
    private static Gson gson;
    private static boolean isLenientOnJson = false;
    private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter();
    private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter();
    private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
    private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
    private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();

    @SuppressWarnings("unchecked")
    public static GsonBuilder createGson() {
        GsonFireBuilder fireBuilder = new GsonFireBuilder()
        ;
        GsonBuilder builder = fireBuilder.createGsonBuilder();
        return builder;
    }

    private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) {
        JsonElement element = readElement.getAsJsonObject().get(discriminatorField);
        if (null == element) {
            throw new IllegalArgumentException("missing discriminator field: <" + discriminatorField + ">");
        }
        return element.getAsString();
    }

    /**
     * Returns the Java class that implements the OpenAPI schema for the specified discriminator value.
     *
     * @param classByDiscriminatorValue The map of discriminator values to Java classes.
     * @param discriminatorValue The value of the OpenAPI discriminator in the input data.
     * @return The Java class that implements the OpenAPI schema
     */
    private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) {
        Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue);
        if (null == clazz) {
            throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">");
        }
        return clazz;
    }

    {
        GsonBuilder gsonBuilder = createGson();
        gsonBuilder.registerTypeAdapter(Date.class, dateTypeAdapter);
        gsonBuilder.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter);
        gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter);
        gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter);
        gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter);
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.Ad.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdListResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdResource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetAudienceLinkEntityV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetAudienceLinkEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetAudienceLinkEntityV1Response.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetAudienceLinkInputEntityV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetCategoryBid.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetCategoryBidListResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetCategoryBidResource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetDeliveryLimitations.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetDeliveryLimitationsV23Q1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetDisplayMultiplier.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetDisplayMultiplierListResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetDisplayMultiplierResource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetFrequencyCapping.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetFrequencyCappingV23Q1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetGeoLocation.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetGeoLocationV23Q1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetSearchFilterV23Q1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetSearchRequestV23Q1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetTargeting.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetTargetingRule.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetTargetingRuleV23Q1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdSetTargetingV23Q1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdWrite.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdWriteRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdWriteResource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdaptiveAttributes.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdaptiveColors.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AdaptiveWriteAttributes.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AlgebraNodeV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ApplicationSummaryModel.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ApplicationSummaryModelResource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ApplicationSummaryModelResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceBulkCreateInputV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceBulkDeleteInputV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceBulkUpdateInputV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceComputeSizeEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceComputeSizesInputV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceCreateEntityV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceCreateEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceDeleteEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceEntityV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceEntityV1AudienceSearchMetadataV1ListResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceEntityV1ListResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceError.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceEstimateSizeEntityV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceEstimateSizeEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceEstimateSizeInputV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceIdEntityV1ListResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceIdEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceNameDescription.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSearchEntityV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSearchEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSearchInputV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSearchMetadataV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentBulkCreateInputV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentBulkDeleteInputV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentBulkUpdateInputV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentComputeSizeEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentComputeSizesInputV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentCreateEntityV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentCreateEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentDeleteEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentEntityV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentEntityV1AudienceSegmentSearchMetadataV1ListResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentEntityV1ListResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentEstimateSizeInputV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentIdEntityV1ListResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentIdEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentSearchEntityV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentSearchEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentSearchInputV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentSearchMetadataV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentSizeEntityV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentSizeEntityV1ListResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentSizeEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentSizeEstimationEntityV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentSizeEstimationEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentSizeEstimationV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentSizeEstimationV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentSizeEstimationV1Response.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentUpdateEntityV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSegmentUpdateEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSizeEntityV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSizeEntityV1ListResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSizeEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSizeEstimationV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSizeEstimationV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceSizeEstimationV1Response.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceUpdateEntityV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceUpdateEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.AudienceWarning.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.BasicAudienceDefinition.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.BehavioralV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CampaignSearchFiltersV23Q1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CampaignSearchRequestV23Q1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CampaignSpendLimitV23Q1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CampaignV23Q1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CampaignV23Q1ListResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CampaignV23Q1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CampaignV23Q1Response.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CommonProblem.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ContactListStatisticsEntityV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ContactListStatisticsEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ContactListStatisticsEntityV1Response.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ContactListV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ContactlistAmendment.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ContactlistAmendmentAttributes.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ContactlistAmendmentRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ContactlistOperation.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ContactlistOperationAttributes.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.Coupon.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CouponListResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CouponResource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CouponResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CouponSupportedSizes.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CouponSupportedSizesResource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CouponSupportedSizesResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreateAdSet.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreateAdSetBidding.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreateAdSetBudget.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreateAdSetGeoLocation.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreateAdSetRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreateAdSetResource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreateAdSetSchedule.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreateAdSetTargeting.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreateCampaign.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreateCampaignRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreateCampaignResource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreateCampaignSpendLimit.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreateCoupon.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreateCouponRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreateCouponResource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreateImageSlide.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.Creative.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreativeListResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreativeResource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreativeResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreativeWrite.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreativeWriteRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CreativeWriteResource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CriteoApiError.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.CriteoApiWarning.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.DeleteAudienceContactListResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.DynamicAttributes.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.DynamicWriteAttributes.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.EntityOfPortfolioMessage.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ErrorCodeResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.GetPortfolioResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.HtmlTagAttributes.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.HtmlTagWriteAttributes.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ImageAttributes.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ImageSet.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ImageSetBase64.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ImageShape.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ImageSlide.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ImageWriteAttributes.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.InMarketAudienceSegmentBrandEntityV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.InMarketAudienceSegmentBrandEntityV1ListResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.InMarketAudienceSegmentBrandEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.InMarketAudienceSegmentInterestEntityV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.InMarketAudienceSegmentInterestEntityV1ListResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.InMarketAudienceSegmentInterestEntityV1Resource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.InMarketCreateV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.InMarketSizeEstimationV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.InMarketUpdateV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.InMarketV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.LocationCreateV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.LocationSizeEstimationV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.LocationUpdateV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.LocationV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.LookalikeCreateV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.LookalikeUpdateV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.LookalikeV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ModifyAudienceResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.NillableAdSetTargetingRule.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.NillableAdSetTargetingRuleV23Q1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.NillableAdSetTargetingRuleV23Q1Value.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.NillableAdSetTargetingRuleValue.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.NillableDateTime.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.NillableDecimal.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.NillableGenderV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.NillableInt32.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.NillableString.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PatchAdSet.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PatchAdSetBidding.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PatchAdSetBudget.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PatchAdSetCategoryBid.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PatchAdSetCategoryBidListRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PatchAdSetCategoryBidResource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PatchAdSetCategoryBidResultListResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PatchAdSetCategoryBidResultResource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PatchAdSetDisplayMultiplier.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PatchAdSetDisplayMultiplierListRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PatchAdSetDisplayMultiplierResource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PatchAdSetDisplayMultiplierResultListResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PatchAdSetDisplayMultiplierResultResource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PatchAdSetScheduling.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PatchCampaign.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PatchCampaignListRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PatchCampaignSpendLimit.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PatchCampaignWriteResource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PatchResultCampaignListResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PatchResultCampaignReadResource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PlacementsReportQueryDataMessage.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PlacementsReportQueryEntityMessage.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PlacementsReportQueryMessage.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PointOfInterestV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.PortfolioMessage.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ProblemDetails.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ProblemsDetails.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ProspectingCreateV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ProspectingUpdateV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ProspectingV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ReadAdSet.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ReadAdSetBidding.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ReadAdSetBiddingV23Q1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ReadAdSetBudget.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ReadAdSetBudgetV23Q1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ReadAdSetSchedule.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ReadAdSetScheduleV23Q1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ReadAdSetV23Q1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ReadModelAdSetId.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ReadModelReadAdSet.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ReadModelReadAdSetV23Q1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.RequestsAdSetId.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.RequestsPatchAdSet.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ResponseReadAdSet.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ResponseReadAdSetV23Q1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ResponsesAdSetId.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.ResponsesReadAdSetV23Q1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.RetargetingCreateV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.RetargetingUpdateV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.RetargetingV1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.Size.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.StatisticsReportQueryMessage.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.Tag.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.TransactionsReportQueryDataMessage.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.TransactionsReportQueryEntityMessage.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.TransactionsReportQueryMessage.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.TransparencyQueryMessage.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.TransparencyReportAttributes.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.TransparencyReportDataMessage.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.TransparencyReportEntityMessage.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.TransparencyReportFile.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.UpdateCoupon.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.UpdateCouponRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.UpdateCouponResource.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.VideoDetail.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.WriteModelAdSetId.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.criteo.api.marketingsolutions.v2024_01.model.WriteModelPatchAdSet.CustomTypeAdapterFactory());
        gson = gsonBuilder.create();
    }

    /**
     * Get Gson.
     *
     * @return Gson
     */
    public static Gson getGson() {
        return gson;
    }

    /**
     * Set Gson.
     *
     * @param gson Gson
     */
    public static void setGson(Gson gson) {
        JSON.gson = gson;
    }

    public static void setLenientOnJson(boolean lenientOnJson) {
        isLenientOnJson = lenientOnJson;
    }

    /**
     * Serialize the given Java object into JSON string.
     *
     * @param obj Object
     * @return String representation of the JSON
     */
    public static String serialize(Object obj) {
        return gson.toJson(obj);
    }

    /**
     * Deserialize the given JSON string to Java object.
     *
     * @param         Type
     * @param body       The JSON string
     * @param returnType The type to deserialize into
     * @return The deserialized Java object
     */
    @SuppressWarnings("unchecked")
    public static  T deserialize(String body, Type returnType) {
        try {
            if (isLenientOnJson) {
                JsonReader jsonReader = new JsonReader(new StringReader(body));
                // see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean)
                jsonReader.setLenient(true);
                return gson.fromJson(jsonReader, returnType);
            } else {
                return gson.fromJson(body, returnType);
            }
        } catch (JsonParseException e) {
            // Fallback processing when failed to parse JSON form response body:
            // return the response body string directly for the String return type;
            if (returnType.equals(String.class)) {
                return (T) body;
            } else {
                throw (e);
            }
        }
    }

    /**
     * Gson TypeAdapter for Byte Array type
     */
    public static class ByteArrayAdapter extends TypeAdapter {

        @Override
        public void write(JsonWriter out, byte[] value) throws IOException {
            if (value == null) {
                out.nullValue();
            } else {
                out.value(ByteString.of(value).base64());
            }
        }

        @Override
        public byte[] read(JsonReader in) throws IOException {
            switch (in.peek()) {
                case NULL:
                    in.nextNull();
                    return null;
                default:
                    String bytesAsBase64 = in.nextString();
                    ByteString byteString = ByteString.decodeBase64(bytesAsBase64);
                    return byteString.toByteArray();
            }
        }
    }

    /**
     * Gson TypeAdapter for JSR310 OffsetDateTime type
     */
    public static class OffsetDateTimeTypeAdapter extends TypeAdapter {

        private DateTimeFormatter formatter;

        public OffsetDateTimeTypeAdapter() {
            this(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
        }

        public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) {
            this.formatter = formatter;
        }

        public void setFormat(DateTimeFormatter dateFormat) {
            this.formatter = dateFormat;
        }

        @Override
        public void write(JsonWriter out, OffsetDateTime date) throws IOException {
            if (date == null) {
                out.nullValue();
            } else {
                out.value(formatter.format(date));
            }
        }

        @Override
        public OffsetDateTime read(JsonReader in) throws IOException {
            switch (in.peek()) {
                case NULL:
                    in.nextNull();
                    return null;
                default:
                    String date = in.nextString();
                    if (date.endsWith("+0000")) {
                        date = date.substring(0, date.length()-5) + "Z";
                    }
                    return OffsetDateTime.parse(date, formatter);
            }
        }
    }

    /**
     * Gson TypeAdapter for JSR310 LocalDate type
     */
    public static class LocalDateTypeAdapter extends TypeAdapter {

        private DateTimeFormatter formatter;

        public LocalDateTypeAdapter() {
            this(DateTimeFormatter.ISO_LOCAL_DATE);
        }

        public LocalDateTypeAdapter(DateTimeFormatter formatter) {
            this.formatter = formatter;
        }

        public void setFormat(DateTimeFormatter dateFormat) {
            this.formatter = dateFormat;
        }

        @Override
        public void write(JsonWriter out, LocalDate date) throws IOException {
            if (date == null) {
                out.nullValue();
            } else {
                out.value(formatter.format(date));
            }
        }

        @Override
        public LocalDate read(JsonReader in) throws IOException {
            switch (in.peek()) {
                case NULL:
                    in.nextNull();
                    return null;
                default:
                    String date = in.nextString();
                    return LocalDate.parse(date, formatter);
            }
        }
    }

    public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
        offsetDateTimeTypeAdapter.setFormat(dateFormat);
    }

    public static void setLocalDateFormat(DateTimeFormatter dateFormat) {
        localDateTypeAdapter.setFormat(dateFormat);
    }

    /**
     * Gson TypeAdapter for java.sql.Date type
     * If the dateFormat is null, a simple "yyyy-MM-dd" format will be used
     * (more efficient than SimpleDateFormat).
     */
    public static class SqlDateTypeAdapter extends TypeAdapter {

        private DateFormat dateFormat;

        public SqlDateTypeAdapter() {}

        public SqlDateTypeAdapter(DateFormat dateFormat) {
            this.dateFormat = dateFormat;
        }

        public void setFormat(DateFormat dateFormat) {
            this.dateFormat = dateFormat;
        }

        @Override
        public void write(JsonWriter out, java.sql.Date date) throws IOException {
            if (date == null) {
                out.nullValue();
            } else {
                String value;
                if (dateFormat != null) {
                    value = dateFormat.format(date);
                } else {
                    value = date.toString();
                }
                out.value(value);
            }
        }

        @Override
        public java.sql.Date read(JsonReader in) throws IOException {
            switch (in.peek()) {
                case NULL:
                    in.nextNull();
                    return null;
                default:
                    String date = in.nextString();
                    try {
                        if (dateFormat != null) {
                            return new java.sql.Date(dateFormat.parse(date).getTime());
                        }
                        return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
                    } catch (ParseException e) {
                        throw new JsonParseException(e);
                    }
            }
        }
    }

    /**
     * Gson TypeAdapter for java.util.Date type
     * If the dateFormat is null, ISO8601Utils will be used.
     */
    public static class DateTypeAdapter extends TypeAdapter {

        private DateFormat dateFormat;

        public DateTypeAdapter() {}

        public DateTypeAdapter(DateFormat dateFormat) {
            this.dateFormat = dateFormat;
        }

        public void setFormat(DateFormat dateFormat) {
            this.dateFormat = dateFormat;
        }

        @Override
        public void write(JsonWriter out, Date date) throws IOException {
            if (date == null) {
                out.nullValue();
            } else {
                String value;
                if (dateFormat != null) {
                    value = dateFormat.format(date);
                } else {
                    value = ISO8601Utils.format(date, true);
                }
                out.value(value);
            }
        }

        @Override
        public Date read(JsonReader in) throws IOException {
            try {
                switch (in.peek()) {
                    case NULL:
                        in.nextNull();
                        return null;
                    default:
                        String date = in.nextString();
                        try {
                            if (dateFormat != null) {
                                return dateFormat.parse(date);
                            }
                            return ISO8601Utils.parse(date, new ParsePosition(0));
                        } catch (ParseException e) {
                            throw new JsonParseException(e);
                        }
                }
            } catch (IllegalArgumentException e) {
                throw new JsonParseException(e);
            }
        }
    }

    public static void setDateFormat(DateFormat dateFormat) {
        dateTypeAdapter.setFormat(dateFormat);
    }

    public static void setSqlDateFormat(DateFormat dateFormat) {
        sqlDateTypeAdapter.setFormat(dateFormat);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy