Skip to content

Instantly share code, notes, and snippets.

@toioski
Created March 25, 2020 10:24
Show Gist options
  • Save toioski/1cdb3f5705e65717991805764e6140aa to your computer and use it in GitHub Desktop.
Save toioski/1cdb3f5705e65717991805764e6140aa to your computer and use it in GitHub Desktop.
Monetate "Overlay" JSON response
// Excel reference file: https://docs.google.com/spreadsheets/d/1QqrhoaTxDEbzShiJHBdLbL_zs2dhvN355AQJ2fRbIx4
// ----------------
// Types definition
// ----------------
enum Language {
ar = "ar",
de = "de",
en = "en",
es = "es",
fr = "fr",
it = "it",
zh = "zh",
ko = "ko"
}
export enum ShopDepartment {
Women = "women",
Men = "men",
Kids = "kids"
}
// TIP: the question mark means that is optional
interface IMonetateOverlayAction {
title: { [K in Language]?: string }
body: { [K in Language]?: string }
cta: {
copy: { [K in Language]?: string }
url: { [D in ShopDepartment]: string }
}
priority?: number // If there are multiple Overlay experiences active, the higher priority will win
}
// Examples
// N.B. if a language is not defined, no content will be displayed for that language
const response = {
"overlay": {
"title": { "en": "Don't miss out" },
"body": { "en": "Sign up to our newsletter for exclusive access to limited-edition collaborations, preshopping events, private sales and much more." },
"cta": {
"copy": { "en": "Sign up now" },
"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