-
public class CEPPayloadParser
-
-
Field Summary
Fields Modifier and Type Field Description private final StringDEFAULT_LIGHT_COLORprivate final StringDEFAULT_DARK_COLORprivate final IntegerDEFAULT_WEBVIEW_TIMEOUTpublic final static CEPPayloadParserINSTANCE
-
Method Summary
Modifier and Type Method Description final static MessageparsePayload(JSONObject payload)Parses a JSON payload representing an in-app message into a Messageobject.final RootContainerparseRootContainer(JSONObject payload, InAppProperty.Format format)Parses a JSON object representing the root container of a layout. final List<InAppComponent>parseComponents(JSONArray payload, InAppProperty.Format format)Parses a JSONArray representing a list of in-app component definitions into a list of InAppComponentobjects.final List<InAppComponent.Column>parseColumnsChildren(JSONArray payload, InAppProperty.Format format)Parses a JSONArray representing a list of column definitions into a list of InAppComponent.Columnobjects.final InAppComponentparseComponent(JSONObject payload, InAppProperty.Format format)Parses a JSON payload representing a component and returns the corresponding InAppComponent object. final InAppComponent.TextparseText(JSONObject payload)Parses a JSON payload to create an InAppComponent.Text object. final InAppComponent.ButtonparseButton(JSONObject payload)Parses a JSON payload representing a button and returns an InAppComponent.Button object. final InAppComponent.ImageparseImage(JSONObject payload, InAppProperty.Format format)Parses a JSON payload to create an InAppComponent.Image object. final InAppComponent.DividerparseDivider(JSONObject payload)Parses a JSON payload to create an InAppComponent.Divider object. final InAppComponent.ColumnsparseColumns(JSONObject payload, InAppProperty.Format format)Parses a JSON payload to create an InAppComponent.Columns object. final InAppComponent.SpacerparseSpacer(JSONObject payload, InAppProperty.Format format)Parses a JSON payload to create an InAppComponent.Spacer object. final InAppComponent.WebViewparseWebView(JSONObject payload)Parses a JSON payload to create an InAppComponent.WebView object. final CloseOptionsparseCloseOptions(JSONObject payload)Parses a JSON payload representing the CloseOptions for an In-App message. final Map<String, Action>parseActions(JSONObject payload)Parses a JSON payload representing the actions for an In-App message. final InAppProperty.BorderparseBorder(JSONObject payload)Parses a JSON payload representing a Border object. final Set<InAppProperty.FontDecoration>parseFontDecoration(JSONArray payload)Parses a JSON payload representing a list of font decorations. final InAppProperty.ThemeColorsparseColor(JSONArray value)Parses a JSON payload representing a LightDarkColorTuple. final InAppProperty.MarginparseMargin(JSONArray value)Parses a JSON payload representing a Margin array. final InAppProperty.CornerRadiusparseRadius(JSONArray value)Parses a JSON payload representing a radius array. final FloatArrayparseColumnRatio(JSONArray value)Parses a JSON payload representing a list of column ratios. final Map<String, String>parseMap(JSONObject payload)Parses a JSON payload representing a map of strings. final StringgetDEFAULT_LIGHT_COLOR()Default values for light and dark colors. final StringgetDEFAULT_DARK_COLOR()Default value for dark color. final IntegergetDEFAULT_WEBVIEW_TIMEOUT()Default values for timeout -
-
Method Detail
-
parsePayload
final static Message parsePayload(JSONObject payload)
Parses a JSON payload representing an in-app message into a
Messageobject.- Parameters:
payload- The JSON object containing the message payload.
-
parseRootContainer
@VisibleForTesting() final RootContainer parseRootContainer(JSONObject payload, InAppProperty.Format format)
Parses a JSON object representing the root container of a layout.
- Parameters:
payload- The JSON object containing the root container data.
-
parseComponents
@VisibleForTesting() final List<InAppComponent> parseComponents(JSONArray payload, InAppProperty.Format format)
Parses a JSONArray representing a list of in-app component definitions into a list of
InAppComponentobjects.- Parameters:
payload- The JSONArray containing the definitions of in-app components.
-
parseColumnsChildren
@VisibleForTesting() final List<InAppComponent.Column> parseColumnsChildren(JSONArray payload, InAppProperty.Format format)
Parses a JSONArray representing a list of column definitions into a list of
InAppComponent.Columnobjects.- Parameters:
payload- The JSONArray containing the columns of in-app components.
-
parseComponent
@VisibleForTesting() final InAppComponent parseComponent(JSONObject payload, InAppProperty.Format format)
Parses a JSON payload representing a component and returns the corresponding InAppComponent object.
This function acts as a factory for creating different types of InAppComponent objects based on the "type" field within the provided JSON payload. It supports parsing for "text", "button", "image", "divider", and "columns" component types.
- Parameters:
payload- The JSONObject representing the component.
-
parseText
@VisibleForTesting() final InAppComponent.Text parseText(JSONObject payload)
Parses a JSON payload to create an InAppComponent.Text object.
- Parameters:
payload- The JSON object containing the text properties.
-
parseButton
@VisibleForTesting() final InAppComponent.Button parseButton(JSONObject payload)
Parses a JSON payload representing a button and returns an InAppComponent.Button object.
- Parameters:
payload- The JSON object containing the button's configuration.
-
parseImage
@VisibleForTesting() final InAppComponent.Image parseImage(JSONObject payload, InAppProperty.Format format)
Parses a JSON payload to create an InAppComponent.Image object.
- Parameters:
payload- The JSON object containing the image's configuration.
-
parseDivider
@VisibleForTesting() final InAppComponent.Divider parseDivider(JSONObject payload)
Parses a JSON payload to create an InAppComponent.Divider object.
- Parameters:
payload- The JSON object containing the divider's configuration.
-
parseColumns
@VisibleForTesting() final InAppComponent.Columns parseColumns(JSONObject payload, InAppProperty.Format format)
Parses a JSON payload to create an InAppComponent.Columns object.
- Parameters:
payload- The JSON object containing the columns' configuration.
-
parseSpacer
@VisibleForTesting() final InAppComponent.Spacer parseSpacer(JSONObject payload, InAppProperty.Format format)
Parses a JSON payload to create an InAppComponent.Spacer object.
- Parameters:
payload- The JSON object containing the spacer's configuration.
-
parseWebView
@VisibleForTesting() final InAppComponent.WebView parseWebView(JSONObject payload)
Parses a JSON payload to create an InAppComponent.WebView object.
- Parameters:
payload- The JSON object containing the webview's configuration.
-
parseCloseOptions
@VisibleForTesting() final CloseOptions parseCloseOptions(JSONObject payload)
Parses a JSON payload representing the CloseOptions for an In-App message.
-
parseActions
@VisibleForTesting() final Map<String, Action> parseActions(JSONObject payload)
Parses a JSON payload representing the actions for an In-App message.
-
parseBorder
@VisibleForTesting() final InAppProperty.Border parseBorder(JSONObject payload)
Parses a JSON payload representing a Border object.
- Parameters:
payload- The JSON object containing the border properties.
-
parseFontDecoration
@VisibleForTesting() final Set<InAppProperty.FontDecoration> parseFontDecoration(JSONArray payload)
Parses a JSON payload representing a list of font decorations.
- Parameters:
payload- The JSON array containing the font decorations.
-
parseColor
@VisibleForTesting() final InAppProperty.ThemeColors parseColor(JSONArray value)
Parses a JSON payload representing a LightDarkColorTuple.
- Parameters:
value- The JSON array containing the color values.
-
parseMargin
@VisibleForTesting() final InAppProperty.Margin parseMargin(JSONArray value)
Parses a JSON payload representing a Margin array.
- Parameters:
value- The JSON array containing the integer values.
-
parseRadius
@VisibleForTesting() final InAppProperty.CornerRadius parseRadius(JSONArray value)
Parses a JSON payload representing a radius array.
- Parameters:
value- The JSON array containing the integer values.
-
parseColumnRatio
@VisibleForTesting() final FloatArray parseColumnRatio(JSONArray value)
Parses a JSON payload representing a list of column ratios.
- Parameters:
value- The JSON array containing the column ratios.
-
parseMap
@VisibleForTesting() final Map<String, String> parseMap(JSONObject payload)
Parses a JSON payload representing a map of strings.
- Parameters:
payload- The JSON object containing the map.
-
getDEFAULT_LIGHT_COLOR
final String getDEFAULT_LIGHT_COLOR()
Default values for light and dark colors.
-
getDEFAULT_DARK_COLOR
final String getDEFAULT_DARK_COLOR()
Default value for dark color.
-
getDEFAULT_WEBVIEW_TIMEOUT
final Integer getDEFAULT_WEBVIEW_TIMEOUT()
Default values for timeout
-
-
-
-