Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import dev.vml.es.acm.core.util.StringUtil;
import java.io.Serializable;
import java.util.*;
Expand Down Expand Up @@ -55,13 +56,17 @@ public Builder message(String title, String text, Map<String, Object> fields) {
return this;
}

public Builder text(String text) {
public Builder text(String text, boolean wrap) {
if (StringUtils.isNotBlank(text)) {
body.add(TextBlock.create(text));
body.add(TextBlock.create(text).wrap(wrap));
}
return this;
}

public Builder text(String text) {
return this.text(text, true);
}

public Builder title(String title) {
if (StringUtils.isNotBlank(title)) {
body.add(0, TextBlock.create(title).size("Large").weight("Bolder"));
Expand Down Expand Up @@ -110,6 +115,13 @@ public Builder facts(Map<String, Object> fields) {
return this;
}

public Builder cardElement(CardElement cardElement) {
if (cardElement != null) {
body.add(cardElement);
}
return this;
}

public Builder openUrlAction(String title, String url) {
if (StringUtils.isNotBlank(title) && StringUtils.isNotBlank(url)) {
actions.add(Action.openUrl(title, url));
Expand Down Expand Up @@ -149,6 +161,7 @@ public AdaptiveCard getContent() {
}

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({"type", "$schema", "version", "msteams", "body", "actions"})
public static final class AdaptiveCard implements Serializable {

private final String type = "AdaptiveCard";
Expand All @@ -158,6 +171,8 @@ public static final class AdaptiveCard implements Serializable {

private final String version = "1.2";

private final Map<String, String> msteams = Collections.singletonMap("width", "full");

private final List<CardElement> body;

private final List<Action> actions;
Expand All @@ -183,6 +198,10 @@ public String getVersion() {
return version;
}

public Map<String, String> getMsteams() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

msteams? :) what's the purpose of it? why such strange name?

return msteams;
}

public List<CardElement> getBody() {
return body;
}
Expand All @@ -203,7 +222,7 @@ public static final class TextBlock implements CardElement, Serializable {

private String weight;

private Boolean wrap;
private Boolean wrap = true;

private TextBlock(String text) {
this.text = StringUtils.defaultString(text);
Expand Down
Loading