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

com.azure.resourcemanager.botservice.models.KikChannelProperties Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for BotService Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Azure Bot Service is a platform for creating smart conversational agents. Package tag package-2021-03-01.

The newest version!
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.botservice.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;

/**
 * The parameters to provide for the Kik channel.
 */
@Fluent
public final class KikChannelProperties implements JsonSerializable {
    /*
     * The Kik user name
     */
    private String username;

    /*
     * Kik API key. Value only returned through POST to the action Channel List API, otherwise empty.
     */
    private String apiKey;

    /*
     * Whether this channel is validated for the bot
     */
    private Boolean isValidated;

    /*
     * Whether this channel is enabled for the bot
     */
    private boolean isEnabled;

    /**
     * Creates an instance of KikChannelProperties class.
     */
    public KikChannelProperties() {
    }

    /**
     * Get the username property: The Kik user name.
     * 
     * @return the username value.
     */
    public String username() {
        return this.username;
    }

    /**
     * Set the username property: The Kik user name.
     * 
     * @param username the username value to set.
     * @return the KikChannelProperties object itself.
     */
    public KikChannelProperties withUsername(String username) {
        this.username = username;
        return this;
    }

    /**
     * Get the apiKey property: Kik API key. Value only returned through POST to the action Channel List API, otherwise
     * empty.
     * 
     * @return the apiKey value.
     */
    public String apiKey() {
        return this.apiKey;
    }

    /**
     * Set the apiKey property: Kik API key. Value only returned through POST to the action Channel List API, otherwise
     * empty.
     * 
     * @param apiKey the apiKey value to set.
     * @return the KikChannelProperties object itself.
     */
    public KikChannelProperties withApiKey(String apiKey) {
        this.apiKey = apiKey;
        return this;
    }

    /**
     * Get the isValidated property: Whether this channel is validated for the bot.
     * 
     * @return the isValidated value.
     */
    public Boolean isValidated() {
        return this.isValidated;
    }

    /**
     * Set the isValidated property: Whether this channel is validated for the bot.
     * 
     * @param isValidated the isValidated value to set.
     * @return the KikChannelProperties object itself.
     */
    public KikChannelProperties withIsValidated(Boolean isValidated) {
        this.isValidated = isValidated;
        return this;
    }

    /**
     * Get the isEnabled property: Whether this channel is enabled for the bot.
     * 
     * @return the isEnabled value.
     */
    public boolean isEnabled() {
        return this.isEnabled;
    }

    /**
     * Set the isEnabled property: Whether this channel is enabled for the bot.
     * 
     * @param isEnabled the isEnabled value to set.
     * @return the KikChannelProperties object itself.
     */
    public KikChannelProperties withIsEnabled(boolean isEnabled) {
        this.isEnabled = isEnabled;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (username() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Missing required property username in model KikChannelProperties"));
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(KikChannelProperties.class);

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("userName", this.username);
        jsonWriter.writeBooleanField("isEnabled", this.isEnabled);
        jsonWriter.writeStringField("apiKey", this.apiKey);
        jsonWriter.writeBooleanField("isValidated", this.isValidated);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of KikChannelProperties from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of KikChannelProperties if the JsonReader was pointing to an instance of it, or null if it
     * was pointing to JSON null.
     * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
     * @throws IOException If an error occurs while reading the KikChannelProperties.
     */
    public static KikChannelProperties fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            KikChannelProperties deserializedKikChannelProperties = new KikChannelProperties();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("userName".equals(fieldName)) {
                    deserializedKikChannelProperties.username = reader.getString();
                } else if ("isEnabled".equals(fieldName)) {
                    deserializedKikChannelProperties.isEnabled = reader.getBoolean();
                } else if ("apiKey".equals(fieldName)) {
                    deserializedKikChannelProperties.apiKey = reader.getString();
                } else if ("isValidated".equals(fieldName)) {
                    deserializedKikChannelProperties.isValidated = reader.getNullable(JsonReader::getBoolean);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedKikChannelProperties;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy