wework 1.2.0 → 1.2.8

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: 3da9ef45528f36cf4ae7d00f2f1003cd28434521f92746649041d6e405b40a5d
4
- data.tar.gz: a792e4129d778a66d232da0439d937f4128a4fa9e0d194815af9fe330818990e
3
+ metadata.gz: 2370a71d7a4ebb3f04257eee4d1573748cfcc5e15ade5931a973d8abcfbe790b
4
+ data.tar.gz: 9340553291b76e20b4f8db91caeadd7455cd11489a78e45f210d2e5a60e02e02
5
5
  SHA512:
6
- metadata.gz: 2b50dd7799cafca89d649d96402964cdbd79e86e116d89acb62dbba74dc196e050a206713c13eecd8820e6addd630a3b3acace6661041758f464e3617cd2d9b4
7
- data.tar.gz: 3124fa217b49d14b1bf3846ed105b96d019496f162996a1d3e29a6a7bdcdc3ec39117af0f707adf115e37925f47cb8d5c1ebb249cf846cba92dca0d5b3dfe8d0
6
+ metadata.gz: 2100dbeb253d7fd17723c440d016f24510ef8215145099bbbf9c80b46411f52089b2cdbf8bf36c458dc21e1266d753945def2c83bbc052773f5dbee78048ee15
7
+ data.tar.gz: 4f7ce15118f59d0843e97e9fbd2adfec40b638fe02dc6e46ea2e00b36d9c97179f78f8b2681e30dc67e400b3e0cf03d5f0179e22d4cc9d02f7373c689134091c
data/README.md CHANGED
@@ -152,6 +152,8 @@ values = JSON.parse data
152
152
 
153
153
  [Wework::Api::Methods::Message](https://github.com/mycolorway/wework/blob/master/lib/wework/api/methods/message.rb)
154
154
 
155
+ [Wework::Api::Methods::Appchat](https://github.com/mycolorway/wework/blob/master/lib/wework/api/methods/appchat.rb)
156
+
155
157
  [Wework::Api::Methods::Media](https://github.com/mycolorway/wework/blob/master/lib/wework/api/methods/media.rb)
156
158
 
157
159
  [Wework::Api::Methods::Menu](https://github.com/mycolorway/wework/blob/master/lib/wework/api/methods/menu.rb)
@@ -2,8 +2,8 @@ require 'redis'
2
2
  require 'active_support/all'
3
3
  #require 'active_support/core_ext/object/blank'
4
4
 
5
- LIB_PATH = "#{File.dirname(__FILE__)}/wework"
6
- Dir["#{LIB_PATH}/api/methods/*.rb", "#{LIB_PATH}/token/*.rb"].each { |path| require path }
5
+ lib_path = "#{File.dirname(__FILE__)}/wework"
6
+ Dir["#{lib_path}/api/methods/*.rb", "#{lib_path}/token/*.rb"].each { |path| require path }
7
7
 
8
8
  require 'wework/version'
9
9
  require 'wework/cipher'
@@ -20,6 +20,7 @@ module Wework
20
20
  API_ENDPOINT = 'https://qyapi.weixin.qq.com/cgi-bin/'.freeze
21
21
  AUTHORIZE_ENDPOINT = 'https://open.weixin.qq.com/connect/oauth2/authorize'.freeze
22
22
  SSO_AUTHORIZE_ENDPOINT = 'https://open.work.weixin.qq.com/wwopen/sso/3rd_qrConnect'.freeze
23
+ AGENT_SSO_AUTHORIZE_ENDPOINT = 'https://open.work.weixin.qq.com/wwopen/sso/qrConnect'.freeze
23
24
  APP_AUTHORIZE_ENDPOINT = 'https://open.work.weixin.qq.com/3rdapp/install'.freeze
24
25
  REGISTER_ENDPOINT = 'https://open.work.weixin.qq.com/3rdservice/wework/register'.freeze
25
26
  HTTP_OK_STATUS = [200, 201].freeze
@@ -4,9 +4,11 @@ module Wework
4
4
 
5
5
  include Methods::Agent
6
6
  include Methods::Message
7
+ include Methods::Appchat
7
8
  include Methods::Menu
8
9
  include Methods::Checkin
9
10
  include Methods::Approval
11
+ include Wework::Cipher
10
12
 
11
13
  attr_reader :agent_id
12
14
 
@@ -27,4 +29,4 @@ module Wework
27
29
  end
28
30
  end
29
31
  end
30
- end
32
+ end
@@ -4,6 +4,11 @@ module Wework
4
4
  module Api
5
5
  module Methods
6
6
  module Agent
7
+ def sso_authorize_url(redirect_uri, state='qrconnect')
8
+ uri = ERB::Util.url_encode(redirect_uri)
9
+ "#{AGENT_SSO_AUTHORIZE_ENDPOINT}?appid=#{corp_id}&agentid=#{agent_id}&redirect_uri=#{uri}&state=#{state}"
10
+ end
11
+
7
12
  def authorize_url(redirect_uri, scope="snsapi_base", state="wxwork")
8
13
  # user agent: UA is mozilla/5.0 (iphone; cpu iphone os 10_2 like mac os x) applewebkit/602.3.12 (khtml, like gecko) mobile/14c92 wxwork/1.3.2 micromessenger/6.2
9
14
  uri = ERB::Util.url_encode(redirect_uri)
@@ -0,0 +1,62 @@
1
+ require "erb"
2
+
3
+ module Wework
4
+ module Api
5
+ module Methods
6
+ module Appchat
7
+
8
+ def appchat_create group_name, owner_id, group_user_ids, chat_id
9
+ post 'appchat/create',
10
+ name: group_name,
11
+ owner: owner_id,
12
+ userlist: group_user_ids,
13
+ chatid: chat_id
14
+ end
15
+
16
+ def appchat_update chat_id, payload={}
17
+ payload.merge! chatid: chat_id
18
+ post 'appchat/update', payload
19
+ end
20
+
21
+ def appchat_get chat_id
22
+ get 'appchat/get', { params: { chatid: chat_id } }
23
+ end
24
+
25
+ def text_appchat_send chat_id, content
26
+ appchat_send chat_id, {text: {content: content}, msgtype: 'text'}
27
+ end
28
+
29
+ def image_appchat_send chat_id, media_id
30
+ appchat_send chat_id, {image: {media_id: media_id}, msgtype: 'image'}
31
+ end
32
+
33
+ def voice_appchat_send chat_id, media_id
34
+ appchat_send chat_id, {voice: {media_id: media_id}, msgtype: 'voice'}
35
+ end
36
+
37
+ def file_appchat_send chat_id, media_id
38
+ appchat_send chat_id, {file: {media_id: media_id}, msgtype: 'file'}
39
+ end
40
+
41
+ def video_appchat_send chat_id, video={}
42
+ appchat_send chat_id, {video: video, msgtype: 'video'}
43
+ end
44
+
45
+ def textcard_appchat_send chat_id, textcard={}
46
+ appchat_send chat_id, {textcard: textcard, msgtype: 'textcard'}
47
+ end
48
+
49
+ def news_appchat_send chat_id, news=[]
50
+ appchat_send chat_id, {news: {articles: news}, msgtype: 'news'}
51
+ end
52
+
53
+ private
54
+
55
+ def appchat_send chat_id, payload={}
56
+ payload.merge!(chatid: chat_id)
57
+ post 'appchat/send', payload
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -5,8 +5,7 @@ module Wework
5
5
  module Methods
6
6
  module Message
7
7
  def miniprogram_message_send user_id, miniprogram_notice={}
8
- notice = miniprogram_notice.merge(appid: agent_id)
9
- post 'message/send', { touser: user_id, msgtype: 'miniprogram_notice', miniprogram_notice: notice }
8
+ post 'message/send', { touser: user_id, msgtype: 'miniprogram_notice', miniprogram_notice: miniprogram_notice }
10
9
  end
11
10
 
12
11
  def text_message_send user_ids, department_ids, content
@@ -10,6 +10,10 @@ module Wework
10
10
  get 'user/get', params: {userid: userid}
11
11
  end
12
12
 
13
+ def user_getuserid mobile
14
+ post 'user/getuserid', {mobile: mobile}
15
+ end
16
+
13
17
  def user_update userid, data={}
14
18
  post 'user/update', data.merge(userid: userid)
15
19
  end
@@ -4,14 +4,6 @@ module Wework
4
4
  include Methods::Provider
5
5
  include Wework::Cipher
6
6
 
7
- attr_reader :encoding_aes_key, :token
8
-
9
- def initialize(options={})
10
- @token = options.delete(:token)
11
- @encoding_aes_key = options.delete(:encoding_aes_key)
12
- super(options)
13
- end
14
-
15
7
  private
16
8
 
17
9
  def token_store
@@ -7,13 +7,12 @@ module Wework
7
7
  include Wework::Cipher
8
8
  include Methods::Service
9
9
 
10
- attr_reader :encoding_aes_key, :suite_id, :suite_secret, :suite_token, :token
10
+ attr_reader :suite_id, :suite_secret, :suite_token
11
11
 
12
12
  def initialize(options={})
13
13
  @suite_id = options.delete(:suite_id)
14
14
  @suite_secret = options.delete(:suite_secret)
15
15
  @token = @suite_token = options.delete(:suite_token)
16
- @encoding_aes_key = options.delete(:encoding_aes_key)
17
16
  super(options)
18
17
  end
19
18
 
@@ -11,6 +11,14 @@ module Wework
11
11
  BLOCK_SIZE = 32
12
12
  CIPHER = 'AES-256-CBC'.freeze
13
13
 
14
+ def token
15
+ @token ||= options[:token]
16
+ end
17
+
18
+ def encoding_aes_key
19
+ @encoding_aes_key ||= options[:encoding_aes_key]
20
+ end
21
+
14
22
  def encrypt(plain, encoding_aes_key)
15
23
  cipher = OpenSSL::Cipher.new(CIPHER)
16
24
  cipher.encrypt
@@ -76,7 +76,7 @@ module Wework
76
76
  data = file
77
77
 
78
78
  when :json
79
- data = JSON.parse response.body.to_s.gsub(/[\u0000-\u001f]+/, '')
79
+ data = JSON.parse response.body.to_s
80
80
  else
81
81
  data = response.body
82
82
  end
@@ -1,3 +1,3 @@
1
1
  module Wework
2
- VERSION = '1.2.0'.freeze
2
+ VERSION = '1.2.8'.freeze
3
3
  end
@@ -22,9 +22,9 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_dependency 'http', '>= 2.2'
24
24
  spec.add_dependency 'activesupport', '~> 5.0'
25
- spec.add_dependency 'redis', '~>3.3'
26
- spec.add_dependency 'builder', '~> 3.2'
27
- spec.add_dependency 'sinatra', '~> 2.0'
25
+ spec.add_dependency 'redis'
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"
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.2.0
4
+ version: 1.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - seandong
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-07 00:00:00.000000000 Z
11
+ date: 2020-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -42,42 +42,42 @@ dependencies:
42
42
  name: redis
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '3.3'
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '3.3'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: builder
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
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
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
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
82
  version: '2.0'
83
83
  - !ruby/object:Gem::Dependency
@@ -172,6 +172,7 @@ files:
172
172
  - lib/wework/api/contact.rb
173
173
  - lib/wework/api/corp.rb
174
174
  - lib/wework/api/methods/agent.rb
175
+ - lib/wework/api/methods/appchat.rb
175
176
  - lib/wework/api/methods/approval.rb
176
177
  - lib/wework/api/methods/batch.rb
177
178
  - lib/wework/api/methods/checkin.rb
@@ -248,8 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
249
  - !ruby/object:Gem::Version
249
250
  version: '0'
250
251
  requirements: []
251
- rubyforge_project:
252
- rubygems_version: 2.7.6
252
+ rubygems_version: 3.1.2
253
253
  signing_key:
254
254
  specification_version: 4
255
255
  summary: Ruby API wrapper for wechat work「企业微信」