hasOwnProperty

Check to see if an object has a property, typescript cast as object type if it does.

hasOwnProperty(obj: any, prop: String): Boolean
Parameters
obj (any) Object to test
prop (String) Property to check for
Returns
Boolean: True if found, false if not

getClosestDay

Returns the closest day record to the current date

getClosestDay(days: Array<Day>): (Day | Boolean)
Parameters
days (Array<Day>) Array of Master Tour Day objects
Returns
(Day | Boolean): Master Tour Day object or false if no day found

getContactInfo

Builds a simple array of phone, email, and URL info.

getContactInfo(item: Object, t: Func, libs: Object): Array
Parameters
item (Object) Item to be extracted
t (Func = x=>x) Translation
libs (Object) Dependencies
Returns
Array: Array of objects with type and url added to the contact method

compareStrings

String compare function for use in sorting arrays

compareStrings(a: string, b: string): number
Parameters
a (string = "") first string to compare
b (string = "") second string to compare
Returns
number: 1 if b is greater, -1 if a is greater, 0 if equal
Example
import { compareStrings } from "@eventric/mastertour"

// -1
const formattedAddress = compareStrings("tango", "bravo");
// 0
const formattedAddress = compareStrings("racecar", "RACECAR");

isValidTimeZone

Check to see if a timezone is valid with a predefined list of invalid options, and others checked from moment-timezone's database

isValidTimeZone(zone: string): boolean
Parameters
zone (string) TimeZone value to check
Returns
boolean: true if valid, false if not
Example
import { isValidTimeZone } from "@eventric/mastertour"

// true
const valid = isValidTimeZone("America/Chicago");
// false
const valid = isValidTimeZone("glenn");

convertFromXML

Convert a Master Tour XML field to a Javascript object

convertFromXML
Parameters
input (string) XML string to be converted
Returns
(string | object): If valid XML, it will be a Javascript object, otherwise, the original string
Example
import { convertFromXML } from "@eventric/mastertour"

// {dataStore: { audioPower: "200amp 3-Phase" } }
const values = convertFromXML("<dataStore><audioPower>200amp 3-Phase</audioPower></dataStore>");
// "some string that isn't XML"
const values = convertFromXML("some string that isn't XML");

getDatesBetweenDates

Build an array of date objects beginning with the start date, ending with the end date, and include an array item for each day in-between

getDatesBetweenDates(options: Object): Array
Parameters
options (Object)
Name Description
options.startDate Date Start Date
options.endDate Date End Date
Returns
Array: Array of date objects
Example
import { getDatesBetweenDates } from "@eventric/mastertour"
// returns [Date(2021, 0, 1), Date(2021, 0, 2), Date(2021, 0, 3)]
getDatesBetweenDates({
	startDate: new Date(2021, 0, 1),
	endDate: new Date(2021, 0, 3)
})

initials

Takes in a rgb color string and determines if color hue is light for dark text or vice verse

initials(options: object): string
Parameters
options (object)
Name Description
options.incomingString string String to check
options.initialsCount number? (default 3) Max number of initials
Returns
string: capitalized initials of passed string
Example
import { initials } from "@eventric/mastertour"

const data = { incomingString: "Weird Al Yankovich" };

// "WAY"
const truncatedData = initials(data);

getPhoneEmailUrl

Extract the contact records in an easier to use format from a Company or Contact record

getPhoneEmailUrl(item: Object): Object
Parameters
item (Object) Object with a phoneXml field
Returns
Object: Object with arrays of email, phone, and url records.

getAttachmentPath

getAttachmentPath will generate a standardized path for a file based on the organizationId, parentVo/id, and it's subtype.

getAttachmentPath(attachment: Attachment, options: object): string
Parameters
attachment (Attachment) Master Tour Attachment record
options (object = {})
Name Description
options.sep string (default "/") Directory separator, defaults to "/"
options.includeFilename boolean (default true) Whether to include the filename in the path output, defaults to true
Returns
string: Standardized path for file
Example
import { getAttachmentPath } from "@eventric/mastertour"

const attachment = {
	organizationId: "org12345",
	parentVo: "day",
	parentId: "day12345",
	subtype: "attachment",
	filename: "tech-pack.pdf"
};

// "org12345/day-day12345/attachment/tech-pack.pdf"
const pathToFile = getAttachmentPath(attachment);

formatAddress

Formats an address as "adressLine1, city, state zip country"

formatAddress(address: object, options: object): string
Parameters
address (object)
Name Description
address.addressLine1 string first address
address.city string city
address.state string state
address.zip string zip
address.zipcode string zipcode
address.country string country
options (object = {})
Name Description
options.translate function Translate function, if included translates country value if it is only 2 letters long
options.translatePrefix string (default "") String to prefix the country value with if needed
Returns
string: Standardized address
Example
import { formatAddress } from "@eventric/mastertour"

const data = {
	addressLine1: "123 Main st",
	city: "MockCity",
	country: "MockCountry"
	state: "MockState",
	zip: "MockZip",
};

// "123 Main st, MockCity, MockState, MockZip MockCountry"
const formattedAddress = formatAddress(data);