Skip to main content

API Client

Browser client for Tee Time APIs.

Package: libs/services/client/teetime-api-client

Usage

import { listClubs, getTeeSheet, listMyBuddies } from '@digiwedge/teetime-api-client';

const clubs = await listClubs({ name: 'Royal' });
const sheet = await getTeeSheet(courseId, new Date());
const buddies = await listMyBuddies(); // uses /players/me/buddies and returns contact details

Configure base URL via environment or rely on same‑origin in production. Helpers prefixed with listMy*/addMy*/removeMy* resolve the current player from the session/JWT automatically.

Frontend integration tips

  • Buddy data & helpers: /players/me/buddies returns contact details under buddy.firstName, buddy.lastName, buddy.fullName, buddy.email, buddy.phoneNumber (aliases name/surname/phone remain for back-compat). Use the buddy object directly; avoid extra player lookups. Prefer the listMy*/addMy*/removeMy* helpers so the client resolves the player automatically.
  • Eligibility context for pricing: visitor pricing/search accepts optional { tenantId, membershipNumber, providerCode } to apply reciprocity/association discounts. Pass these query params when available (they degrade to standard visitor pricing on failure):
    const params = new URLSearchParams({
    tenantId: 'tenant-uuid',
    membershipNumber: '123456',
    providerCode: 'SAGA_NETWORK', // or GOLFRSA / DOTGOLF / NEDBANK_GREENTIME / DISCOVERY_VITALITY
    });
    const slots = await fetch(`/api/courses/${courseId}/tee-times/visitor?${params.toString()}`, {
    credentials: 'include',
    }).then((r) => r.json());
  • Same-origin in prod: Frontends should prefer relative API calls; only set base URL in dev/preview. Ensure credentials/cookies are allowed when using session-backed flows.