Options
All
  • Public
  • Public/Protected
  • All
Menu

@myinterview/global-api-sdk

myInterview - myInterview API SDK

Prerequisites

This project requires NodeJS (version 14 or later) and NPM. Node and NPM are really easy to install. To make sure you have them available on your machine, try running the following command.

$ npm -v && node -v
6.14.15
v14.18.1

Install

npm i @myinterview/global-api-sdk

:warning: Do not use this Node.js library in a front-end application. Doing so can expose your myInterview credentials to end-users as part of the bundled HTML/JavaScript sent to their browser.

Usage

Basic configuration

import { GlobalApi } from '@myinterview/global-api-sdk';

GlobalApi.setConfig({
secret: 'yoursecret',
companyId: 'yourcompanyid',
accessKey: 'youraccesskey',
});

To use the SDK you have to set the configuration with the keys provided by myinterview prior use of the classes.

Responses (Regular/Error)

Standard Response

interface IApiResponseObj<T = any> {
statusCode: number;
errorCode: number;
statusReason: string;
callId: string;
data?: T;
time: Date | number;
}

IApiResponseObj

Type Field Description
number statusCode Status code of the response
number errorCode Internal error code
string statusReason Info message of the response
string callId Internal call ID
any data This field contain the data required based on the request
Date / number time Timestamp

This is the response object you will receive from the SDK the content of data will change based on your request.

Standard Error Response

interface IApiErrorObj {
errorMessage: string | ValidationError[];
errorDetails?: string;
statusCode: number;
errorCode: number;
statusReason: string;
callId?: string;
time: Date | number;
}

IApiResponseObj

Type Field Description
string *errorMessage Error message
string errorDetails Error message details
number *statusCode Status code of the response
number *errorCode Internal error code
string *statusReason Info message of the response
string *callId Internal call ID
Date / number *time Timestamp
*required field

This is the error response object you will receive from the SDK.

GACandidates

import { GACandidates } from '@myinterview/global-api-sdk';

getCandidate

const res: IApiResponseObj<ICandidate> = await GACandidates.getCandidate('candidate_id');

const candidate = res.data;

getJobCandidates

const body = {
job_id: "job_id",
query: {
ids: ['candidate_id1', 'candidate_id2'],
email: 'email@email.com',
status: 'pending',
username: 'username',
skip: 0,
limit: 20,
}
};

const res: IApiResponseObj<ICandidate[]> = await GACandidates.getJobCandidates(body);

const candidates = res.data;

getJobCandidates Params

getJobCandidatesBody

Type Field Description
string *job_id ID of the job
object communication Query object
string array query.ids ids of candidates you need
string query.email email of candidate you need
string query.status status of the candidate enum (pending, clicked, completed, cancelled)
string query.username username of candidate you need
number query.skip Pagination
number query.limit Pagination
*required field

createBulkCandidates

const body = {
job_id: "job_id",
communication: false,
deadlineDate: "2021-10-20T08:42:59.537+00:00",
timezoneForInvite: "Australia/Sydney",
candidates: [{
username: "username",
email: "email@email.com",
jobTitle: "Job title",
}]
};

await GACandidates.createBulkCandidates(body);

createBulkCandidates Params

createBulkCandidatesBody

Type Field Description
string *job_id ID of the job to connect the candidate
boolean communication Flag to send mails with the creation
Date / string / number deadlineDate Deadline date for the candidate/s
string timezoneForInvite Timezone for the deadline
Array of candidate object *candidates Array of candidate objects definition is above in the interface
*required field

This call will create one or more candidates and connect them to your Job.

updateCandidate

const body = {
id: "candidate_id", // You have to provide the id of the candidate
username: "username",
email: "email@email.com",
jobTitle: "Job title",
};

await GACandidates.updateCandidate(body);

updateCandidate Params

updateCandidateBody

Type Field Description
string *id ID of the candidate
string status Status of the candidate
string username Username of the candidate
Date / string / number deadline Deadline date for the candidate/s
string timezoneForInvite Timezone for the deadline
*required field

GACompanies

import { GACompanies } from '@myinterview/global-api-sdk';

getCompanyInfo

const res: IApiResponseObj<ICompany> = await GACompanies.getCompanyInfo();

const companyInfo = res.data;

getCompanyTemplates

const res: IApiResponseObj<ITemplate[]> = await GACompanies.getCompanyTemplates();

const templates = res.data;

createCompanyTemplateBulk

const body = [{
id: "template_id",
name: "template_name",
questions: [{
numOfRetakes: 1,
partDuration: 30,
question: "How are you today?"
}],
introVideo: 'youtube.com/watch'
},
{
id: "template_id",
name: "template_name",
questions: [{
numOfRetakes: 1,
partDuration: 30,
question: "How are you today?"
}],
introVideo: 'youtube.com/watch'
}]

await GACompanies.createCompanyTemplateBulk(body);

createCompanyTemplateBulk Params

createCompanyTemplateBulkBody

Type Field Description
string *id ID of the company template
boolean hideQuestions hideQuestions flag
string *name Name of the template
string introVideo Url of the introduction video on the application page
Array of job questions *questions Array of job questions objects definition is above in the interface
*required field

updateCompanyTemplate

const body = {
id: "template_id",
name: "template_name",
questions: [{
numOfRetakes: 1,
partDuration: 30,
question: "How are you today?"
}],
introVideo: 'youtube.com/watch'
};

await GACompanies.updateCompanyTemplate(body);

updateCompanyTemplate Params

updateCompanyTemplateBody

Type Field Description
string *id ID of the company template
boolean hideQuestions hideQuestions flag
string name Name of the template
string introVideo Url of the introduction video on the application page
Array of job questions *questions Array of job questions objects definition is above in the interface
*required field

GAJobs

import { GAJobs } from '@myinterview/global-api-sdk';

getCompanyInfo

const res: IApiResponseObj<IJob[]> = await GAJobs.getJobs();

const jobs = res.data;

getJobsWithIds

const ids: string[];

const res: IApiResponseObj<IJob[]> = await GAJobs.getJobsWithIds(ids);

const jobs = res.data;

getJob

const id: string;

const res: IApiResponseObj<IJob> = await GAJobs.getJob(id);

const job = res.data;

createJob

const body = {
title: "job_title",
language: 'en',
overlay: '#000000',
config: {
hideQuestions: true,
practice: true
},
jobDescription: 'jobDescription',
logo: "logo.url.com",
questions: [{
numOfRetakes: 1,
partDuration: 30,
question: "How are you today?"
}],
}

await GAJobs.createJob(body);

createJob Params

createJobBody

Type Field Description
string *title Title of the job
string language Language of the job
string overlay Overlay of the of the application page (Value in Color Hexa #000000)
string termsUrl Url of the Terms of Service
string privacyUrl Url of the Privacy
string backgroundImage Background Image of the of the application page
string transcriptLanguage Language of the transcript video
Config Object *config Configuration object definition is above in the interface
Date / string / number deadlineDate Deadline date for the job
string experience experience of the job
string jobDescription Job description
string logo Logo
Array of job questions *questions Array of job questions objects definition is above in the interface
Array of string skills skills
string introVideo introduction video for application page
*required field

createJobCandidatesWithTemplate

const body = {
template_id: 'template_id',
title: "job_title",
language: 'en',
overlay: '#000000',
config: {
practice: true
},
jobDescription: 'jobDescription',
logo: "logo.url.com",
candidates: {
communication: true,
deadlineDate: "2021-10-20T08:42:59.537+00:00",
timezoneForInvite: "Australia/Sydney",
candidates: [{
username: "username",
email: "email@email.com",
}]
}
}

await GAJobs.createJobCandidatesWithTemplate(body);

createJobCandidatesWithTemplate Params

createJobCandidatesWithTemplateBody

Type Field Description
string *template_id ID of the template
string title Title of the job
string language Language of the job
string overlay Overlay of the of the application page (Value in Color Hexa #000000)
string termsUrl Url of the Terms of Service
string privacyUrl Url of the Privacy
string backgroundImage Background Image of the of the application page
string transcriptLanguage Language of the transcript video
Config Object config Configuration object definition is above in the interface
Date / string / number deadlineDate Deadline date for the job
string experience experience of the job
string jobDescription Job description
string logo Logo
Array of string skills skills
string introVideo introduction video for application page
*required field

createJobWithCandidates

const body = {
title: "job_title",
language: 'en',
overlay: '#000000',
config: {
practice: true
},
jobDescription: 'jobDescription',
logo: "logo.url.com",
candidates: {
communication: true,
deadlineDate: "2021-10-20T08:42:59.537+00:00",
timezoneForInvite: "Australia/Sydney",
candidates: [{
username: "username",
email: "email@email.com",
}]
}
}

await GAJobs.createJobWithCandidates(body);

createJobWithCandidates Params

createJobWithCandidatesBody

Type Field Description
string *title Title of the job
Array of job questions *questions Array of job questions objects definition is above in the interface
string language Language of the job
string overlay Overlay of the of the application page (Value in Color Hexa #000000)
string termsUrl Url of the Terms of Service
string privacyUrl Url of the Privacy
string backgroundImage Background Image of the of the application page
string transcriptLanguage Language of the transcript video
Config Object config Configuration object definition is above in the interface
Date / string / number deadlineDate Deadline date for the job
string experience experience of the job
string jobDescription Job description
string logo Logo
Array of string skills skills
string introVideo introduction video for application page
*required field

updateJob

const body = {
job_id: 'job_id',
title: "job_title",
language: 'en',
overlay: '#000000',
config: {
hideQuestions: true,
practice: true
},
jobDescription: 'jobDescription',
logo: "logo.url.com",
questions: [{
numOfRetakes: 1,
partDuration: 30,
question: "How are you today?"
}],
}

await GAJobs.updateJob(body);

updateJob Params

updateJobBody

Type Field Description
string *job_id ID of the job
string title Title of the job
string language Language of the job
string overlay Overlay of the of the application page (Value in Color Hexa #000000)
string termsUrl Url of the Terms of Service
string privacyUrl Url of the Privacy
string backgroundImage Background Image of the of the application page
string transcriptLanguage Language of the transcript video
Config Object config Configuration object definition is above in the interface
Date / string / number deadlineDate Deadline date for the job
string experience experience of the job
string jobDescription Job description
string logo Logo
Array of job questions questions Array of job questions objects definition is above in the interface
Array of string skills skills
string introVideo introduction video for application page
*required field

GAVideos

import { GAVideos } from '@myinterview/global-api-sdk';

getVideo

const id: string;

const res: IApiResponseObj<IVideo> = await GAVideos.getVideo(id);

const video = res.data;

getJobVideos

const body = {
job_id: 'job_id',
query: { // This object is not mandatory
apiKey: 'apiKey',
clicked: true,
uploaded: true,
completed: true,
email: "email@example.com",
username: "exemple",
candidate_id: "candidate_id",
language: "en",
skip: 20,
limit: 20
}
}

const res: IApiResponseObj<IVideo[]> = await GAVideos.getJobVideos(body);

const videos = res.data;

getJobVideos Params

getJobVideosBody

Type Field Description
string *job_id ID of the job
Query Object query Query object definition is above in the interface
*required field

getVideoPersonality

const id: string;

const res: IApiResponseObj<IPersonality> = await GAVideos.getVideoPersonality(id);

const personality = res.data;

GAWebhooks

import { GAWebhooks } from '@myinterview/global-api-sdk';

testWebhook

const body = {
url: 'https://webhook.test',
}

const res: IApiResponseObj<{ message: string }> = await GAWebhooks.testWebhook(body);

testWebhook Params

testWebhookBody

Type Field Description
string *url webhook url
*required field

createWebhook

const body = {
url: 'https://webhook.io',
}

const res: IApiResponseObj<{ message: string }> = await GAWebhooks.createWebhook(body);

createWebhook Params

createWebhookBody

Type Field Description
string *url webhook url
*required field

Error Handling

You can catch the error the same way you catch error normally.

Async/Await

try {
const res = await GAVideos.getVideoPersonality("");
} catch (error) {
// The error will be of type IApiErrorObj the definition is above.
console.log(error)
}

Callback

GAVideos.getVideoPersonality("").then((res) => {
// Type IApiResponseObj
}).catch((error) => {
// The error will be of type IApiErrorObj the definition is above.
console.log(error)
})

Authentication Helper for API

populateHeaders

This call will populate the headers you need to connect to the global API service it will return an object that you can use in you request. In order to authenticate to the API you need to populate the headers (x-myinterview-timestamp, x-myinterview-key, x-myinterview-signed) the populateHeaders method will return an object that you need to include in the headers config.

import { GlobalApi } from '@myinterview/global-api-sdk';

GlobalApi.populateHeaders({
secret: 'yoursecret',
companyId: 'yourcompanyid',
accessKey: 'youraccesskey',
});

It will return:

{
'x-myinterview-timestamp': 'headTimestamp',
'x-myinterview-key': 'headKey',
'x-myinterview-signed': 'headSigned'
}

Authors

  • Dvd1109 (David Sellam)

Generated using TypeDoc