@kintone/rest-api-client-dingtalk-mp
v0.1.0
Published
kintone REST API client for DingTalk Mini Program
Downloads
2
Readme
kintone-rest-api-client-dingtalk-mp
An API client for Kintone REST API, it is used in DingTalk Mini Program client. It is based on @kintone/[email protected]. It wraps the functions of app, record and bulkRequest of "@kintone/rest-api-client", and develops the new functions of file.
Requirement
- DingTalk Developer Tool (The latest)
Usage
Step 1
Open DingTalk Developer Tool and create a new project. (Ref. 小程序IDE使用)
Step 2
Install with npm
cd [your-project-directory]
npm init -y
npm install @kintone/rest-api-client-dingtalk-mp
Sample code
const {KintoneRestAPIClientDingTalkMP} = require('@kintone/rest-api-client-dingtalk-mp');
const client = new KintoneRestAPIClientDingTalkMP({
baseUrl: "https://example.cybozu.com",
// Use password authentication
auth: {
username: process.env.KINTONE_USERNAME,
password: process.env.KINTONE_PASSWORD,
},
// Use API token authentication
// auth: { apiToken: process.env.KINTONE_API_TOKEN }
});
client.record
.getRecords({ app: "1" })
.then((resp) => {
console.log(resp.records);
})
.catch((err) => {
console.log(err);
});
Parameters for KintoneRestAPIClientDingTalkMP
| Name | Type | Required | Description |
| -------------------------- | :--------------------------------------------------------------: | :-------------------------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| baseUrl | String | Required | The base URL for your Kintone environment.It must start with https
. (e.g. https://example.kintone.com) |
| auth | Object | Required | The object for authentication. See Authentication. |
| guestSpaceId | Number or String | | The guest space ID. If you are dealing with apps that are in guest spaces, please specify this. |
| basicAuth | Object | | If your Kintone environment uses Basic authentication, please specify its username and password. |
| basicAuth.username | String | | The username of Basic authentication. |
| basicAuth.password | String | | The password of Basic authentication. |
Authentication
The client supports three authentication methods:
The required parameters inside auth
are different by the methods.
The client determines which method to use by passed parameters.
1. Parameters for Password authentication
| Name | Type | Required | Description | | -------- | :----: | :------: | ----------------- | | username | String | Yes | User's login name | | password | String | Yes | User's password |
2. Parameters for API token authentication
| Name | Type | Required | Description | | -------- | :----------------: | :------: | ------------------------------------------------------- | | apiToken | String or String[] | Yes | You can pass multiple api tokens as an array of string. |
References
The usage of following functions is not changed, you can refer to the doc of "@kintone/rest-api-client". Pay attention to the class name, you should use KintoneRestAPIClientDingTalkMP in DingTalk. Refer to Sample code.
- @kintone/rest-api-client/errorHandling
- @kintone/rest-api-client/record
- @kintone/rest-api-client/app
- @kintone/rest-api-client/bulkRequest
License
Copyright
Copyright(c) Cybozu, Inc.