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
npm install --save @securecall/client-api
<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>
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().
Method | Type |
---|---|
authenticate |
(email?: string or undefined, password?: string or undefined, useCookie?: boolean or undefined) => Promise<void> |
Parameters:
-
email
: - email address of the user -
password
: - password of the user. This could be a Webex Org ID, SecureCall API Key or a password -
useCookie
: - true if cookies will be used for all API requests or false to send the email/password each time
login uses the email/password to log into the Client API. Typically only used when cookies are used.
Method | Type |
---|---|
login |
() => Promise<void> |
Logs out of the SecureCall Client API and disconnects the event stream
Method | Type |
---|---|
logout |
() => Promise<void> |
Attempts to secure the call. All updates come through the event stream and will be emitted as Events
Method | Type |
---|---|
secure |
() => Promise<void> |
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
Method | Type |
---|---|
submit |
(data: IPaymentValues) => Promise<void> |
Parameters:
-
data
: - submits payment data
Method | Type |
---|---|
telephony |
(data: ITelephony) => Promise<void> |
Parameters:
-
data
: - update telephony state for Client Telephony
connects the event stream using email/password/useCookie
Method | Type |
---|---|
connect |
() => Promise<void> |
disconnects the event stream connection
Method | Type |
---|---|
disconnect |
() => void |