wework 1.1.3 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c4a4454feadfb1cadf33e0431610e3a140ef18dec8b5671c690e95f4a5c19e42
4
- data.tar.gz: a433e6117c9ce4b27962cfc455c62c26d0a972aa243446ccbdbf9fb31cc1da4b
3
+ metadata.gz: 9e3ed7c0371d7411dba8f0b23e88e220add94c7d30c4c3d2a5b56fd0e175460a
4
+ data.tar.gz: 389d38ad1070a6a15133aba8899029fd3dea09fabfe5aec29728d3ae09beac94
5
5
  SHA512:
6
- metadata.gz: 754f7a608454a16aed92bb900d1be56ce8f660cc0bba8d7287209e0aa20676f67efe6071b377ae6e524d58047b44431f9bb084e01aa480932805196aa5edf7c4
7
- data.tar.gz: 65f9f9525fd2796fe43a56a0eb447e5b1dbf5c4fab55fe692e5c2d2486feb75cf3a00ec99b41e12f5d4bcf974ad1ce84a890db2417855342afbafa3c3e5a4ede
6
+ metadata.gz: f118fe5ecd90f0bba3aea25b3f7c91a59e7d19253ee5935982d969ae9462407bea1d699a265da936d398880784f442952e8986e831c127317f2324ee99ef8863
7
+ data.tar.gz: eeb901426c8a76ad7114a4d0b0c1016bc5fc2b92a6dda6663782b0c4ab66efaff4ea253f69053e9ced266f52345cdf1a50660994dd31418fe755852d5efd4947
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Wework
1
+ # Wechat Work 「企业微信 API」
2
2
 
3
- Wework is a ruby API wrapper for work wechat.
3
+ Wework is a ruby API wrapper for wechat work「企业微信」.
4
4
 
5
- [![CircleCI](https://circleci.com/gh/mycolorway/wework/tree/suite.svg?style=svg)](https://circleci.com/gh/mycolorway/wework/tree/suite)
5
+ [![CircleCI](https://circleci.com/gh/mycolorway/wework/tree/suite.svg?style=svg)](https://circleci.com/gh/mycolorway/wework/tree/suite) [![Gem Version](https://badge.fury.io/rb/wework.svg)](https://badge.fury.io/rb/wework)
6
6
 
7
7
  ## Installation
8
8
 
@@ -46,6 +46,33 @@ agent_api = $wework_suite.corp(
46
46
  )
47
47
  ```
48
48
 
49
+ 3). 第三方应用回调协议
50
+
51
+ 获取加密数据
52
+
53
+ ```ruby
54
+ encrypt_str = if params[:xml].present?
55
+ params[:xml]['Encrypt']
56
+ else
57
+ Hash.from_xml(request.raw_post)['xml']['Encrypt']
58
+ end
59
+
60
+ #首次校验接口 encrpt_str = params[:echostr]
61
+ ```
62
+
63
+ 消息签名
64
+
65
+ ```ruby
66
+ $wework_suite.signature(timestamp, nonce, encrypt_str)
67
+ ```
68
+
69
+ 消息解密
70
+
71
+ ```ruby
72
+ $wework_suite.msg_decrypt(encrypt_data)
73
+ ```
74
+
75
+
49
76
  #### 自建应用
50
77
 
51
78
  初始化接口 [Wework::Api::Agent](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/agent.rb)
@@ -80,6 +107,21 @@ $provider_api = Wework::Api::Provider.new(
80
107
  )
81
108
  ```
82
109
 
110
+ #### 小程序 encryptedData 解密
111
+
112
+ ```ruby
113
+ require "openssl"
114
+ CIPHER = 'AES-128-CBC'.freeze
115
+
116
+ cipher = OpenSSL::Cipher.new(CIPHER)
117
+ cipher.decrypt
118
+ cipher.key = Base64.decode64(session_key)
119
+ cipher.iv = Base64.decode64(iv)
120
+ encrypted = Base64.decode64(encryptedData)
121
+ data = cipher.update(encrypted) + cipher.final
122
+ values = JSON.parse data
123
+ ```
124
+
83
125
 
84
126
  ## Methods
85
127
 
@@ -87,6 +129,8 @@ $provider_api = Wework::Api::Provider.new(
87
129
 
88
130
  [Wework::Api::Methods::User](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/user.rb)
89
131
 
132
+ [Wework::Api::Methods::Tag](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/tag.rb)
133
+
90
134
  [Wework::Api::Methods::Department](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/department.rb)
91
135
 
92
136
  [Wework::Api::Methods::Message](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/message.rb)
@@ -99,9 +143,11 @@ $provider_api = Wework::Api::Provider.new(
99
143
 
100
144
  [Wework::Api::Methods::Checkin](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/checkin.rb)
101
145
 
146
+ [Wework::Api::Methods::Batch](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/batch.rb)
147
+
102
148
  [Wework::Api::Methods::Provider](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/provider.rb)
103
149
 
104
- [Wework::Api::Methods::Suite](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/suite.rb)
150
+ [Wework::Api::Methods::Service](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/service.rb)
105
151
 
106
152
 
107
153
  ## Contributing
@@ -7,6 +7,9 @@ module Wework
7
7
  include Methods::Media
8
8
  include Methods::User
9
9
  include Methods::Department
10
+ include Methods::Tag
11
+ include Methods::Crm
12
+ include Methods::Batch
10
13
 
11
14
  attr_accessor :corp_id, :secret, :options
12
15
 
@@ -1,7 +1,6 @@
1
1
  module Wework
2
2
  module Api
3
3
  class Contact < Base
4
- include Methods::Batch
5
4
  end
6
5
  end
7
6
  end
@@ -3,8 +3,6 @@ module Wework
3
3
  class Corp < Base
4
4
 
5
5
  include Wework::Cipher
6
- include Methods::User
7
- include Methods::Department
8
6
 
9
7
  attr_reader :suite, :permanent_code
10
8
 
@@ -18,6 +18,10 @@ module Wework
18
18
  get 'batch/getresult', params: {jobid: job_id}
19
19
  end
20
20
 
21
+ def batch_invite user=[], party=[], tag=[]
22
+ post 'batch/invite', {user: user, party: party, tag: tag}
23
+ end
24
+
21
25
  private
22
26
 
23
27
  def batch_params media_id, callback_url, token, encodingaeskey
@@ -0,0 +1,11 @@
1
+ module Wework
2
+ module Api
3
+ module Methods
4
+ module Crm
5
+ def crm_get_external_contact external_userid
6
+ get 'crm/get_external_contact', params: {external_userid: external_userid}
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,7 +1,7 @@
1
1
  module Wework
2
2
  module Api
3
3
  module Methods
4
- module Suite
4
+ module Service
5
5
  def corp_authorize_url(redirect_uri, state="corp_authorize")
6
6
  "#{APP_AUTHORIZE_ENDPOINT}?suite_id=#{suite_id}&pre_auth_code=#{get_pre_auth_code}&redirect_uri=#{redirect_uri}&state=#{state}"
7
7
  end
@@ -0,0 +1,37 @@
1
+ module Wework
2
+ module Api
3
+ module Methods
4
+ module Tag
5
+ def tag_create(tagname, tagid=nil)
6
+ data = {tagname: tagname}
7
+ data[:tagid] = tagid unless tagid.nil?
8
+ post 'tag/create', data
9
+ end
10
+
11
+ def tag_update(tagid, tagname)
12
+ post 'tag/update', {tagid: tagid, tagname: tagname}
13
+ end
14
+
15
+ def tag_delete tagid
16
+ get 'user/delete', params: {tagid: tagid}
17
+ end
18
+
19
+ def tag_get tagid
20
+ get 'user/get', params: {tagid: tagid}
21
+ end
22
+
23
+ def tag_addtagusers tagid, userlist=[], partylist=[]
24
+ post 'tag/addtagusers', {tagid: tagid, userlist: userlist, partylist: partylist}
25
+ end
26
+
27
+ def tag_deltagusers tagid, userlist=[], partylist=[]
28
+ post 'tag/deltagusers', {tagid: tagid, userlist: userlist, partylist: partylist}
29
+ end
30
+
31
+ def tag_list
32
+ get 'user/list'
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -29,6 +29,18 @@ module Wework
29
29
  def user_list department_id, fetch_child=0
30
30
  get 'user/list', params: {department_id: department_id, fetch_child: fetch_child}
31
31
  end
32
+
33
+ def convert_to_openid userid
34
+ post 'user/convert_to_openid', {userid: userid}
35
+ end
36
+
37
+ def convert_to_userid openid
38
+ post 'user/convert_to_userid', {openid: openid}
39
+ end
40
+
41
+ def authsucc userid
42
+ get 'user/authsucc', params: {userid: userid}
43
+ end
32
44
  end
33
45
  end
34
46
  end
@@ -5,7 +5,7 @@ module Wework
5
5
  class Suite < Base
6
6
 
7
7
  include Wework::Cipher
8
- include Methods::Suite
8
+ include Methods::Service
9
9
 
10
10
  attr_reader :encoding_aes_key, :suite_id, :suite_secret, :suite_token
11
11
 
@@ -1,3 +1,3 @@
1
1
  module Wework
2
- VERSION = '1.1.3'.freeze
2
+ VERSION = '1.1.5'.freeze
3
3
  end
data/wework.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["seandong"]
10
10
  spec.email = ["sindon@gmail.com"]
11
11
 
12
- spec.summary = spec.description = %q{Ruby API wrapper for work wechat.}
12
+ spec.summary = spec.description = %q{Ruby API wrapper for wechat work「企业微信」}
13
13
  spec.homepage = "https://github.com/mycolorway/wework"
14
14
  spec.license = "MIT"
15
15
 
@@ -23,12 +23,12 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency 'http', '>= 2.2'
24
24
  spec.add_dependency 'activesupport', '~> 5.0'
25
25
  spec.add_dependency 'redis', '~>3.3'
26
- spec.add_dependency 'builder', '~> 3.2.2'
27
- spec.add_dependency 'sinatra', '~>2.0.0'
26
+ spec.add_dependency 'builder', '~> 3.2'
27
+ spec.add_dependency 'sinatra', '~> 2.0'
28
28
 
29
29
  spec.add_development_dependency "bundler", "~> 1.13"
30
30
  spec.add_development_dependency "rake", "~> 10.0"
31
31
  spec.add_development_dependency "minitest", "~> 5.10"
32
- spec.add_development_dependency 'webmock', '~> 3.4.1'
33
- spec.add_development_dependency 'mock_redis', '~>0.18.0'
32
+ spec.add_development_dependency 'webmock', '~> 3.4'
33
+ spec.add_development_dependency 'mock_redis', '~>0.18'
34
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wework
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - seandong
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-21 00:00:00.000000000 Z
11
+ date: 2018-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -58,28 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.2.2
61
+ version: '3.2'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 3.2.2
68
+ version: '3.2'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: sinatra
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 2.0.0
75
+ version: '2.0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 2.0.0
82
+ version: '2.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -128,29 +128,29 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 3.4.1
131
+ version: '3.4'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 3.4.1
138
+ version: '3.4'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: mock_redis
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 0.18.0
145
+ version: '0.18'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 0.18.0
153
- description: Ruby API wrapper for work wechat.
152
+ version: '0.18'
153
+ description: Ruby API wrapper for wechat work「企业微信」
154
154
  email:
155
155
  - sindon@gmail.com
156
156
  executables: []
@@ -175,12 +175,14 @@ files:
175
175
  - lib/wework/api/methods/approval.rb
176
176
  - lib/wework/api/methods/batch.rb
177
177
  - lib/wework/api/methods/checkin.rb
178
+ - lib/wework/api/methods/crm.rb
178
179
  - lib/wework/api/methods/department.rb
179
180
  - lib/wework/api/methods/media.rb
180
181
  - lib/wework/api/methods/menu.rb
181
182
  - lib/wework/api/methods/message.rb
182
183
  - lib/wework/api/methods/provider.rb
183
- - lib/wework/api/methods/suite.rb
184
+ - lib/wework/api/methods/service.rb
185
+ - lib/wework/api/methods/tag.rb
184
186
  - lib/wework/api/methods/user.rb
185
187
  - lib/wework/api/provider.rb
186
188
  - lib/wework/api/suite.rb
@@ -250,5 +252,5 @@ rubyforge_project:
250
252
  rubygems_version: 2.7.6
251
253
  signing_key:
252
254
  specification_version: 4
253
- summary: Ruby API wrapper for work wechat.
255
+ summary: Ruby API wrapper for wechat work「企业微信」
254
256
  test_files: []