Reapit Foundations
View on GitHub
  • Home
  • APIs
    • REST API
    • Webhooks
    • GraphQL
    • Reapit Connect
    • Desktop API
    • Notifications
  • Developer Portal
  • Listing your App
    • App Permissions
    • App Listing Review
  • App Development
    • Developer Guidelines
    • Usage Guidelines
    • Elements
    • Vite Template
    • Create React App Template
    • Connect Session
    • Foundations TS Defintions
    • Login With Reapit
    • Contributing
    • Website Development
    • IaaS (Coming Soon)
      • 🖥️Developer Portal (Beta)
      • 💻CLI (Beta)
  • What’s New
  • Platform Glossary
    • Permissions
  • Developer Terms and Conditions
  • Troubleshooting
    • Accessing Customer Data
    • Authentication Issues
    • Reapit Connect
    • REST API
  • Development Requests
  • FAQ's
    • Reapit Connect Emails
  • Help
  • Reapit Connect Updates
Powered by GitBook
On this page
  • Usage:
  • Webhook types
  1. App Development

Foundations TS Defintions

TypeScript definition files for the Reapit Foundations API

PreviousConnect SessionNextLogin With Reapit

Last updated 1 year ago

Develop in TypeScript against the Reapit Foundations Platform with confidence

If you are using TypeScript (and we recommend you do!), for your front end or NodeJS project, we provide full type definitions for the API documented in the .

We generate these types from the Swagger contracts direct with a daily CRON job, so you can be sure that when the API changes, your types will be updated too. This allows for a much closer alignment between front and back end development, with compile time feedback on definition changes. Ultimately this should lead to more robust applications.

The definitions are updated automatically when the API changes. As such, it is recommended strongly that you match by date stamp the correct version of the definitions to the API version you are using in your headers.

Usage:

For the latest version;

yarn add @reapit/foundations-ts-definitions

Then import the required type into your code with ES6 Modules or CommonJS. The naming maps directly to the model names in the API Explorer in the developer portal.

import { AppModel } from '@reapit/foundations-ts-definitions'

// Or

const { AppModel } = require('@reapit/foundations-ts-definitions')

Webhook types

Webhook event payloads are generic, however the types can be infered by the topicId. Here are some examples of how to use the webhook types

import {
  ReapitWebhookPayloadType,
  ReapitWebhookTopicEnum,
  ReapitWebhookApplicantCreatedEvent,
} from '@reapit/foundations-ts-definitions'

export const webhookEventHandler = (event: ReapitWebookPayloadType) => {
  switch (event.topicId) {
    case ReapitWebhookTopicEnum.APPLICANTS_CREATED:
      handleApplicantCreated(event) // event is of infered type ReapitWebhookApplicantCreatedEvent
      break
    default:
      console.log(event.new) // event.new is of infered type any
  }
}

const handleApplicantCreated = (event: ReapitWebhookApplicantCreatedEvent) => {
  console.log(event.new) // new is of inferred type ApplicantModel
}
API explorer