wework 1.1.5 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e3ed7c0371d7411dba8f0b23e88e220add94c7d30c4c3d2a5b56fd0e175460a
4
- data.tar.gz: 389d38ad1070a6a15133aba8899029fd3dea09fabfe5aec29728d3ae09beac94
3
+ metadata.gz: f64f0d8436c00eabc6bccec0ec06674b344c683af83c289d5bbab600efddeed0
4
+ data.tar.gz: afb5f5ac2ad3d80b1e5b22738ef2c77445e9a1c89bc54bceaaeb9ec88a349583
5
5
  SHA512:
6
- metadata.gz: f118fe5ecd90f0bba3aea25b3f7c91a59e7d19253ee5935982d969ae9462407bea1d699a265da936d398880784f442952e8986e831c127317f2324ee99ef8863
7
- data.tar.gz: eeb901426c8a76ad7114a4d0b0c1016bc5fc2b92a6dda6663782b0c4ab66efaff4ea253f69053e9ced266f52345cdf1a50660994dd31418fe755852d5efd4947
6
+ metadata.gz: 1961367ffc18e715cd434df2b9e7928ab9894a5f53ee6d40f3b9df7224803461a928457cd756db90cc7068c3237c8e26029206fb504f46e512dedd6096a6d212
7
+ data.tar.gz: f50251f9823dbcd33c0076107533667590b010da0d83624a262c5784a1a0f565eb7dd2321a456de248ef43764a346b6a8103aabed24c8c92c263248a59b752cc
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
- # Wechat Work 「企业微信 API」
1
+ # Wechat Work 「企业微信」
2
2
 
3
3
  Wework is a ruby API wrapper for wechat work「企业微信」.
4
4
 
5
+ [企业微信 API 文档](https://work.weixin.qq.com/api/doc)
6
+
5
7
  [![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
8
 
7
9
  ## Installation
@@ -22,9 +24,19 @@ Or install it yourself as:
22
24
 
23
25
  ## Usage
24
26
 
25
- #### 第三方应用
27
+ ### 初始化
28
+
29
+ ```
30
+ Wework.configure do |config|
31
+ config.redis = Redis.new(host: ENV['REDIS_HOST'], port: ENV['REDIS_PORT'], db: ENV['REDIS_CACHE_DB']) # redis
32
+ config.http_timeout_options = {write: 15, read: 15, connect: 10} # 请求超时
33
+ config.expired_shift_seconds = 180 # access token 有效期偏移量 (时间有效期 - 偏移量)
34
+ end
35
+ ```
26
36
 
27
- 1). 初始化套件接口 [Wework::Api::Suite](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/suite.rb)
37
+ ### 第三方应用
38
+
39
+ 1). 初始化套件接口 [Wework::Api::Suite](https://github.com/mycolorway/wework/blob/master/lib/wework/api/suite.rb)
28
40
 
29
41
  ```ruby
30
42
  $wework_suite = Wework::Api::Suite.new(
@@ -35,15 +47,15 @@ $wework_suite = Wework::Api::Suite.new(
35
47
  suite_secret: ENV['WEWORK_SUITE_SECRET'] # Secret
36
48
  )
37
49
  ```
38
- [套件接口列表](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/suite.rb)
39
50
 
40
- 2). 获取授权企业应用API [Wework::Api::Agent](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/agent.rb)
51
+
52
+ 2). 获取第三方应用接口 [Wework::Api::Agent](https://github.com/mycolorway/wework/blob/master/lib/wework/api/agent.rb)
41
53
 
42
54
  ```ruby
43
55
  agent_api = $wework_suite.corp(
44
- corp_id, # 授权企业 CorpID
45
- permanent_code # 永久授权码
46
- )
56
+ corp_id, # 授权企业 CorpID
57
+ permanent_code # 永久授权码
58
+ ).agent(agent_id)
47
59
  ```
48
60
 
49
61
  3). 第三方应用回调协议
@@ -73,9 +85,9 @@ $wework_suite.signature(timestamp, nonce, encrypt_str)
73
85
  ```
74
86
 
75
87
 
76
- #### 自建应用
88
+ ### 自建应用
77
89
 
78
- 初始化接口 [Wework::Api::Agent](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/agent.rb)
90
+ 初始化接口 [Wework::Api::Agent](https://github.com/mycolorway/wework/blob/master/lib/wework/api/agent.rb)
79
91
 
80
92
  ``` ruby
