@securecall/client-api
v0.1.3
Published
SecureCall Client API Javascript library
Downloads
281
Readme
SecureCall Client API Library
This library provides helper functions to make consuming the SecureCall Client API easier from Javascript/Typescript. It provides the following
- sets up the SSE stream for status updates
- emits Events on session, authentication and configuration updates
- has helper functions for each of the APIs
Install
npm install --save @securecall/client-api
Usage
<body>
<script type="module">
import {SecureCallClientAPI} from "https://unpkg.com/@securecall/client-api";
let api = new SecureCallClientAPI('https://client.<region>.securecallapi.cloud')
api.addEventListener('authentication',(evt) => {
if(evt.success) {
console.log('Authentication Success message: ', evt)
} else {
console.log('Authentication Failure message: ', evt)
}
})
api.addEventListener('session',(evt) => {
console.log('Session message: ', evt)
})
api.addEventListener('configuration',(evt) => {
console.log('Configuration message: ', evt)
console.log(' gateways: ', evt.gateways)
})
api.authenticate(<email>, <password>, true)
console.debug('connecting')
</script>
Authentication
There are multiple ways to authenticating to SecureCall using this library. Further details are in the Client API OpenAPI spec found here https://client.au.securecallapi.cloud/v1/
The SecureCallClientAPI
class has members for email, password and useCookie. These can be set manually and then connect() called
or passed via authenticate() which will set them and then call connect().
:factory: SecureCallClientAPI
Methods
:gear: authenticate
| Method | Type |
| ---------- | ---------- |
| authenticate
| (email?: string or undefined, password?: string or undefined, useCookie?: boolean or undefined) => Promise<void>
|
Parameters:
email
: - email address of the userpassword
: - password of the user. This could be a Webex Org ID, SecureCall API Key or a passworduseCookie
: - true if cookies will be used for all API requests or false to send the email/password each time
:gear: login
login uses the email/password to log into the Client API. Typically only used when cookies are used.
| Method | Type |
| ---------- | ---------- |
| login
| () => Promise<void>
|
:gear: logout
Logs out of the SecureCall Client API and disconnects the event stream
| Method | Type |
| ---------- | ---------- |
| logout
| () => Promise<void>
|
:gear: secure
Attempts to secure the call. All updates come through the event stream and will be emitted as Events
| Method | Type |
| ---------- | ---------- |
| secure
| () => Promise<void>
|
:gear: reset
| Method | Type |
| ---------- | ---------- |
| reset
| (v?: string or string[] or undefined) => Promise<void>
|
Parameters:
v
: - if empty, will attempt to reset all the PCI fields, if a string will attempt to reset just that field or can be an array of field name
:gear: submit
| Method | Type |
| ---------- | ---------- |
| submit
| (data: IPaymentValues) => Promise<void>
|
Parameters:
data
: - submits payment data
:gear: telephony
| Method | Type |
| ---------- | ---------- |
| telephony
| (data: ITelephony) => Promise<void>
|
Parameters:
data
: - update telephony state for Client Telephony
:gear: connect
connects the event stream using email/password/useCookie
| Method | Type |
| ---------- | ---------- |
| connect
| () => Promise<void>
|
:gear: disconnect
disconnects the event stream connection
| Method | Type |
| ---------- | ---------- |
| disconnect
| () => void
|