Code Monkey home page Code Monkey logo

coa-wx-work's Introduction

coa-wx-work

GitHub license npm version npm downloads PRs Welcome

简洁的企业微信 SDK for Node.js

特点

根据日常实际项目使用情况:

  • 覆盖了绝大多数使用场景
  • 统一了异步表现形式,全部返回 Promise
  • 内置类型引用,无需额外查看文档,开箱即用,IDE 友好

快速开始

安装

yarn add coa-wx-work

使用

import {
  WxWorkBin,
  WxWorkDepartmentService,
  WxWorkMemberService,
} from 'coa-wx-work'

// Bin实例,任何服务都必须依赖此实例
const bin = new WxWorkBin()

// 定义一个agent配置
const agent = {
  corpId: 'wwc2bf51eeeeeee825b1',
  agentId: '1000001',
  secret: 'J1jxD5X3eXXXXXXXXXXXXIAHvawDRU4',
}

// 成员类服务实例
const memberService = new WxWorkMemberService(bin, agent)

// 获取成员列表
await memberService.getList()
// 创建成员
await memberService.create({ userid: 'u0001', name: 'AAA' })
// 更新成员
await memberService.update('u0001', { name: 'AAAAA' })
// 删除成员
await memberService.delete(['u0001'])

// 部门类服务实例
const departmentService = new WxWorkDepartmentService(bin, agent)

// 获取部门列表
await departmentService.getList()
// 创建部门
await departmentService.create({ id: 1, name: 'DeptA' })
// 更新部门
await departmentService.update(1, { name: 'DeptAA' })
// 删除部门
await departmentService.delete(1)

企业微信机器人的使用

import { WxWorkBin, WxWorkBotService, WxWorkMarkdown } from 'coa-wx-work'

// Bin实例,任何服务都必须依赖此实例
const bin = new WxWorkBin()

// 根据key创建一个bot服务
const botService = new WxWorkBotService(bin, 'XXXXX-XXXXX-XXXXX-XXXXX')

// 发送文本消息
await botService.text('文本消息')

// 通过base64方式发送图片消息
await botService.image('data of base64')

// 发送markdown消息
const content = new WxWorkMarkdown().header3('主题').text('主体内容')
await botService.markdown(content)

coa-wx-work's People

Contributors

adaex avatar willerhe avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.