0.1.7 • Published 6 years ago

dancecard-email-schemas v0.1.7

Weekly downloads
8
License
ISC
Repository
github
Last release
6 years ago

Dancecard Email Schemas

NPM Package that defines schemas for objects used in the Dancecard Email/Lead Nurturing API. Allows for validation of objects.

Quickstart

Installation

npm install dancecard-email-schemas

Usage

import {
  Template, TemplateBlock, Token,
  Email, EmailSubtype, Program,
  Outcome
} from dancecard-email-schemas;

Objects

Template

propertytypedescriptionrequired
_idstringUnique ID generated by database.yes
template_namestringUser provided Template ID/Nameyes
template_typestring(enum)String: either "Email" or "Page Behind"yes
urlstringURL where Jinja email template is storedyes
page_behindTemplateObject that denotes the name of the page behind template and its Unique ID generated by database.yes
blocksArray<TemplateBlock>List of all blocks that are in this email.yes

Template Block

Template Block object modeled from the following mockup. https://projects.invisionapp.com/freehand/document/7DJGRFO3e

propertytypedescriptionrequired
block_namestringUser provided Template Block ID/Nameyes
block_short_namestringUser provided short version of Template Block ID/Nameyes
placeholderstringBlock name used in templatesyes
block_typestring(enum)String: Either "Text", "CTA", "Video", "Gallery", or "File"yes
subtype_fieldsTemplateBlockSubtypeAn object that will contain any custom fields associated with a specific template block subtypeyes
orderintRelative ordering of block in relation to other blocks for this Template. Starts indexing at 0.yes

Template Block Subtype

propertytypedescriptionrequired
text_block_fieldsTextBlockSubtype or nullAll fields for a Template Block with block_type == "Text" otherwise this property will be nullyes
cta_block_fieldsCTABlockSubtype or nullAll fields for a Template Block with block_type == "CTA" otherwise this property will be nullyes
video_block_fieldsVideoBlockSubtype or nullAll fields for a Template Block with block_type == "Video" otherwise this property will be nullyes
gallery_block_fieldsGalleryBlockSubtype or nullAll fields for a Template Block with block_type == "Gallery"yes
file_block_fieldsFileBlockSubtype or nullAll fields for a Template Block with block_type == "File"yes

Text Block Subtype

propertytypedescriptionrequired
formalstringFormal text sent in an emailyes
casualstringCasual form of text sent in an emailyes

CTA Block Subtype

propertytypedescriptionrequired

Video Block Subtype

propertytypedescriptionrequired

Gallery Block Subtype

propertytypedescriptionrequired

File Block Subtype

propertytypedescriptionrequired

Token

propertytypedescriptionrequired
_idstringUnique ID generated by database.yes
token_namestringUser provided Token ID/Nameyes
placeholderstringToken placeholder used in email templates.yes
jinja_placeholderstringToken placeholder used in the Jinja email templates.yes
end_user_visibilitybooleanIf true show this token to end users in list of available tokens. If false do not show to end users in their list of available tokens.yes
all_program_visibilitybooleanIf true show this token in list of available tokens for all programs. If false this token is to be shown only in the selected programs.yes
programsArray<Program>List of programs this token is visible for.yes

Email

propertytypedescriptionrequired
_idstringUnique ID generated by database.yes
email_namestringUser provided Template ID/Name.yes
templateTemplateTemplate that this Email is using.yes
cta_typestring(enum)String: either "Gallery", "Video", or "Case Study"yes
cta_overridebooleanTODO: Talk to Colin about thisyes
email_typestring(enum)String: Either "First Email", "2+ Email", "Lifecycle Email", "Single Email", or "Opt-In Email"yes
subtype_fieldsEmailSubtypeAn object that will contain any custom fields associated with a specific email subtypeyes
orderintRelative ordering of this email versus other emails of the same email_type. For example if there are 8 total emails with 3 "first emails" and 5 "2+ emails" then the 3 first emails will have order ids of 0, 1, 2 and the 2+ emails will have order ids of 0, 1, 2, 3, 4yes

Email Subtype

propertytypedescriptionrequired
first_email_fieldsFirstEmailSubtype or nullAll fields for an email with email_type == "First Email" otherwise this property will be nullyes
single_email_fieldsSingleEmailSubtype or nullAll fields for an email with email_type == "Single Email" otherwise this property will be nullyes
opt_in_email_fieldsOptInEmailSubtype or nullAll fields for an email with email_type == "Opt-In Email" otherwise this property will be nullyes

First Email Subtype

propertytypedescriptionrequired
outcomeOutcomeAn outcome object that this email is associated with.yes

Single Email Subtype

propertytypedescriptionrequired
subjectstringSubject line for single email.yes
salutationstringSalutation used for single email.yes
bodystringBody of email used for single email.
signaturestringSignature used for single email.yes

Opt-In Email Subtype

propertytypedescriptionrequired
subjectstringSubject line for opt-in email.yes
salutationstringSalutation used for opt-in email.yes
bodystringBody of email used for opt-in email.yes
signaturestringSignature used for opt-in email.yes

Program

propertytypedescriptionrequired
_idstringUnique ID generated by database.yes
program_namestringUser provided Program ID/Name.yes
created_onintUnix timestamp of creation dateyes
created_on_friendlystringMM/DD/YYYY date string of creation date.yes
updated_onintUnix timestamp of last update date.yes
updated_on_friendlystringMM/DD/YYYY date string of last update date.yes
activebooleanTrue if this program is active. False if this program is not active.yes
emailsArray<Email>List of all emails in this program.yes

Outcome

These outcomes are setup in Dancecard.

propertytypedescriptionrequired
_idstringUnique ID generated by database for outcome.yes
outcome_namestringUser provided name for outcome.yes

Validation

To validate an object after constructing it you simply need to import the EmailSchemasValidator object and the associated object schema. Once you have done that you can get a validation object by running the validate() function of the validator.

Following is an example of constructing and validating a Token object.

import { EmailSchemasValidator, Token } from 'dancecard-email-schemas'
let t = {
  _id = "atestid",
  token_name: "A test token",
  placeholder: "test placeholder",
  jinja_placeholder: "{test_token}",
  end_user_visibility: true,
  all_program_visibility: true,
  programs: []
}

console.log(EmailSchemasValidator.validate(t, Token))

Building

npm run build

Testing

npm run test
0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago