eyeone-node-sdk
v0.6.16
Published
EyeOne customer API SDK
Downloads
3
Readme
EyeOne SDK Library
EyeOne SDK library provides access to the EyeOne API from server-side applications written in JavaScript.
Documentation
Documentation is currently in progress.
Requirements
Node 10 or higher.
Installation
You can install EyeOne SDK with:
npm install eyeone-node-sdk --save
Usage
Import/require
You need valid api key and secret token from your Eye One account in order to properly configure this package. You can obtain your keys at app.eye.one/api-settings.
You need to define an origin as well. Origin is a custom name that will be added to resources created by external API. For example if you will define origin [MY_APP], then you will be able to filter out chat conversations, invitations or appointments by this tag in EyeOne dashboard.
Require eyeone-node-sdk with api key, secret and origin:
const EyeOne = require("eyeone-node-sdk")("ef7ce...", "NzAs4G/...", "MY_APP", config);
EyeOne.Appointments.slots({ appointmentTypeHash })
.then((slots) => {
console.log(slots);
})
.catch((error) => console.error(error));
or with async/await:
const EyeOne = require("eyeone-node-sdk")("ef7ce...", "NzAs4G/...", "MY_APP", config);
async getAppointmentSlots(appointmentTypeHash) {
try {
const slots = await EyeOne.Appointments.slots({ appointmentTypeHash });
return slots;
} catch (error) {
throw new EyeOneError(error);
}
}
Configuration object
You can define config
object and set parameters from the list below:
| Parameter | Default | Description |
| ------------- | ----------------------- | ------------------------------------------------------------------------------------- |
| host
| 'https://app.eye.one'
| EyeOne API host. Mostly used for development if API is hosted locally or at dev site. |
| debug
| false
| Shows logs in console. |
| development
| false
| If set to true then it does not check url validity (i.e. localhost:8000). |
Available resources
Not all resources are available via external api and this package.
Appointments / invitations
Get all appointment types
You can get all appointment types by using your email
.
const appointments = await EyeOne.Appointments.types({
email
});
Get slots for appointment type
You can get available slots for your appointment by using a hash of your appointment type, you can copy it from scheduling settings at app.eye.one:
const slots = await EyeOne.Appointments.slots({ appointmentTypeHash });
Get all invitations/appointments
You can get all of invitations by using your:
email
(or your guest email),
is_eye_one_user
(if you are active EyeOne user specify as true)
type
(can be created
(for invited guests), completed
(for ended invitations) or confirmed
(waiting for a call))
You can use page
and limit
to properly paginate through all invitations.
const appointments = await EyeOne.Appointments.list({
email,
is_eye_one_user,
type,
page,
limit
});
Create appointment/invitation
You can create new invitation by using:
start_date
(which is one of the slots supplied by previous endpoint),
timezone
(guest timezone, used for properly setting timezones),
hash
(appointment type hash),
email
(guest email),
name
(guest name).
const newAppointment = await EyeOne.Appointments.create({
start_date,
timezone,
hash: appointmentTypeHash,
email: user.email,
name: `${user.firstName} ${user.lastName}`
});
Chat conversations
Creating conversation
Chat conversations at EyeOne can be created by EyeOne user or by a guest. In order to properly start a conversation,
you need to provide:
caller_email
(who is starting a chat),
receiver_email
(Who is being written to),
first_name
,
last_name
,
is_eye_one_user
(if you are active EyeOne user specify as true)
const conversation = await EyeOne.Chat.create({
caller_email,
receiver_email,
first_name,
last_namee,
is_eye_one_user
});
Get all conversations
You can list all conversations for a given user, by using:
email
(who is requesting conversations list),
is_eye_one_user
(if you are active EyeOne user specify as true)
show_team
(show your team members conversations as well),
const conversations = await EyeOne.Chat.list({
email,
is_eye_one_user,
show_team
});
Get single conversation with messages
Chat conversations at EyeOne can be created by EyeOne user or by a guest. In order to properly start a conversation,
you need to provide:
conversationHash
(conversation hash, can be obtained by creating new conversation or by a list),
email
(who is requesting this conversation)
You can use page
and limit
to properly paginate through all invitations.
const conversation = await EyeOne.Chat.get({
conversationHash,
email,
page,
limit
});
Status
Get user status
You can get user availability (is logged into Eye One or not?) and name.
const user = await EyeOne.Status.user({
email
});
Widgets
Get widgets list
You can get all user's widgets.
const user = await EyeOne.Widgets.list({
email
});