Socket
Socket
Sign inDemoInstall

tmt-api-sdk-test

Package Overview
Dependencies
0
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    tmt-api-sdk-test

Software Development Kit for the Trust My Travel API.


Version published
Weekly downloads
7
decreased by-87.27%
Maintainers
1
Install size
47.9 kB
Created
Weekly downloads
 

Readme

Source

TMT API SDK for JavaScript

This is the server-side JavaScript SDK for the TMT API. The intention is that this provides a wrapper with a simplified interface for end users to interact with the TMT API. Currently only limited access to the bookings endpoint is supported.

Requirements

  • Node

Installation

Install the package with:

npm install tmt-api-sdk
# or
yarn add tmt-api-sdk

Usage

The SDK needs to be configured with an API token and your site path. The library also exports an Enums helper for the currency, country and language fields.

Example for when using CJS modules:

const TMT = require("tmt-api-sdk");
const Enums = require("tmt-api-sdk").Enums;

const tmtServerSdk = new TMT({
  apiToken: "123|abcDEFg1Hfjk...",
  sitePath: "path-of-site",
});

tmtServerSdk
  .createBooking({
    title: "Booking title",
    firstname: "John",
    surname: "Doe",
    email: "jd@somedomain.com",
    date: "2025-01-31",
    total: 1000,
    currencies: Enums.Currency.USD,
    channels: 1234,
    content: "Holiday for two in London",
    pax: 2,
    reference: "someinternalreference",
    countries: Enums.Country.US,
  })
  .then((booking) => console.log(booking.id))
  .catch((error) => console.error(error));

Or using ES modules and async/await:

import TMT, { Enums } from "tmt-api-sdk";

const tmtServerSdk = new TMT({
  apiToken: "123|abcDEFg1Hfjk...",
  sitePath: "path-of-site",
});

const booking = await tmtServerSdk.createBooking({
  title: "Booking title",
  firstname: "John",
  surname: "Doe",
  email: "jd@somedomain.com",
  date: "2025-01-31",
  total: 1000,
  currencies: Enums.Currency.USD,
  channels: 1234,
  content: "Holiday for two in London",
  pax: 2,
  reference: "someinternalreference",
  countries: Enums.Country.US,
});

console.log(booking.id);

You can also update an existing booking, or retrieve a booking using its id:

tmtServerSdk.updateBooking(id, { reference: "editedreference" });

tmtServerSdk.getBookingById(id);

Module support

We support both CommonJS modules and ECMAScript modules. Please see the node documentation for more context on how these module systems are utilized and how to correctly configure your project to use them. If using TypeScript, note that enabling esModuleInterop could result in your project using an export not intended for your module system. This might work but should ideally not be used as this as is workaround and may result in unexpected behaviour.

Version support

The latest major version of the tmt-api-sdk package introduces new features and addresses bugs. To access these enhancements and bug fixes, including those for security issues, it's advisable to upgrade from older versions. Although older major versions remain accessible, they won't receive further updates.

Development

Run all tests:

$ npm install
$ npm test

Detailed development documentation here.

FAQs

Last updated on 15 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc