New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@freshworks/api-sdk

Package Overview
Dependencies
Maintainers
16
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@freshworks/api-sdk

Node.js SDK for Freshworks HTTP APIs

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
20
increased by5.26%
Maintainers
16
Weekly downloads
 
Created
Source

Freshworks API SDK

Node.js SDK for working with Freshworks HTTP APIs. Currently supports Freshteam.

Installation

npm install --save @freshworks/api-sdk

Supported product APIs

ProductStatus
Freshteam

Get started

const { Freshteam } = require("@freshworks/api-sdk");

const ft = new Freshteam(domain, apiKey);

Call a method, e.g., list all employees (who match a search criteria):

const employees = await ft.employees.list({ firstName: "Arthur", lastName: "Dent" });

Freshteam

Models

The Freshteam class includes a static property called models. All models used by the API methods below can be accessed from there.

For example:

// Create a new EmployeeCreate model to pass to employees.create() method
const newEmp = new Freshteam.models.EmployeeCreate("Arthur", "Dent", "arthur@heartofgold.com", [300060409]);

API methods

API methods are the methods you'd interact primarily with. Each method is async and returns a Promise. So, you can either chain the method calls with .then() or call them using async/await syntax.

Applicants

List all applicants
const applicants = await ft.applicants.list(jobPostingId, query);
  • Returns a Promise that resolves to an Array of Freshteam.models.ApplicantDetail objects
  • The second argument provides queries accepted by the REST API. (TODO: Document the query parameters)
Get applicant by ID
const applicant = await ft.applicants.get(id);
  • Returns a Promise that resolves to a Freshteam.models.ApplicantDetail object
Update an applicant
const applicant = await ft.applicants.update(id, applicant);
  • Returns a Promise that resolves to a Freshteam.models.ApplicantDetail object
  • The second argument is of type Freshteam.models.ApplicantUpdate
Archive an applicant
const applicant = await ft.applicants.archive(id, options);
  • Returns a Promise that resolves to a Freshteam.models.ApplicantDetail object
  • The second argument is of type Freshteam.models.ApplicantArchive
Update applicant sub-stage
const applicant = await ft.applicants.updateSubStage(id, options);
  • Returns a Promise that resolves to a Freshteam.models.ApplicantDetail object
  • The second argument is of type Freshteam.models.ApplicantSubStage

Branches

List all branches
const branches = await ft.branches.list();
  • Returns a Promise that resolves to an Array of Freshteam.models.Branch objects
Get branch by ID
const branch = await ft.branches.get(id);
  • Returns a Promise that resolves to a Freshteam.models.Branch object

Business units

List all business units
const buList = await ft.businessUnits.list();
  • Returns a Promise that resolves to an Array of Freshteam.models.BusinessUnit objects
Get business unit by ID
const bu = await ft.businessUnits.get(id);
  • Returns a Promise that resolves to a Freshteam.models.BusinessUnit object

Candidate sources

List all candidate sources
const sources = await ft.candidateSources.list();
  • Returns a Promise that resolves to an Array of Freshteam.models.Source objects
Create a candidate source
const newSource = await ft.candidateSources.create(source);
  • Returns a Promise that resolves to a Freshteam.models.Source object
  • The first argument is of type Freshteam.models.SourceCreate
List candidate source categories
const categories = await ft.candidateSources.listCategories();
  • Returns a Promise that resolves to an Array of Freshteam.models.SourceCategory objects

Departments

List all departments
const depts = await ft.departments.list();
  • Returns a Promise that resolves to an Array of Freshteam.models.Department objects
Get department by ID
const dept = await ft.departments.get(id);
  • Returns a Promise that resolves to a Freshteam.models.Department object

Employees

List all employees
const empList = await ft.employees.list(query);
  • Returns a Promise that resolves to an Array of Freshteam.models.Employee objects
  • The first argument is an object containing query parameters accepted by the REST API, specified using a lowerCamelCase property naming convention. So, first_name becomes firstName. (TODO: Document the query parameters)
Get employee by ID
const emp = await ft.employees.get(id);
  • Returns a Promise that resolves to a Freshteam.models.EmployeeDetail object
Create an employee
const newEmp = await ft.employees.create(employee);
  • Returns a Promise that resolves to a Freshteam.models.Employee object
  • The first argument is of type Freshteam.models.EmployeeCreate
Update an employee
const updatedEmp = await ft.employees.update(id, employee);
  • Returns a Promise that resolves to a Freshteam.models.Employee object
  • The first argument is the employee ID
  • The second argument is an object of type Freshteam.models.Employee
List all employee fields
const fields = await ft.employees.fields();
  • Returns a Promise that resolves to an Array of Freshteam.models.EmployeeField objects
Create an employee field
const newEmpField = await ft.employees.createField(field);
  • Returns a Promise that resolves to a Freshteam.models.EmployeeField object
  • The first argument is of type Freshteam.models.EmployeeFieldCreate

Job postings

List all job postings
const jobList = await ft.jobPostings.list(query);
  • Returns a Promise that resolves to an Array of Freshteam.models.Job objects
  • The first argument is an object containing query parameters accepted by the REST API, specified using a lowerCamelCase property naming convention. So, location_city becomes locationCity. (TODO: Document the query parameters)
Get job posting by ID
const job = await ft.jobPostings.get(id);
  • Returns a Promise that resolves to a Freshteam.models.Job object
Create an applicant
const newApplicant = await ft.jobPostings.createApplicant(jobPostingId, applicant);
  • Returns a Promise that resolves to a Freshteam.models.ApplicantDetail object
  • The first argument is the job posting ID for which to create an applicant
  • The second argument is an object of type Freshteam.models.ApplicantCreate
List job posting fields
const fields = await ft.jobPostings.listFields();
  • Returns a Promise that resolves to an Array of Freshteam.models.Jobfield objects
List applicant fields
const fields = await ft.jobPostings.listApplicantFields();
  • Returns a Promise that resolves to an Array of Freshteam.models.Applicantfield objects
  • The first argument is the job posting ID to fetch applicant fields from

Levels

List all levels
const levels = await ft.levels.list();
  • Returns a Promise that resolves to an Array of Freshteam.models.Level objects
Get level by ID
const level = await ft.levels.get(id);
  • Returns a Promise that resolves to a Freshteam.models.Level object

New hires

Create a new hire
const newHire = await ft.newHires.create(data);
  • Returns a Promise that resolves to a Freshteam.models.NewHire object
  • The first argument is of type Freshteam.models.NewHireCreate
Get new hire by ID
const newHireDetails = await ft.newHires.get(id, options);
  • Returns a Promise that resolves to a Freshteam.models.EmployeeDetail object

  • The first argument is ID of the new hire

  • The second argument is an object containing query parameters accepted by the REST API, specified using a lowerCamelCase property naming convention. So, reporting_to becomes reportingTo. (TODO: Document the query parameters)

    • The property options.include can be added as an Array of string to include additional resources in the response, e.g.:
    await ft.newHires.get(id, { include: ["branch", "team"], ...otherOptions });
    
Update an new hire
const updatedNewHire = await ft.newHires.update(id, data);
  • Returns a Promise that resolves to a Freshteam.models.NewHire object
  • The first argument is the new hire ID
  • The second argument is an object of type Freshteam.models.NewHireCreate

Roles

List all roles
const roles = await ft.roles.list();
  • Returns a Promise that resolves to an Array of Freshteam.models.Role objects
Get role by ID
const role = await ft.roles.get(id);
  • Returns a Promise that resolves to a Freshteam.models.Role object

Sub-departments

List all sub-departments
const subDepts = await ft.subDepartments.list();
  • Returns a Promise that resolves to an Array of Freshteam.models.SubDepartment objects
Get sub-department by ID
const subDept = await ft.subDepartments.get(id);
  • Returns a Promise that resolves to a Freshteam.models.SubDepartment object

Teams

List all teams
const teams = await ft.teams.list();
  • Returns a Promise that resolves to an Array of Freshteam.models.Team objects
Get team by ID
const team = await ft.teams.get(id);
  • Returns a Promise that resolves to a Freshteam.models.Team object

Time offs

List all time-off types
const leaveTypes = await ft.timeOffs.types();
  • Returns a Promise that resolves to an Array of Freshteam.models.LeaveType objects
Get time-off type by ID
const leaveType = await ft.timeOffs.type(id);
  • Returns a Promise that resolves to a Freshteam.models.LeaveType object
List all time-off requests
const leaveReqList = await ft.timeOffs.list(query);
  • Returns a Promise that resolves to an Array of Freshteam.models.LeaveRequest objects
  • The first argument is an object containing query parameters accepted by the REST API, specified using a lowerCamelCase property naming convention. So, leave_type becomes leaveType. (TODO: Document the query parameters)
Create a time-off
const newLeaveReq = await ft.timeOffs.create(leaveRequest);
  • Returns a Promise that resolves to a Freshteam.models.LeaveRequest object
  • The first argument is an object of type Freshteam.models.LeaveRequestCreate
Get time-off by ID
const leave = await ft.timeOffs.get(id);
  • Returns a Promise that resolves to a Freshteam.models.LeaveRequest object
Approve time-off by ID
const res = await ft.timeOffs.approve(id, options);
  • Returns a Promise that resolves to null if request was successful
  • The second argument is an object of type Freshteam.models.LeaveRequestApprove
Reject time-off by ID
const res = await ft.timeOffs.reject(id, options);
  • Returns a Promise that resolves to null if request was successful
  • The second argument is an object of type Freshteam.models.LeaveRequestReject
Cancel time-off by ID
const res = await ft.timeOffs.cancel(id);
  • Returns a Promise that resolves to null if request was successful

User functions

List all user functions
const userFns = await ft.userFunctions.list();
  • Returns a Promise that resolves to an Array of Freshteam.models.UserFunction objects
Get user function by ID
const userFn = await ft.userFunctions.get(id);
  • Returns a Promise that resolves to a Freshteam.models.UserFunction object

License

MIT

FAQs

Package last updated on 01 Nov 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