Wework

Wework is a ruby API wrapper for work wechat.

CircleCI

Installation

Add this line to your application's Gemfile:

gem 'wework'

And then execute:

$ bundle

Or install it yourself as:

$ gem install wework

Usage

第三方应用

1). 初始化套件接口 Wework::Api::Suite

$wework_suite = Wework::Api::Suite.new(
  corp_id: ENV['WEWORK_CORPID'],                            # 应用服务商 CorpID
  suite_id: ENV['WEWORK_SUITE_ID'],                         # SuiteID
  encoding_aes_key: ENV['WEWORK_SUITE_ENCODING_AES_KEY'],   # EncodingAESKey
  suite_token: ENV['WEWORK_SUITE_TOKEN'],                   # Token
  suite_secret: ENV['WEWORK_SUITE_SECRET']                  # Secret
)

套件接口列表

2). 获取授权企业应用API Wework::Api::Agent

agent_api = $wework_suite.corp(
  corp_id,                                                  # 授权企业 CorpID
  permanent_code                                            # 永久授权码
)

自建应用

初始化接口 Wework::Api::Agent

$agent_api = Wework::Api::Agent.new(
  corp_id: ENV['WEWORK_CORPID'],                            # 企业 CorpID
  agent_id: ENV['WEWORK_APPID'],                            # AgentId
  secret: ENV['DEMO_APP_SECRET']                            # Secret
)

通讯录同步

初始化接口 Wework::Api::Contact

$contact_api = Wework::Api::Contact.new(
  corp_id: ENV['WEWORK_CORPID'],                            # 企业 CorpID
  secret: ENV['DEMO_APP_SECRET']                            # 通讯录同步 Secret
)

应用服务商接口 (单点登录)

初始化

$provider_api = Wework::Api::Provider.new(
  corp_id: ENV['WEWORK_PROVIDER_CORPID'],                   # 应用服务商 CorpID
  secret: ENV['WEWORK_PROVIDER_SECRET']                     # Secret
)

Methods

Wework::Api::Methods::Agent

Wework::Api::Methods::User

Wework::Api::Methods::Department

Wework::Api::Methods::Message

Wework::Api::Methods::Media

Wework::Api::Methods::Menu

Wework::Api::Methods::Approval

Wework::Api::Methods::Checkin

Wework::Api::Methods::Provider

Wework::Api::Methods::Suite

Contributing

  • Fork Wework on GitHub
  • Make your changes
  • Ensure all tests pass (bundle exec rake)
  • Send a pull request
  • If we like them we'll merge them
  • If we've accepted a patch, feel free to ask for commit access!

License

Copyright (c) 2018 MyColorway. See LICENSE.txt for further details.