com.urbanairship.api.createandsend.parse.CreateAndSendEmailChannelSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-client Show documentation
Show all versions of java-client Show documentation
The Urban Airship Java client library
package com.urbanairship.api.createandsend.parse;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.urbanairship.api.common.parse.DateFormats;
import com.urbanairship.api.createandsend.model.audience.email.EmailChannel;
import java.io.IOException;
public class CreateAndSendEmailChannelSerializer extends JsonSerializer {
@Override
public void serialize(EmailChannel payload, JsonGenerator jgen, SerializerProvider serializerProvider) throws IOException {
jgen.writeStartObject();
jgen.writeStringField("ua_address", payload.getUaAddress());
if (payload.getCommercialOptedIn().isPresent()) {
jgen.writeStringField("ua_commercial_opted_in", DateFormats.DATE_FORMATTER.print(payload.getCommercialOptedIn().get()));
} else if (payload.getTransactionalOptedIn().isPresent()) {
jgen.writeStringField("ua_transactional_opted_in", DateFormats.DATE_FORMATTER.print(payload.getTransactionalOptedIn().get()));
}
jgen.writeEndObject();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy