Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "utilities"

Index

Functions

Const boolFromYesOrNo

  • boolFromYesOrNo(text: string): boolean
  • Get the boolean value of a yes/no text, independent of the language

    Parameters

    • text: string

      The text of the value to be converted

    Returns boolean

    Boolean dependent on the yes/no value given

Const companySlugToId

  • companySlugToId(slug: string): Promise<number>
  • Convert a Tarjouspalvelu company slug to it's numeric ID number

    Parameters

    • slug: string

      The slug of the company to convert

    Returns Promise<number>

    Numeric company ID of the provided slug

Const getSession

  • getSession(slug: string): Promise<Session>
  • Get a Tarjouspalvelu session

    Parameters

    • slug: string

      The slug of the company to get the session UUID with

    Returns Promise<Session>

    Session object including the session UUID and ID

Const getSessionLanguage

  • getSessionLanguage(companyId: number, session: Session): Promise<Language>
  • Get the current locale of a Tarjouspalvelu session

    Parameters

    • companyId: number

      The ID of the company to get the locale with (can be anyone, session is not restricted to it in any way)

    • session: Session

      Session object to get the locale from

    Returns Promise<Language>

    The current locale of the session

Const loginToSession

  • loginToSession(slug: string, username: string, password: string, session?: Session): Promise<Session>
  • Log in a Tarjouspalvelu session

    Parameters

    • slug: string

      The slug of the company to log in with (can be anyone, session is not restricted to it in any way)

    • username: string

      The user name used for logging in

    • password: string

      The password used for logging in

    • Optional session: Session

      Session object to be filled with the token

    Returns Promise<Session>

    The given session object filled with the session token

Const matchLocale

  • Match the current locale from page HTML content

    Parameters

    • html: string

      The HTML source of the page to get the locale from

    Returns Language

    The current locale

Const parseLocalizedDate

  • parseLocalizedDate(date: string, locale: Language): Date
  • Get the Date object of a given localized string representation of date by the locale given, and convert it to UTC from Europe/Helsinki time

    Parameters

    • date: string

      The localized string to be converted

    • locale: Language

      The locale to convert the string from

    Returns Date

    Date object of the given localized date in UTC

Const setSessionLanguage

  • Set the language of a Tarjouspalvelu session

    Parameters

    • companyId: number

      The ID of the company to set the language with (can be anyone, session is not restricted to it in any way)

    • language: Language

      The language to set. Must be either "fi-FI", "sv-SE", "en-GB" or "da-DK".

    • session: Session

      Session object to set the language for

    Returns Promise<Session>

    The given session object that has the language set

Generated using TypeDoc