Skip to content

Instantly share code, notes, and snippets.

@toioski
Last active July 16, 2020 13:37
Show Gist options
  • Save toioski/57171b8b207cde0b0c9cb4e88a691e40 to your computer and use it in GitHub Desktop.
Save toioski/57171b8b207cde0b0c9cb4e88a691e40 to your computer and use it in GitHub Desktop.
Monetate "Message" JSON response
// Excel reference file: https://docs.google.com/spreadsheets/d/1QqrhoaTxDEbzShiJHBdLbL_zs2dhvN355AQJ2fRbIx4
enum Language {
ar = "ar",
de = "de",
en = "en",
es = "es",
fr = "fr",
it = "it",
zh = "zh",
ko = "ko"
}
enum ShopDepartment {
Women = "women",
Men = "men",
Kids = "kids"
}
// Ask Vittorio (vittorio.morganti@mytheresa.com) to know which icon is behind each name
interface IconTypes {
arrowContent: string
arrowDownContent: string
caretLeft: string
caretRight: string
checkGrey: string
checkWhite: string
close: string
debug: string
designers: string
filter: string
fta: string
gold: string
heartBlack: string
heartGrey: string
heartPink: string
loadingSpinnerDark: string
loadingSpinnerLight: string
menu: string
metallic: string
multicolor: string
mythLogo: string
newArrivals: string
newArrivalsCh: string
return: string
ruler: string
search: string
share: string
shoppingBag: string
silver: string
tick: string
truck: string
wishlist: string
}
// Explanation
// 1. the question mark (?) means that the key is optional
// 2. the "icon" value could be either an icon already present inside the app or a URL to an external image.
// In the former case, you pass as value one of the strings defined by the interface IconTypes, in the latter
// you give a URL to an external image (maximum size allowed is 3KB)
interface MonetateApiMessage {
messages: [{
contentByLanguage?: { [K in Language]?: string }
contentByStoreview?: { [channel: string]: string }
color?: string // Color of the text of the message
icon?: IconTypes | string // The icon is placed before the text
}]
backgroundColor?: string // Background color of the banner
interval?: number // Number of milliseconds to slide between messages (default is 3000)
url?: { [D in ShopDepartment]: string } // Relative URL to visit on press on the banner
priority?: number // If there are multiple TopLevelBanner experiences active, the higher priority will win
}
// Examples
const response = {
topLevelBanner: {
messages: [
{
contentByStoreview: {
"en-it": "Specific message for english speaking users in Itally"
},
icon: "checkGrey"
},
{
contentByLanguage: {
de: "Home mitteilung custom", // if a language is not defined, no content will be displayed for that language
en: "Home message custom",
it: "Home messaggio custom"
},
icon: "search"
},
{
contentByStoreview: {
"en-de": "Specific message for english speaking users in Germany"
},
contentByLanguage: {
de: "Generic message for German-speaking",
en: "Generic message for English-speaking users outside of Germany",
it: "Generic message for Italian-speaking"
},
icon: "https://i.ibb.co/wCmcdNj/heart-black-4x.png"
}
],
interval: 4000,
url: {
men: "men/new-arrivals.html",
women: "new-arrivals.html",
kids: "kids/new-arrivals.html"
},
priority: 1
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment