Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@myinterview/global-api-sdk

Package Overview
Dependencies
Maintainers
7
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@myinterview/global-api-sdk

SDK to access myInterview Global API

  • 1.0.460
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
7
Created
Source

myInterview - GlobalAPI SDK

You can see the full typed documentation here.

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

TypeFieldDescription
numberstatusCodeStatus code of the response
numbererrorCodeInternal error code
stringstatusReasonInfo message of the response
stringcallIdInternal call ID
anydataThis field contain the data required based on the request
Date / numbertimeTimestamp

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

TypeFieldDescription
string*errorMessageError message
stringerrorDetailsError message details
number*statusCodeStatus code of the response
number*errorCodeInternal error code
string*statusReasonInfo message of the response
string*callIdInternal call ID
Date / number*timeTimestamp
*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

TypeFieldDescription
string*job_idID of the job
objectcommunicationQuery object
string arrayquery.idsids of candidates you need
stringquery.emailemail of candidate you need
stringquery.statusstatus of the candidate enum (pending, clicked, completed, cancelled)
stringquery.usernameusername of candidate you need
numberquery.skipPagination
numberquery.limitPagination
*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

TypeFieldDescription
string*job_idID of the job to connect the candidate
booleancommunicationFlag to send mails with the creation
Date / string / numberdeadlineDateDeadline date for the candidate/s
stringtimezoneForInviteTimezone for the deadline
Array of candidate object*candidatesArray 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

TypeFieldDescription
string*idID of the candidate
stringstatusStatus of the candidate
stringusernameUsername of the candidate
Date / string / numberdeadlineDeadline date for the candidate/s
stringtimezoneForInviteTimezone 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

TypeFieldDescription
string*idID of the company template
booleanhideQuestionshideQuestions flag
string*nameName of the template
stringintroVideoUrl of the introduction video on the application page
Array of job questions*questionsArray 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

TypeFieldDescription
string*idID of the company template
booleanhideQuestionshideQuestions flag
stringnameName of the template
stringintroVideoUrl of the introduction video on the application page
Array of job questions*questionsArray 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

TypeFieldDescription
string*titleTitle of the job
stringlanguageLanguage of the job
stringoverlayOverlay of the of the application page (Value in Color Hexa #000000)
stringtermsUrlUrl of the Terms of Service
stringprivacyUrlUrl of the Privacy
stringbackgroundImageBackground Image of the of the application page
stringtranscriptLanguageLanguage of the transcript video
Config Object*configConfiguration object definition is above in the interface
Date / string / numberdeadlineDateDeadline date for the job
stringexperienceexperience of the job
stringjobDescriptionJob description
stringlogoLogo
Array of job questions*questionsArray of job questions objects definition is above in the interface
Array of stringskillsskills
stringintroVideointroduction 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

TypeFieldDescription
string*template_idID of the template
stringtitleTitle of the job
stringlanguageLanguage of the job
stringoverlayOverlay of the of the application page (Value in Color Hexa #000000)
stringtermsUrlUrl of the Terms of Service
stringprivacyUrlUrl of the Privacy
stringbackgroundImageBackground Image of the of the application page
stringtranscriptLanguageLanguage of the transcript video
Config ObjectconfigConfiguration object definition is above in the interface
Date / string / numberdeadlineDateDeadline date for the job
stringexperienceexperience of the job
stringjobDescriptionJob description
stringlogoLogo
Array of stringskillsskills
stringintroVideointroduction 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

TypeFieldDescription
string*job_idID of the job
stringtitleTitle of the job
stringlanguageLanguage of the job
stringoverlayOverlay of the of the application page (Value in Color Hexa #000000)
stringtermsUrlUrl of the Terms of Service
stringprivacyUrlUrl of the Privacy
stringbackgroundImageBackground Image of the of the application page
stringtranscriptLanguageLanguage of the transcript video
Config ObjectconfigConfiguration object definition is above in the interface
Date / string / numberdeadlineDateDeadline date for the job
stringexperienceexperience of the job
stringjobDescriptionJob description
stringlogoLogo
Array of job questionsquestionsArray of job questions objects definition is above in the interface
Array of stringskillsskills
stringintroVideointroduction 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

TypeFieldDescription
string*job_idID of the job
Query ObjectqueryQuery 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

TypeFieldDescription
string*urlwebhook url
*required field

createWebhook

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

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

createWebhook Params

createWebhookBody

TypeFieldDescription
string*urlwebhook 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)

FAQs

Package last updated on 16 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc