npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

koala-partner-client

v1.0.0

Published

Node client for the Koala partner API

Downloads

5

Readme

Koala partner NodeJS client

Client for Koala partner's API (See https://development-partner-api.hikoala.co/api-docs).

Installation.

npm install --save koala-partner-client

Creating the client.

Development.

import { Koala } from 'koala-partner-client';
const client = new Koala({ token: '<your development token>' });

Production.

import { Koala, ServerURL } from 'koala-partner-client';
const client = new Koala({
  token: '<your production token>',
  target: ServerURL.production,
});

Note: You can use KOALA_PARTNER_TOKEN to set token.

Quote

import { Koala } from 'koala-partner-client';
import {
  MinimalAttendant,
  Flight,
  Leg,
  Place,
  QuoteQuery,
} from 'koala-partner-client/lib/types';

const client = new Koala({ token: '<your development token>' });
const quoteQuery = new QuoteQuery({
  // The flights attendants.
  attendants: [
    new MinimalAttendant({
      ageRange: AgeRange.Adult,
    }),
    new MinimalAttendant({
      ageRange: AgeRange.Adult,
    }),
  ],
  // The price of the booking (without ancillaries)
  price: 1030.4,
  // The currency code of the booking (ISO 4217).
  currencyCode: 'EUR',
  // The itinerary.
  flights: [
    new Flight({
      // The different flights of the itinerary.
      legs: [
        new Leg({
          // The IATA code of the departure airport.
          departureAirportIATA: 'CDG',
          // The IATA code of the arrival airport.
          arrivalAirportIATA: 'JFK',
          // The departure date as an ISO string (ISO 8601).
          departureDate: '2021-06-22T18:10:15+02:00',
          // The departure date as an ISO string (ISO 8601).
          arrivalDate: '2021-06-22T21:10:15-04:00',
          // The IATA of the airline.
          airlineIATA: 'AF',
          // The flight number.
          flightNumber: '2131',
        }),
      ],
    }),
    new Flight({
      // The different flights of the itinerary.
      legs: [
        // Same as before.
        new Leg({
          departureAirportIATA: 'JFK',
          arrivalAirportIATA: 'CDG',
          departureDate: '2021-06-27T21:10:15-04:00',
          arrivalDate: '2021-06-28T12:10:15+02:00',
          airlineIATA: 'AF',
          flightNumber: '2222',
        }),
      ],
    }),
  ],
  // The places.
  places: [
    new Place({
      // The display name of the activity / place.
      name: 'Having lunch with your favorite actor',
      // The description of the activity / place.
      description:
        'Have you ever dream to have diner with your favorite actor... We offer you that.',
      // Your internal ID for the place (allows us to reuse places).
      partnerInternalId: '01838481',
      // The language of the name and description (ISO 639-1).
      lang: 'en',
      // The country code of the country (ISO 3166-1).
      countryCode: 'FR',
      // The start date of the activity (ISO 8601).
      start: '2021-06-28T12:10:15+02:00',
      // The end date of the activity (ISO 8601).
      end: '2021-06-28T12:10:15+02:00',
    }),
  ],
});

const quotes = await client.quotes(quoteQuery);
// Expected:
// [
//   {
//     name: 'policy 1',
//     price: { EUR: 12.5 },
//     // ...
//   },
//   {
//     name: 'policy 2',
//     price: { EUR: 14.5 },
//     // ...
//   },
//   {
//     name: 'policy 3',
//     price: { EUR: 16.5 },
//     // ...
//   },
// ]

Subscription.

import { Koala } from 'koala-partner-client';
import {
  Attendant,
  Flight,
  Leg,
  SubscribeQuery,
  Client,
} from 'koala-partner-client/lib/types';
const client = new Koala({ token: '<your token>' });

const quoteQuery: QuoteQuery = {}; // Your quote query.
const quotes = await client.quotes(quoteQuery);

// Select the right quote.
const quote: Quote = quotes[1];

// Create a subscription.
const subscribe = new SubscribeQuery({
  // The info about the client (the person booking the product).
  client: new Client({
    firstName: 'Alain',
    lastName: 'Prost',
    email: '[email protected]',
  }),
  // The booking (a detailed version of the quote)
  booking: new Booking({
    // The attendants (a detailed version).
    attendants: [
      new Attendant({
        firstName: 'Christine',
        lastName: 'Bravo',
        ageRange: AgeRange.Adult,
      }),
      new Attendant({
        firstName: 'Alain',
        lastName: 'Prost',
        ageRange: AgeRange.Adult,
      }),
    ],
    // The booking number (must be unique from your system).
    number: 'K131E49',
    // The price of the booking (without ancillaries)
    price: quoteQuery.price,
    // The currency code of the booking.
    currencyCode: quoteQuery.currencyCode,
    // The flights from the quote query.
    flights: quoteQuery.flights,
    // The places from teh quote query.
    places: quoteQuery.places,
  }),
  // The unaltered quote.
  quote,
});

const subscription = await client.subscribe(subscribe);