Skip to Content
APIPlanning Center People TSSrcFunctionsFunction: calculateTrust()

planning-center-monorepo v1.0.0


planning-center-monorepo / planning-center-people-ts/src / calculateTrust

Function: calculateTrust()

calculateTrust(createdAt, trustWindow): TrustResult

Defined in: packages/planning-center-people-ts/src/helpers.ts:392 

Calculate whether a person ID can be trusted based on when it was created/verified

This is useful for caching person IDs to avoid unnecessary API calls. PCO takes 15-30 minutes to index new contacts, so recently created person IDs should be trusted without re-verification to avoid race conditions.

Parameters

createdAt

string

ISO timestamp when the person ID was created/saved

trustWindow

number = DEFAULT_TRUST_WINDOW

Trust window in milliseconds (default: 1 hour)

Returns

TrustResult

Object with trust decision, age, and reason

@gmail.com

const trust = calculateTrust(pcoInfo.personIdCreatedAt); if (trust.shouldTrust) { // Use cached personId without verification return cachedPersonId; } else { // Verify personId still exists in PCO await client.people.getById(cachedPersonId); }