wework 0.2.0 → 0.2.2

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
  SHA1:
3
- metadata.gz: 7dffeebfa4fffccab3b0a28b5cc581a801ebf63e
4
- data.tar.gz: d1d77e3344ceea9b83f98066931ff7ba649dae6d
3
+ metadata.gz: 23353739f387e0990b71b0aeee47804573a0965f
4
+ data.tar.gz: 681c567f7f98bf3dc4d6d3ad616a55ec5f71d7d9
5
5
  SHA512:
6
- metadata.gz: 49b226e216980d916b24ff5905455d1cbdd18d1b55e9252620db7b49afa18fd90c4f3cb19a50c71edb739cc0e821cd75f6d600fecec2f7a100cce2541c87360f
7
- data.tar.gz: 25ca0092cceaac5a379d2eac7a3681bfbf50a7fb19f9572abb8512b817b58ffc5553d9e24888ad6416f807bd831e57fc20a9a3a8b95280162debbac03731830e
6
+ metadata.gz: 7eea1d777d3461900c64e2bd9f5a711ee75f09248de9f764878cf5bb8657b14f23c550f7fd997a562b30b780a63c3635d3a4296a1f48967cbd9cd3276200aa5c
7
+ data.tar.gz: c74e035741920048a38524e2c7c86732b029fcaa701b4ad1d7aba5fe63e8d4f7afe81b8987d261c8356f875cecdb912fe22e4b113a36f00357f20ea2221182bc
@@ -67,12 +67,12 @@ module Wework
67
67
  message_send user_ids, department_ids, {file: {media_id: media_id}, msgtype: 'file'}
68
68
  end
69
69
 
70
- def video_message_send user_ids, department_ids, media_id, title='', description=''
71
- message_send user_ids, department_ids, {video: {media_id: media_id, title: 'title', description: description}, msgtype: 'video'}
70
+ def video_message_send user_ids, department_ids, video={}
71
+ message_send user_ids, department_ids, {video: video, msgtype: 'video'}
72
72
  end
73
73
 
74
- def textcard_message_send user_ids, department_ids, title, description, url, btntxt='详情'
75
- message_send user_ids, department_ids, {textcard: {title: title, description: description, url: url, btntxt: btntxt}, msgtype: 'textcard'}
74
+ def textcard_message_send user_ids, department_ids, textcard={}
75
+ message_send user_ids, department_ids, {textcard: textcard, msgtype: 'textcard'}
76
76
  end
77
77
 
78
78
  def news_message_send user_ids, department_ids, news=[]
@@ -15,7 +15,7 @@ module Wework
15
15
  end
16
16
 
17
17
  def http_timeout_options
18
- config.http_timeout_options || {write: 5, connect: 5, read: 5}
18
+ config.http_timeout_options || {write: 2, connect: 5, read: 10}
19
19
  end
20
20
  end
21
21
 
@@ -0,0 +1,327 @@
1
+ module Wework
2
+ GLOBAL_CODES = {
3
+ -1 => "系统繁忙",
4
+ 0 => "请求成功",
5
+ 40001 => "获取access_token时Secret错误,或者access_token无效",
6
+ 40002 => "不合法的凭证类型",
7
+ 40003 => "不合法的UserID",
8
+ 40004 => "不合法的媒体文件类型",
9
+ 40005 => "不合法的文件类型",
10
+ 40006 => "不合法的文件大小",
11
+ 40007 => "不合法的媒体文件id",
12
+ 40008 => "不合法的消息类型",
13
+ 40013 => "不合法的corpid",
14
+ 40014 => "不合法的access_token",
15
+ 40015 => "不合法的菜单类型",
16
+ 40016 => "不合法的按钮个数",
17
+ 40017 => "不合法的按钮类型",
18
+ 40018 => "不合法的按钮名字长度",
19
+ 40019 => "不合法的按钮KEY长度",
20
+ 40020 => "不合法的按钮URL长度",
21
+ 40021 => "不合法的菜单版本号",
22
+ 40022 => "不合法的子菜单级数",
23
+ 40023 => "不合法的子菜单按钮个数",
24
+ 40024 => "不合法的子菜单按钮类型",
25
+ 40025 => "不合法的子菜单按钮名字长度",
26
+ 40026 => "不合法的子菜单按钮KEY长度",
27
+ 40027 => "不合法的子菜单按钮URL长度",
28
+ 40028 => "不合法的自定义菜单使用成员",
29
+ 40029 => "不合法的oauth_code",
30
+ 40031 => "不合法的UserID列表",
31
+ 40032 => "不合法的UserID列表长度",
32
+ 40033 => "不合法的请求字符,不能包含\\uxxxx格式的字符",
33
+ 40035 => "不合法的参数",
34
+ 40038 => "不合法的请求格式",
35
+ 40039 => "不合法的URL长度",
36
+ 40040 => "不合法的插件token",
37
+ 40041 => "不合法的插件id",
38
+ 40042 => "不合法的插件会话",
39
+ 40048 => "url中包含不合法domain",
40
+ 40054 => "不合法的子菜单url域名",
41
+ 40055 => "不合法的按钮url域名",
42
+ 40056 => "不合法的agentid",
43
+ 40057 => "不合法的callbackurl或者callbackurl验证失败",
44
+ 40058 => "不合法的红包参数",
45
+ 40059 => "不合法的上报地理位置标志位",
46
+ 40060 => "设置上报地理位置标志位时没有设置callbackurl",
47
+ 40061 => "设置应用头像失败",
48
+ 40062 => "不合法的应用模式",
49
+ 40063 => "参数为空",
50
+ 40064 => "管理组名字已存在",
51
+ 40065 => "不合法的管理组名字长度",
52
+ 40066 => "不合法的部门列表",
53
+ 40067 => "标题长度不合法",
54
+ 40068 => "不合法的标签ID",
55
+ 40069 => "不合法的标签ID列表",
56
+ 40070 => "列表中所有标签(成员)ID都不合法",
57
+ 40071 => "不合法的标签名字,标签名字已经存在",
58
+ 40072 => "不合法的标签名字长度",
59
+ 40073 => "不合法的openid",
60
+ 40074 => "news消息不支持指定为高保密消息",
61
+ 40077 => "不合法的预授权码",
62
+ 40078 => "不合法的临时授权码",
63
+ 40079 => "不合法的授权信息",
64
+ 40080 => "不合法的suitesecret",
65
+ 40082 => "不合法的suitetoken",
66
+ 40083 => "不合法的suiteid",
67
+ 40084 => "不合法的永久授权码",
68
+ 40085 => "不合法的suiteticket",
69
+ 40086 => "不合法的第三方应用appid",
70
+ 40092 => "导入文件存在不合法的内容",
71
+ 40093 => "不合法的跳转target",
72
+ 40094 => "不合法的URL",
73
+ 40095 => "修改失败,并发冲突",
74
+ 40155 => "请勿添加其他公众号的主页链接",
75
+ 41001 => "缺少access_token参数",
76
+ 41002 => "缺少corpid参数",
77
+ 41003 => "缺少refresh_token参数",
78
+ 41004 => "缺少secret参数",
79
+ 41005 => "缺少多媒体文件数据",
80
+ 41006 => "缺少media_id参数",
81
+ 41007 => "缺少子菜单数据",
82
+ 41008 => "缺少oauth code",
83
+ 41009 => "缺少UserID",
84
+ 41010 => "缺少url",
85
+ 41011 => "缺少agentid",
86
+ 41012 => "缺少应用头像mediaid",
87
+ 41013 => "缺少应用名字",
88
+ 41014 => "缺少应用描述",
89
+ 41015 => "缺少Content",
90
+ 41016 => "缺少标题",
91
+ 41017 => "缺少标签ID",
92
+ 41018 => "缺少标签名字",
93
+ 41021 => "缺少suiteid",
94
+ 41022 => "缺少suitetoken",
95
+ 41023 => "缺少suiteticket",
96
+ 41024 => "缺少suitesecret",
97
+ 41025 => "缺少永久授权码",
98
+ 41034 => "缺少login_ticket",
99
+ 41035 => "缺少跳转target",
100
+ 42001 => "access_token过期",
101
+ 42002 => "refresh_token过期",
102
+ 42003 => "oauth_code过期",
103
+ 42004 => "插件token过期",
104
+ 42007 => "预授权码失效",
105
+ 42008 => "临时授权码失效",
106
+ 42009 => "suitetoken失效",
107
+ 43001 => "需要GET请求",
108
+ 43002 => "需要POST请求",
109
+ 43003 => "需要HTTPS",
110
+ 43004 => "需要成员已关注",
111
+ 43005 => "需要好友关系",
112
+ 43006 => "需要订阅",
113
+ 43007 => "需要授权",
114
+ 43008 => "需要支付授权",
115
+ 43010 => "需要处于回调模式",
116
+ 43011 => "需要企业授权",
117
+ 43013 => "应用对成员不可见",
118
+ 44001 => "多媒体文件为空",
119
+ 44002 => "POST的数据包为空",
120
+ 44003 => "图文消息内容为空",
121
+ 44004 => "文本消息内容为空",
122
+ 45001 => "多媒体文件大小超过限制",
123
+ 45002 => "消息内容大小超过限制",
124
+ 45003 => "标题大小超过限制",
125
+ 45004 => "描述大小超过限制",
126
+ 45005 => "链接长度超过限制",
127
+ 45006 => "图片链接长度超过限制",
128
+ 45007 => "语音播放时间超过限制",
129
+ 45008 => "图文消息的文章数量不能超过10条",
130
+ 45009 => "接口调用超过限制",
131
+ 45010 => "创建菜单个数超过限制",
132
+ 45015 => "回复时间超过限制",
133
+ 45016 => "系统分组,不允许修改",
134
+ 45017 => "分组名字过长",
135
+ 45018 => "分组数量超过上限",
136
+ 45022 => "应用名字长度不合法,合法长度为2-16个字",
137
+ 45024 => "帐号数量超过上限",
138
+ 45025 => "同一个成员每周只能邀请一次",
139
+ 45026 => "触发删除用户数的保护",
140
+ 45027 => "mpnews每天只能发送100次",
141
+ 45028 => "素材数量超过上限",
142
+ 45029 => "media_id对该应用不可见",
143
+ 45032 => "作者名字长度超过限制",
144
+ 46001 => "不存在媒体数据",
145
+ 46002 => "不存在的菜单版本",
146
+ 46003 => "不存在的菜单数据",
147
+ 46004 => "不存在的成员",
148
+ 47001 => "解析JSON/XML内容错误",
149
+ 48001 => "Api未授权",
150
+ 48002 => "Api禁用(一般是管理组类型与Api不匹配,例如普通管理组调用会话服务的Api)",
151
+ 48003 => "suitetoken无效",
152
+ 48004 => "授权关系无效",
153
+ 48005 => "Api已废弃",
154
+ 50001 => "redirect_uri未授权",
155
+ 50002 => "成员不在权限范围",
156
+ 50003 => "应用已停用",
157
+ 50004 => "成员状态不正确,需要成员为企业验证中状态",
158
+ 50005 => "企业已禁用",
159
+ 60001 => "部门长度不符合限制",
160
+ 60002 => "部门层级深度超过限制",
161
+ 60003 => "部门不存在",
162
+ 60004 => "父亲部门不存在",
163
+ 60005 => "不允许删除有成员的部门",
164
+ 60006 => "不允许删除有子部门的部门",
165
+ 60007 => "不允许删除根部门",
166
+ 60008 => "部门ID或者部门名称已存在",
167
+ 60009 => "部门名称含有非法字符",
168
+ 60010 => "部门存在循环关系",
169
+ 60011 => "权限不足,user/department/agent无权限(1.只有通迅录同步助手才有通迅录写权限。2.自定义的应用,需要确定可见范围是否有此人)",
170
+ 60012 => "不允许删除默认应用",
171
+ 60013 => "不允许关闭应用",
172
+ 60014 => "不允许开启应用",
173
+ 60015 => "不允许修改默认应用可见范围",
174
+ 60016 => "不允许删除存在成员的标签",
175
+ 60017 => "不允许设置企业",
176
+ 60019 => "不允许设置应用地理位置上报开关",
177
+ 60020 => "访问ip不在白名单之中",
178
+ 60023 => "已授权的应用不允许企业管理组调用接口修改菜单",
179
+ 60025 => "主页型应用不支持的消息类型",
180
+ 60027 => "不支持第三方修改主页型应用字段",
181
+ 60028 => "应用已授权予第三方,不允许通过接口修改主页url",
182
+ 60029 => "应用已授权予第三方,不允许通过接口修改可信域名",
183
+ 60031 => "未设置管理组的登录授权域名",
184
+ 60102 => "UserID已存在",
185
+ 60103 => "手机号码不合法",
186
+ 60104 => "手机号码已存在",
187
+ 60105 => "邮箱不合法",
188
+ 60106 => "邮箱已存在",
189
+ 60107 => "微信号不合法",
190
+ 60108 => "微信号已存在",
191
+ 60109 => "QQ号已存在",
192
+ 60110 => "用户同时归属部门超过20个",
193
+ 60111 => "UserID不存在",
194
+ 60112 => "成员姓名不合法",
195
+ 60113 => "身份认证信息(微信号/手机/邮箱)不能同时为空",
196
+ 60114 => "性别不合法",
197
+ 60115 => "已关注成员微信不能修改",
198
+ 60116 => "扩展属性已存在",
199
+ 60118 => "成员无有效邀请字段,详情参考(邀请成员关注)的接口说明",
200
+ 60119 => "成员已关注",
201
+ 60120 => "成员已禁用",
202
+ 60121 => "找不到该成员",
203
+ 60122 => "邮箱已被外部管理员使用",
204
+ 60123 => "无效的部门id",
205
+ 60124 => "无效的父部门id",
206
+ 60125 => "非法部门名字,长度超过限制、重名等,重名包括与csv文件中同级部门重名或者与旧组织架构包含成员的同级部门重名",
207
+ 60126 => "创建部门失败",
208
+ 60127 => "缺少部门id",
209
+ 60128 => "字段不合法,可能存在主键冲突或者格式错误",
210
+ 60129 => "用户设置了拒绝邀请",
211
+ 60131 => "不合法的职位长度",
212
+ 80001 => "可信域名不匹配,或者可信域名没有IPC备案(后续将不能在该域名下正常使用jssdk)",
213
+ 81003 => "邀请额度已用完",
214
+ 81004 => "部门数量超过上限",
215
+ 82001 => "发送消息或者邀请的参数全部为空或者全部不合法",
216
+ 82002 => "不合法的PartyID列表长度",
217
+ 82003 => "不合法的TagID列表长度",
218
+ 82004 => "微信版本号过低",
219
+ 85002 => "包含不合法的词语",
220
+ 86001 => "不合法的会话ID",
221
+ 86003 => "不存在的会话ID",
222
+ 86004 => "不合法的会话名",
223
+ 86005 => "不合法的会话管理员",
224
+ 86006 => "不合法的成员列表大小",
225
+ 86007 => "不存在的成员",
226
+ 86101 => "需要会话管理员权限",
227
+ 86201 => "缺少会话ID",
228
+ 86202 => "缺少会话名",
229
+ 86203 => "缺少会话管理员",
230
+ 86204 => "缺少成员",
231
+ 86205 => "非法的会话ID长度",
232
+ 86206 => "非法的会话ID数值",
233
+ 86207 => "会话管理员不在用户列表中",
234
+ 86208 => "消息服务未开启",
235
+ 86209 => "缺少操作者",
236
+ 86210 => "缺少会话参数",
237
+ 86211 => "缺少会话类型(单聊或者群聊)",
238
+ 86213 => "缺少发件人",
239
+ 86214 => "非法的会话类型",
240
+ 86215 => "会话已存在",
241
+ 86216 => "非法会话成员",
242
+ 86217 => "会话操作者不在成员列表中",
243
+ 86218 => "非法会话发件人",
244
+ 86219 => "非法会话收件人",
245
+ 86220 => "非法会话操作者",
246
+ 86221 => "单聊模式下,发件人与收件人不能为同一人",
247
+ 86222 => "不允许消息服务访问的API",
248
+ 86304 => "不合法的消息类型",
249
+ 86305 => "客服服务未启用",
250
+ 86306 => "缺少发送人",
251
+ 86307 => "缺少发送人类型",
252
+ 86308 => "缺少发送人id",
253
+ 86309 => "缺少接收人",
254
+ 86310 => "缺少接收人类型",
255
+ 86311 => "缺少接收人id",
256
+ 86312 => "缺少消息类型",
257
+ 86313 => "缺少客服,发送人或接收人类型,必须有一个为kf",
258
+ 86314 => "客服不唯一,发送人或接收人类型,必须只有一个为kf",
259
+ 86315 => "不合法的发送人类型",
260
+ 86316 => "不合法的发送人id。Userid不存在、openid不存在、kf不存在",
261
+ 86317 => "不合法的接收人类型",
262
+ 86318 => "不合法的接收人id。Userid不存在、openid不存在、kf不存在",
263
+ 86319 => "不合法的客服,kf不在客服列表中",
264
+ 86320 => "不合法的客服类型",
265
+ 88001 => "缺少seq参数",
266
+ 88002 => "缺少offset参数",
267
+ 88003 => "非法seq",
268
+ 90001 => "未认证摇一摇周边",
269
+ 90002 => "缺少摇一摇周边ticket参数",
270
+ 90003 => "摇一摇周边ticket参数不合法",
271
+ 90004 => "摇一摇周边ticket过期",
272
+ 90005 => "未开启摇一摇周边服务",
273
+ 91004 => "卡券已被核销",
274
+ 91011 => "无效的code",
275
+ 91014 => "缺少卡券详情",
276
+ 91015 => "代金券缺少least_cost或者reduce_cost参数",
277
+ 91016 => "折扣券缺少discount参数",
278
+ 91017 => "礼品券缺少gift参数",
279
+ 91019 => "缺少卡券sku参数",
280
+ 91020 => "缺少卡券有效期",
281
+ 91021 => "缺少卡券有效期类型",
282
+ 91022 => "缺少卡券logo_url",
283
+ 91023 => "缺少卡券code类型",
284
+ 91025 => "缺少卡券title",
285
+ 91026 => "缺少卡券color",
286
+ 91027 => "缺少offset参数",
287
+ 91028 => "缺少count参数",
288
+ 91029 => "缺少card_id",
289
+ 91030 => "缺少卡券code",
290
+ 91031 => "缺少卡券notice",
291
+ 91032 => "缺少卡券description",
292
+ 91033 => "缺少ticket类型",
293
+ 91036 => "不合法的有效期",
294
+ 91038 => "变更库存值不合法",
295
+ 91039 => "不合法的卡券id",
296
+ 91040 => "不合法的ticket type",
297
+ 91041 => "没有创建,上传卡券logo,以及核销卡券的权限",
298
+ 91042 => "没有该卡券投放权限",
299
+ 91043 => "没有修改或者删除该卡券的权限",
300
+ 91044 => "不合法的卡券参数",
301
+ 91045 => "缺少团购券groupon结构",
302
+ 91046 => "缺少现金券cash结构",
303
+ 91047 => "缺少折扣券discount结构",
304
+ 91048 => "缺少礼品券gift结构",
305
+ 91049 => "缺少优惠券coupon结构",
306
+ 91050 => "缺少卡券必填字段",
307
+ 91051 => "商户名称超过12个汉字",
308
+ 91052 => "卡券标题超过9个汉字",
309
+ 91053 => "卡券提醒超过16个汉字",
310
+ 91054 => "卡券描述超过1024个汉字",
311
+ 91055 => "卡券副标题长度超过18个汉字",
312
+ 301001 => "应用id已存在",
313
+ 301002 => "accesstoken不允许操作其它应用。",
314
+ 301004 => "不允许删除超级管理员",
315
+ 301005 => "消息型应用不允许做此操作",
316
+ 301006 => "不允许禁用超级管理员",
317
+ 301008 => "主页型应用不允许做此操作",
318
+ 301009 => "应用发送消息没有接收主体",
319
+ 301010 => "部门名已存在",
320
+ 301013 => "座机不合法",
321
+ 301014 => "英文名称不合法",
322
+ 302001 => "批量同步成员存在userid为空的用户",
323
+ 302002 => "管理员userid不存在",
324
+ 302003 => "存在重复的userid",
325
+ 302004 => "组织架构不合法"
326
+ } unless defined?(GLOBAL_CODES)
327
+ end
@@ -7,7 +7,7 @@ module Wework
7
7
 
8
8
  def initialize(base, skip_verify_ssl)
9
9
  @base = base
10
- @httprb = HTTP.timeout(:global, **Wework.http_timeout_options)
10
+ @httprb = HTTP.timeout(**Wework.http_timeout_options)
11
11
  @ssl_context = OpenSSL::SSL::SSLContext.new
12
12
  @ssl_context.ssl_version = :TLSv1_client
13
13
  @ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE if skip_verify_ssl
@@ -83,7 +83,8 @@ module Wework
83
83
 
84
84
  class Result < OpenStruct
85
85
  def initialize(data)
86
- data['full_message'] = "(#{data['errcode']}) #{data['errmsg']}"
86
+ data['message'] = GLOBAL_CODES[data['errcode'].to_i]
87
+ data['full_message'] = "#{data['errcode']}:#{data['errmsg']}(#{data['message']})"
87
88
  super data
88
89
  end
89
90
 
@@ -95,7 +96,7 @@ module Wework
95
96
  end
96
97
 
97
98
  def throw_error
98
- raise ResultErrorException.new(full_message) unless success?
99
+ raise ResultErrorException.new(message || errmsg) unless success?
99
100
  end
100
101
 
101
102
  def success?
@@ -1,3 +1,3 @@
1
1
  module Wework
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.2.2'.freeze
3
3
  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: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - seandong
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-25 00:00:00.000000000 Z
11
+ date: 2016-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -123,6 +123,7 @@ files:
123
123
  - lib/wework/cipher.rb
124
124
  - lib/wework/config.rb
125
125
  - lib/wework/engine.rb
126
+ - lib/wework/global_code.rb
126
127
  - lib/wework/js_ticket/redis_store.rb
127
128
  - lib/wework/js_ticket/store.rb
128
129
  - lib/wework/request.rb