From 043d4ac8cb5a52fb41fd0eb8f64f3c0945ef85a3 Mon Sep 17 00:00:00 2001 From: Justin Warmkessel Date: Wed, 18 Dec 2024 10:59:18 -0800 Subject: [PATCH] Use upper case notation for enums with a string representation for the page type --- .../api/shopperinsights/PageType.kt | 28 +++++++++++-------- .../shopperinsights/ShopperInsightsClient.kt | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/PageType.kt b/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/PageType.kt index f746bbf58f..2b4ae0879f 100644 --- a/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/PageType.kt +++ b/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/PageType.kt @@ -3,59 +3,63 @@ package com.braintreepayments.api.shopperinsights /** * The page or view that a button is displayed on. */ -enum class PageType { +enum class PageType(internal val stringValue: String) { /** * The homepage */ - homepage, + HOMEPAGE("homepage"), /** * The about page */ - about, + ABOUT("about"), /** * The contact page */ - contact, + CONTACT("contact"), /** * A product category page */ - product_category, + PRODUCT_CATEGORY("product_category"), /** * The product details page */ - product_details, + PRODUCT_DETAILS("product_details"), /** * The search page */ - search, + SEARCH("search"), /** * The checkout page */ - checkout, + CHECKOUT("checkout"), /** * The order review page */ - order_review, + ORDER_REVIEW("order_review"), /** * The order confirmation page */ - order_confirmation, + ORDER_CONFIRMATION("order_confirmation"), /** * The mini cart */ - mini_cart, + MINI_CAR("mini_cart"), /** * Some other page */ - other + OTHER("other"); + + internal fun getStringRepresentation(): String { + return stringValue + } } diff --git a/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/ShopperInsightsClient.kt b/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/ShopperInsightsClient.kt index 53258a7ec3..3eb6d503ae 100644 --- a/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/ShopperInsightsClient.kt +++ b/ShopperInsights/src/main/java/com/braintreepayments/api/shopperinsights/ShopperInsightsClient.kt @@ -182,7 +182,7 @@ class ShopperInsightsClient internal constructor( shopperSessionId = shopperSessionId, buttonType = buttonType.getStringRepresentation(), buttonOrder = presentmentDetails.buttonOrder.getStringRepresentation(), - pageType = presentmentDetails.pageType.toString() + pageType = presentmentDetails.pageType.getStringRepresentation() ) braintreeClient.sendAnalyticsEvent(BUTTON_PRESENTED, params)