0.1.6 • Published 9 months ago

@otrs/client-lib v0.1.6

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

otrs-client-lib

Disclaimer

This is a library used by OTRS to facilitate frontend clients to interact with the backend.

Currently this is an active work in progress, with lots more to be added.

Usage

Install the library using npm install @otrs/client-lib in a Javascript or Typescript application.

Next, register the client with the correct configuration

const client = createClient({
  testMode: false // optional (default = false),
})

Listening to events

client.eventBus.on('translation-switch-success', (language) => {
  console.log('Language switched to: ', language)
})

client.eventBus.on('addUserLoaded', (user) => {
  console.log('User signed in: ', user)
})

client.eventBus.on('addUserSignedOut', () => {
  console.log('User signed out')
})

Using authentication

// first, register the module
client.auth.init({
  clientId: '',
  authority: '',
  // Other options are automatically suggested
})

client.auth.signIn().then(
  res => console.log('result =', res)
)

Loading translations

// Using aync/await
const language = 'en'
const hash = '<hash-value>'

// ... Error handling omitted
const res = await client.locale.loadLanguage(language, hash)
const { Locale, Translations } = res.data

Logging

Most function calls are automatically logged, you can pass your own custom logger through the createClient options.

License

MIT License © 2024 OTRS AG

0.1.5-beta.2

10 months ago

0.1.5-beta.1

10 months ago

0.1.4-beta.1

10 months ago

0.1.6

9 months ago

0.1.5

10 months ago

0.1.4

11 months ago

0.1.3

11 months ago

0.1.2

12 months ago

0.1.1

12 months ago

0.1.0

12 months ago

0.0.2

1 year ago

0.0.1

1 year ago