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

com.urbanairship.api.channel.parse.email.UpdateEmailChannelResponseReader Maven / Gradle / Ivy

There is a newer version: 9.4.2
Show newest version
package com.urbanairship.api.channel.parse.email;

import com.fasterxml.jackson.core.JsonParser;
import com.urbanairship.api.channel.model.email.EmailChannelResponse;
import com.urbanairship.api.common.parse.APIParsingException;
import com.urbanairship.api.common.parse.JsonObjectReader;

import java.io.IOException;

public class UpdateEmailChannelResponseReader implements JsonObjectReader {

    private final EmailChannelResponse.Builder builder;

    public UpdateEmailChannelResponseReader() {
        this.builder = EmailChannelResponse.newBuilder();
    }

    public void readOk(JsonParser jsonParser) throws IOException {
        builder.setOk(jsonParser.getBooleanValue());
    }

    public void readChannelId(JsonParser jsonParser) throws IOException {
        builder.setChannelId(jsonParser.readValueAs(String.class));
    }

    @Override
    public EmailChannelResponse validateAndBuild() throws IOException {
        try {
            return builder.build();
        } catch (Exception ex) {
            throw new APIParsingException(ex.getMessage());
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy