0.9.1 • Published 8 months ago

@trieb.work/zoho-ts v0.9.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

npm version

Zoho TS

A typescript / node.js library used to work with Zoho Finance Suite APIs: Zoho Inventory, Zoho Books and Zoho Invoice. These APIs are for most entities the same, apart from some specific functions.
There are several functions already created, but in the end they are all custom. Some of them are documented and some are reverse-engineered and implemented in this library to have an optimised, easy way working with the Zoho APIs.

All entities are fully typed.

Installation

yarn add @trieb.work/zoho-ts
npm i @trieb.work/zoho-ts
pnpm i @trieb.work/zoho-ts

Usage on server

Make sure to select the correct datacenter for your API client credentials: e.g. ".com" or ".eu". You can also select, which API endpoint to use - Zoho Books, Zoho Invoice or Zoho Inventory. Most API endpoints are the same and work the same. You just need to select the product, that you have licensed.

import { Zoho, ZohoApiClient } from "@trieb.work/zoho-ts";

const zoho = new Zoho(
    await ZohoApiClient.fromOAuth({
      orgId: "243546",
      dc: ".com",
      apiFlavour: "invoice",
      scope: "ZohoInvoice.fullaccess.all"
      client: {
        id: "",
        secret: "",
      },
    }),
  );

You can decide, which API to use - Zoho Inventory, Zoho Books, Zoho Invoice. Currently, you can only decide per instance. It is planned to make it possible to decide which API to use on function level.

Authentication with OAuth

The library on the server should be used with a client ID and a client secret, that you can register at the developer console: https://api-console.zoho.eu/ (Self Client)

Usage in Browser Context (use cookies for auth)

The library can run in the browser as well (for example with browser extensions)

import { Zoho, ZohoApiClient } from "@trieb.work/zoho-ts";

const zoho = new Zoho(
    await ZohoApiClient.fromCookies({ 
        orgId: "",
        cookie: "",
        zsrfToken: ""
    }),
  );

Implemented entities

EntityFunctions
bankaccountlist
contactcreate, get, update, delete, list, addAddress,updateAddress, listContactPersons
contactpersoncreate, get, delete, list
invoicecreate, get, delete, list, createFromSalesOrder, sent
itemcreate, get, delete, list, createGroup, deleteGroup, getComposite
organizationslist
packagecreate, get, delete, list,bulkCreateQuickShipment, createShipment, markDelivered, deleteShipmentOrder
paymentcreate, get, delete, list
salesordercreate, get, delete, list, update, confirm, markVoid, setCustomFieldValue, search
taxlist
warehouseget, list

Usage example:

import { Zoho, ZohoApiClient } from "@trieb.work/zoho-ts";

const zoho = new Zoho(
    await ZohoApiClient.fromOAuth({
      orgId: "243546",
      dc: ".com",
      client: {
        id: "",
        secret: "",
      },
    }),
  );

/// Get all payments that were modified in the last hour
const payments = await zoho.payment.list({
    lastModifiedTime: subHours(new Date(), 1),
})  

Error Handling

The library includes a custom error type, that you can use to handle the from Zoho returned error type:

try {
  
  await zoho.invoice.createFromSalesOrder(id)

} catch(err) {
  if ((err as ZohoApiError).code === 36026) {
    console.warn(
      "Aborting sync of this invoice since it was already created. Original Error: " +
        err.message,
    );
  } else {
    console.error(err.message);
  }
}
0.9.1

8 months ago

0.8.2

11 months ago

0.9.0

11 months ago

0.7.2

1 year ago

0.7.1

1 year ago

0.7.3

1 year ago

0.8.1

12 months ago

0.8.0

12 months ago

0.6.6

1 year ago

0.6.3

1 year ago

0.6.4

1 year ago

0.6.2

1 year ago

0.6.1

1 year ago

0.6.0

1 year ago

0.5.72

1 year ago

0.5.73

1 year ago

0.5.70

1 year ago

0.5.71

1 year ago

0.5.69

1 year ago

0.5.65

1 year ago

0.5.66

1 year ago

0.5.63

1 year ago

0.5.64

1 year ago

0.5.61

2 years ago

0.5.62

2 years ago

0.5.60

2 years ago

0.5.67

1 year ago

0.5.68

1 year ago

0.5.54

2 years ago

0.5.55

2 years ago

0.5.52

2 years ago

0.5.53

2 years ago

0.5.50

2 years ago

0.5.51

2 years ago

0.5.59

2 years ago

0.5.56

2 years ago

0.5.57

2 years ago

0.5.49

2 years ago

0.5.43

2 years ago

0.5.44

2 years ago

0.5.41

2 years ago

0.5.42

2 years ago

0.5.40

2 years ago

0.5.47

2 years ago

0.5.48

2 years ago

0.5.45

2 years ago

0.5.46

2 years ago

0.5.32

2 years ago

0.5.33

2 years ago

0.5.30

2 years ago

0.5.31

2 years ago

0.5.38

2 years ago

0.5.39

2 years ago

0.5.36

2 years ago

0.5.37

2 years ago

0.5.34

2 years ago

0.5.35

2 years ago

0.5.29

2 years ago

0.5.27

2 years ago

0.5.28

2 years ago

0.5.18

2 years ago

0.5.19

2 years ago

0.5.21

2 years ago

0.5.22

2 years ago

0.5.20

2 years ago

0.5.25

2 years ago

0.5.26

2 years ago

0.5.23

2 years ago

0.5.24

2 years ago

0.5.10

2 years ago

0.5.11

2 years ago

0.5.16

2 years ago

0.5.17

2 years ago

0.5.14

2 years ago

0.5.15

2 years ago

0.5.12

2 years ago

0.5.13

2 years ago

0.5.8

2 years ago

0.5.7

2 years ago

0.5.9

2 years ago

0.5.4

2 years ago

0.5.3

2 years ago

0.5.6

2 years ago

0.5.5

2 years ago

0.4.9

2 years ago

0.4.8

2 years ago

0.4.48

2 years ago

0.4.49

2 years ago

0.4.46

2 years ago

0.4.47

2 years ago

0.4.44

2 years ago

0.4.45

2 years ago

0.4.31

2 years ago

0.4.32

2 years ago

0.4.30

2 years ago

0.4.33

2 years ago

0.4.20

2 years ago

0.4.21

2 years ago

0.4.28

2 years ago

0.4.29

2 years ago

0.4.26

2 years ago

0.4.27

2 years ago

0.4.24

2 years ago

0.4.25

2 years ago

0.4.22

2 years ago

0.4.23

2 years ago

0.4.19

2 years ago

0.4.10

2 years ago

0.4.17

2 years ago

0.4.18

2 years ago

0.4.15

2 years ago

0.4.16

2 years ago

0.4.13

2 years ago

0.4.14

2 years ago

0.4.11

2 years ago

0.4.12

2 years ago

0.4.5

2 years ago

0.4.7

2 years ago

0.4.2

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.4.51

2 years ago

0.4.52

2 years ago

0.4.50

2 years ago

0.3.46

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.31

2 years ago

0.3.30

2 years ago

0.3.36

2 years ago

0.3.32

2 years ago

0.3.29

2 years ago

0.3.28

2 years ago

0.3.27

2 years ago

0.3.26

2 years ago

0.3.24

2 years ago

0.3.23

2 years ago

0.3.22

2 years ago

0.3.21

2 years ago

0.3.0

2 years ago

0.3.19

2 years ago

0.3.18

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.8

2 years ago

0.3.7

2 years ago

0.3.2

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.3.9

2 years ago

0.3.17

2 years ago

0.3.16

2 years ago

0.3.15

2 years ago

0.3.14

2 years ago

0.3.13

2 years ago

0.3.12

2 years ago

0.3.11

2 years ago

0.3.42

2 years ago

0.3.41

2 years ago

0.3.40

2 years ago

0.2.36

2 years ago

0.2.35

2 years ago

0.2.34

2 years ago

0.3.45

2 years ago

0.2.33

2 years ago

0.3.44

2 years ago

0.2.32

2 years ago

0.3.43

2 years ago

0.2.31

3 years ago

0.2.27

3 years ago

0.2.26

3 years ago

0.2.25

3 years ago

0.2.23

3 years ago

0.2.22

3 years ago

0.2.30

3 years ago

0.2.26-rc.1

3 years ago

0.2.26-rc.2

3 years ago

0.2.29

3 years ago

0.2.28

3 years ago

0.2.21

3 years ago

0.2.20

3 years ago

0.2.19

3 years ago

0.2.18

3 years ago

0.2.17

3 years ago

0.2.16

3 years ago

0.2.15

3 years ago

0.2.14

3 years ago

0.2.13

3 years ago

0.2.12

3 years ago

0.2.11

3 years ago

0.2.10

3 years ago

0.2.22-rc.8

3 years ago

0.2.22-rc.7

3 years ago

0.2.22-rc.6

3 years ago

0.2.22-rc.5

3 years ago

0.2.22-rc.4

3 years ago

0.2.22-rc.3

3 years ago

0.2.22-rc.2

3 years ago

0.2.22-rc.1

3 years ago

0.2.9

3 years ago

0.2.8

3 years ago

0.2.7

3 years ago

0.2.3

3 years ago