Skip to content

LarisLab/kustomer-client

Repository files navigation

Kustomer Client

semantic-release code style: prettier

Kustomer typescript API client

Missing something? Create feature request!

Read documentation 📘 or API reference 📕

Installation

npm version npm

Install with NPM/yarn:

# NPM
npm install kustomer-client
# Yarn
yarn add kustomer-client

Usage

import { createKustomerClient, KustomerApi } from 'kustomer-client'

const client = createKustomerClient({
    subdomain: 'subdomain', // https://{subdomain}.api.kustomerapp.com
    auth: 'api key',
})

const conversations = await KustomerApi.getConversations({
    client,
    query: {
        page: 1,
        pageSize: 5,
    },
}).then((v) => v.data.data)

for (const conversation of conversations) {
    const messages = await KustomerApi.getMessagesByConversation({
        client,
        path: {
            id: conversation.id,
        },
    }).then((v) => v.data.data)

    for (const message of messages) {
        console.log(message)
    }

    await KustomerApi.updateConversation({
        client,
        path: {
            id: conversation.id,
        },
        body: {
            name: 'My new name',
        },
    })
}

Contributors