81
93
  $agent_api = Wework::Api::Agent.new(
@@ -85,9 +97,9 @@ $agent_api = Wework::Api::Agent.new(
85
97
  )
86
98
  ```
87
99
 
88
- #### 通讯录同步
100
+ ### 通讯录同步
89
101
 
90
- 初始化接口 [Wework::Api::Contact](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/contact.rb)
102
+ 初始化接口 [Wework::Api::Contact](https://github.com/mycolorway/wework/blob/master/lib/wework/api/contact.rb)
91
103
 
92
104
  ``` ruby
93
105
  $contact_api = Wework::Api::Contact.new(
@@ -96,7 +108,7 @@ $contact_api = Wework::Api::Contact.new(
96
108
  )
97
109
  ```
98
110
 
99
- #### 应用服务商接口 (单点登录)
111
+ ### 应用服务商接口 (单点登录)
100
112
 
101
113
  初始化
102
114
 
@@ -107,7 +119,7 @@ $provider_api = Wework::Api::Provider.new(
107
119
  )
108
120
  ```
109
121
 
110
- #### 小程序 encryptedData 解密
122
+ ### 小程序 encryptedData 解密
111
123
 
112
124
  ```ruby
113
125
  require "openssl"
@@ -123,31 +135,31 @@ values = JSON.parse data
123
135
  ```
124
136
 
125
137
 
126
- ## Methods
138
+ ## 已实现接口列表
127
139
 
128
- [Wework::Api::Methods::Agent](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/agent.rb)
140
+ [Wework::Api::Methods::Agent](https://github.com/mycolorway/wework/blob/master/lib/wework/api/methods/agent.rb)
129
141
 
130
- [Wework::Api::Methods::User](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/user.rb)
142
+ [Wework::Api::Methods::User](https://github.com/mycolorway/wework/blob/master/lib/wework/api/methods/user.rb)
131
143
 
132
- [Wework::Api::Methods::Tag](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/tag.rb)
144
+ [Wework::Api::Methods::Tag](https://github.com/mycolorway/wework/blob/master/lib/wework/api/methods/tag.rb)
133
145
 
134
- [Wework::Api::Methods::Department](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/department.rb)
146
+ [Wework::Api::Methods::Department](https://github.com/mycolorway/wework/blob/master/lib/wework/api/methods/department.rb)
135
147
 
136
- [Wework::Api::Methods::Message](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/message.rb)
148
+ [Wework::Api::Methods::Message](https://github.com/mycolorway/wework/blob/master/lib/wework/api/methods/message.rb)
137
149
 
138
- [Wework::Api::Methods::Media](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/media.rb)
150
+ [Wework::Api::Methods::Media](https://github.com/mycolorway/wework/blob/master/lib/wework/api/methods/media.rb)
139
151
 
140
- [Wework::Api::Methods::Menu](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/menu.rb)
152
+ [Wework::Api::Methods::Menu](https://github.com/mycolorway/wework/blob/master/lib/wework/api/methods/menu.rb)
141
153
 
142
- [Wework::Api::Methods::Approval](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/approval.rb)
154
+ [Wework::Api::Methods::Approval](https://github.com/mycolorway/wework/blob/master/lib/wework/api/methods/approval.rb)
143
155
 
144
- [Wework::Api::Methods::Checkin](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/checkin.rb)
156
+ [Wework::Api::Methods::Checkin](https://github.com/mycolorway/wework/blob/master/lib/wework/api/methods/checkin.rb)
145
157
 
146
- [Wework::Api::Methods::Batch](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/batch.rb)
158
+ [Wework::Api::Methods::Batch](https://github.com/mycolorway/wework/blob/master/lib/wework/api/methods/batch.rb)
147
159
 
148
- [Wework::Api::Methods::Provider](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/provider.rb)
160
+ [Wework::Api::Methods::Provider](https://github.com/mycolorway/wework/blob/master/lib/wework/api/methods/provider.rb)
149
161
 
150
- [Wework::Api::Methods::Service](https://github.com/mycolorway/wework/blob/suite/lib/wework/api/methods/service.rb)
162
+ [Wework::Api::Methods::Service](https://github.com/mycolorway/wework/blob/master/lib/wework/api/methods/service.rb)
151
163
 
152
164
 
153
165
  ## Contributing
@@ -45,14 +45,16 @@ module Wework
45
45
  url_base = header.delete(:base) || base
46
46
  as = header.delete(:as)
47
47
  header['Accept'] = 'application/json'
48
+ dup_header = header.dup
48
49
  response = yield("#{url_base}#{path}", header)
49
-
50
50
  raise ResponseError.new(response.status) unless HTTP_OK_STATUS.include?(response.status)
51
51
 
52
52
  parse_response(response, as || :json) do |parse_as, data|
53
53
  break data unless parse_as == :json
54
54
  result = Wework::Result.new(data)
55
- Rails.logger.debug "[WEWORK] request path(#{url_base}#{path}): #{result.inspect}" if defined?(Rails.logger) && Rails.logger
55
+ if defined?(Rails.logger) && Rails.logger
56
+ Rails.logger.debug "[WEWORK] request path(#{url_base}#{path}); request params: #{dup_header.inspect}; response: #{result.inspect}"
57
+ end
56
58
  raise AccessTokenExpiredError if result.token_expired?
57
59
  result
58
60
  end
@@ -1,3 +1,3 @@
1
1
  module Wework
2
- VERSION = '1.1.5'.freeze
2
+ VERSION = '1.1.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wework
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - seandong