npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@coachall/teamleader-node-client

v0.0.111

Published

An asynchronous wrapper for the Teamleader API written in Typescript with Zod schema validation

Downloads

87

Readme

Teamleader Node Client

A community developed API wrapper around the V2 Teamleader Focus API. This package is completely written in Typescript and uses Zod for schema validation and Axios for requests.

WARNING: This package is currently marked as 'experimental' and 'in development' and should be used at your own risk.

Endpoints wille be added whenever I need them in production / have some spare time. You can help speed up development by submitting a pull request

Available endpoints

  • General ✅
    • ✅ Departments (list, info)
    • ✅ Users (me, list, info)
    • ✅ Teams (list)
    • ✅ Custom Fields (list, info)
    • ✅ Work Types (list)
  • CRM 👷‍♂️
    • ✅ Contacts (list, info, add, update, delete, tag, untag, linkToCompany, unlinkFromCompany, updateCompanyLink)
    • ✅ Companies (list, info, add, update, delete, tag, untag)
    • 👷‍♂️ Business Types
    • 👷‍♂️ Tags
    • 👷‍♂️ Addresses
  • Deals 👷‍♂️
    • 👷‍♂️ Deals (list, info, create, update, move, win, lose, delete, ~~lostReasonsList~~ )
    • 👷‍♂️ Quotations (~~list~~, ~~info~~, ~~download~~, create, send, ~~update~~, ~~accept~~, ~~delete~~ )
  • Calendar 👷‍♂️
    • 👷‍♂️ Events (~~list~~, info, ~~create~~, ~~update~~, ~~cancel~~ )
    • ~~Activity Types~~
  • Invoicing 👷‍♂️
    • ✅ Tax Rates (list)
  • Products ✅ (list, info, add)
  • ~~Projects~~
  • ~~Tasks~~
  • ~~Time Tracking~~
  • Files 👷‍♂️ (~~list~~, ~~info~~, ~~download~~, upload, ~~delete~~ )
  • Other 👷‍♂️
    • 👷‍♂️ Migrate (id, ~~taxRate~~, ~~ActivityType~~ )
    • ✅ Webhooks (register, list, unregister)

Installation

npm i @coachall/teamleader-node-client
yarn add @coachall/teamleader-node-client

Initialize the client:

import TLclient from "@coachall/teamleader-node-client";

/*
The initial configuration of the client.
You will need to manage refresh and access tokens yourself with the callback function.
It is advised to use a lightweight database to store these (eg: Lowdb, SQLite)
*/

const config = {
  client_id: string,
  client_secret: string,
  refresh_token: string,
  access_token: string,
  redirect_uri: string,
  //callback function fires when a new token pair is requested. Use the results to overwrite the refresh_token and access_token above
  callback: (e) => {
    e.access_token: string
    e.refresh_token: string,
    e.token_type: string,
    e.expires_in: number,
  },
};

const client = new TLclient(config);

Examples

// Get all departments
const departments = await client.departmentsList();

console.log(departments);

/* ---- RESULT----
{
data: [
        {
            id: 'c506e35a-2177-0626-865f-c1fcdfgc2bd21',
            name: 'Coachall BV',
            currency: 'EUR',
            vat_number: 'BE 0743.533.110',
            emails: [Array],
            status: 'active'
        }
    ]
}
*/

// Get a single department

const ourDepartment = await client.departmentsInfo(
	"c506e35a-2177-0626-865f-c1fcdfgc2bd21"
);

console.log(ourDepartment);

/* ---- RESULT----
{
data: {
        id: 'c506e35a-2177-0626-865f-c1fcdfgc2bd21',
        name: 'Coachall BV',
        currency: 'EUR',
        vat_number: 'BE 0743.533.110',
        emails: [Array],
        status: 'active'
      }
}
*/

// Filter the departments

const filteredDepartments = await client.departmentsList({
	filter: {
		status: "archived",
	},
});

console.log(filteredDepartments);

/* ---- RESULT----
{
data: []
}
*/

Endpoints

Departments

Departments are used to split quotations and invoices for different legal entities or within one organisation. https://developer.teamleader.eu/#/reference/general/departments

List

Get a list of departments. https://developer.teamleader.eu/#/reference/general/departments/departments.list

const departments: Promise<DepartmentsListResponse> = await client.departmentsList(params?: DepartmentsListParams);

Info

Get details for a single department. https://developer.teamleader.eu/#/reference/general/departments/departments.info

const departmentsInfo: Promise<DepartmentsInfoResponse> = await client.departmentsList(id: Uuid);

Users

Users are co-workers in a Teamleader account. https://developer.teamleader.eu/#/reference/general/users

Me

Get the current authenticated user. https://developer.teamleader.eu/#/reference/general/users/users.me

const me: Promise<UsersMe> = await client.usersMe();

List

Get a list of all users. https://developer.teamleader.eu/#/reference/general/users/users.list

const userList: Promise<UsersList> = await client.usersList(params?: UsersListParams);

Info

Get details for a single user. https://developer.teamleader.eu/#/reference/general/users/users.info

const userInfo: Promise<UsersInfo> = await client.usersInfo(id: Uuid);

Teams

https://developer.teamleader.eu/#/reference/general/teams

List

Get a list of all teams. https://developer.teamleader.eu/#/reference/general/users/teams.list

const teams: Promise<TeamsList> = await client.teamsList();

Custom Fields

Custom fields are used to add additional data/properties to entities within Teamleader. https://developer.teamleader.eu/#/reference/general/custom-fields

List

Get a list of all the definitions of custom fields. https://developer.teamleader.eu/#/reference/general/custom-fields/customfielddefinitions.list

const customfields: Promise<CustomFieldDefinitionsList> = await client.customFieldDefinitionsList(params?: CustomFieldDefinitionsListParams);

Info

Get info about a specific custom field definition. https://developer.teamleader.eu/#/reference/general/custom-fields/customfielddefinitions.info

const customfieldInfo: Promise<CustomFieldDefinitionsInfo> = await client.customFieldDefinitionsInfo(id: Uuid);

Work Types

Work types define the type of work for events or time tracking. Hourly rates can be added to work types, so that the work can be billed to a customer. https://developer.teamleader.eu/#/reference/general/work-types

List

Get a list of all the definitions of custom fields. https://developer.teamleader.eu/#/reference/general/work-types/worktypes.list

const worktypes: Promise<WorkTypesList> = await client.workTypesList(params?: WorkTypesListParams);

Contacts

Contacts are physical entities who are added to your CRM database. Contacts might be linked to one or more companies. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.list

List

Get a list of contacts. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.list

const contacts: Promise<ContactsListResponse> = await client.contactsList(params?: ContactsListParams);

Info

Get details for a single contact. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.info

const contact: Promise<ContactsInfoResponse> = await client.contactsInfo(id: Uuid);

Add

Add a new contact. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.add

const addContact: Promise<contactsAddResponse> = await client.contactsAdd(body: ContactsAdd);

Update

Update a contact. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.update

const updateContact: Promise<null> = await client.contactsUpdate(body: ContactsUpdate);

Delete

Delete a contact. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.delete

const deleteContact: Promise<null> = await client.contactsDelete(body: ContactsDelete);

Tag

Add a new or existing tag to a contact. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.tag

const tagContact: Promise<null> = await client.contactsTag(body: ContactsTag);

Untag

Remove a tag from a contact. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.untag

const untagContact: Promise<null> = await client.contactsUntag(body: ContactsUntag);

Link to company

Link a contact to a company. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.linktocompany

const linkContact: Promise<null> = await client.contactsLinkToCompany(body: ContactsLinkToCompany);

Unlink from company

Unlink a contact from a company. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.unlinkfromcompany

const unlinkContact: Promise<null> = await client.contactsUnlinkFromCompany(body: ContactsUnlinkFromCompany);

Update company link

Update contact to company link. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.updatecompanylink

const updateCompanyLink: Promise<null> = await client.contactsUpdateCompanyLink(body: ContactsUpdateCompanyLink);