Class FlexSlackMessage

All Implemented Interfaces:
Serializable

public class FlexSlackMessage extends SlackRequestPojo
An object representing a nicely formatted slack message. Set relevant fields with setters and adds. Finally call the toString method to return the json representation which can be sent via API call to slack.
See Also:
  • Field Details

  • Constructor Details

    • FlexSlackMessage

      public FlexSlackMessage(String pMessage, String pIconEmoji, String pColor)
      Parameters:
      pMessage - Header level text/message
      pIconEmoji - Icon to place in header message
      pColor - Color to give this message - will only be used if additional fields are present
    • FlexSlackMessage

      public FlexSlackMessage()
  • Method Details

    • setColor

      public void setColor(String pColor)
      Set a color theme for the message, note this color only shows up if the slack message has additional fields
      Parameters:
      pColor - Any valid css color string
    • getColor

      public String getColor()
    • addButton

      public void addButton(String pBtnText, String pStyle, String pAction, Object pValue)
      Adds a button to the slack message, each button will show up in a button row between the header and key/value details
      Parameters:
      pBtnText - Text/name of the button
      pStyle - Style for the button, only options are 'danger', 'primary', or 'default'
      pAction - Any string value representing the action of the button. This value will be passed back in webhooks. E.G 'approve', 'reject'.
      pValue - Any value to associate with this button. This is usually an id or name in another system. Task Id or Object Name. This is also passed back in webhooks.
    • clearAdditionalFields

      public void clearAdditionalFields()
      Clears all additional fields that have been added to the message
    • addAdditionalField

      public void addAdditionalField(String pKey, String pValue, Boolean pIsShort)
      Adds an additional key/value item below the message header.
      Parameters:
      pKey - key
      pValue - value
      pIsShort - If short is true then two fields will fit on a single row
    • addAdditionalField

      public void addAdditionalField(String pKey, String pValue)
      Adds an additional key/value item below the message header.
      Parameters:
      pKey - key
      pValue - value
    • toString

      public String toString()
      Convert this Object to a Json string representation with no formatting
      Overrides:
      toString in class BasePOJO
      Returns:
      a String representation of this object
    • toString

      public String toString(int pIndentFactor)
      Convert this Object to a Json string representation with the given indent factor
      Parameters:
      pIndentFactor - The indent factor when formatting the json payload
      Returns: