cloud.genesys.webmessaging.sdk.model.ContentCardAction Maven / Gradle / Ivy
package cloud.genesys.webmessaging.sdk.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import java.util.Objects;
import java.io.IOException;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
* A card action that a user can take.
*/
@ApiModel(description = "A card action that a user can take.")
public class ContentCardAction implements Serializable {
private static class TypeEnumDeserializer extends StdDeserializer {
public TypeEnumDeserializer() {
super(TypeEnumDeserializer.class);
}
@Override
public TypeEnum deserialize(JsonParser jsonParser, DeserializationContext ctxt)
throws IOException {
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
return TypeEnum.fromString(node.toString().replace("\"", ""));
}
}
/**
* Describes the type of action.
*/
@JsonDeserialize(using = TypeEnumDeserializer.class)
public enum TypeEnum {
OUTDATEDSDKVERSION("OutdatedSdkVersion"),
LINK("Link"),
POSTBACK("Postback");
private String value;
TypeEnum(String value) {
this.value = value;
}
@JsonCreator
public static TypeEnum fromString(String key) {
if (key == null) return null;
for (TypeEnum value : TypeEnum.values()) {
if (key.equalsIgnoreCase(value.toString())) {
return value;
}
}
return TypeEnum.values()[0];
}
@Override
@JsonValue
public String toString() {
return String.valueOf(value);
}
}
private TypeEnum type = null;
private String text = null;
private String payload = null;
private String url = null;
/**
* Describes the type of action.
**/
public ContentCardAction type(TypeEnum type) {
this.type = type;
return this;
}
@ApiModelProperty(example = "null", value = "Describes the type of action.")
@JsonProperty("type")
public TypeEnum getType() {
return type;
}
public void setType(TypeEnum type) {
this.type = type;
}
/**
* The response text from the button click.
**/
public ContentCardAction text(String text) {
this.text = text;
return this;
}
@ApiModelProperty(example = "null", value = "The response text from the button click.")
@JsonProperty("text")
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
/**
* Text to be returned as the payload from a ButtonResponse when a button is clicked. The payload and text are a combination which will have to be unique across each card and carousel in order to determine which button was clicked in that card or carousel.
**/
public ContentCardAction payload(String payload) {
this.payload = payload;
return this;
}
@ApiModelProperty(example = "null", value = "Text to be returned as the payload from a ButtonResponse when a button is clicked. The payload and text are a combination which will have to be unique across each card and carousel in order to determine which button was clicked in that card or carousel.")
@JsonProperty("payload")
public String getPayload() {
return payload;
}
public void setPayload(String payload) {
this.payload = payload;
}
/**
* A URL of a web page to direct the user to.
**/
public ContentCardAction url(String url) {
this.url = url;
return this;
}
@ApiModelProperty(example = "null", value = "A URL of a web page to direct the user to.")
@JsonProperty("url")
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ContentCardAction contentCardAction = (ContentCardAction) o;
return Objects.equals(this.type, contentCardAction.type) &&
Objects.equals(this.text, contentCardAction.text) &&
Objects.equals(this.payload, contentCardAction.payload) &&
Objects.equals(this.url, contentCardAction.url);
}
@Override
public int hashCode() {
return Objects.hash(type, text, payload, url);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ContentCardAction {\n");
sb.append(" type: ").append(toIndentedString(type)).append("\n");
sb.append(" text: ").append(toIndentedString(text)).append("\n");
sb.append(" payload: ").append(toIndentedString(payload)).append("\n");
sb.append(" url: ").append(toIndentedString(url)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}