blsm-mp-wx 0.2.3 → 0.2.4

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: 3c76ba513d31eca7548aef7ca0ca085bc0a9b854
4
- data.tar.gz: 3f2ada9a37ec301fee39917490df1b20e8ee2602
3
+ metadata.gz: 9b1e280500c9517d27b7a84c8795028f0c622e76
4
+ data.tar.gz: 97567fef806c56123168565da3ff045ccdc8f50b
5
5
  SHA512:
6
- metadata.gz: a5578473e6ce2823edb4e209671341a1086a59c49ee7518d19f30aa64bba09c3095cf660f897380caaac395644d0f8ebddd1732db2adc9b7f0378c14940aefe7
7
- data.tar.gz: 23815a6e481bd88b7d322517edcf1857d59dc30b76ddcc057f11ad4dd225277c5a42067885fa862b897c5f9bf8875678b04d2185cc408b355de8e0f4af4768c9
6
+ metadata.gz: 2f1fbe6f0b605f0372c0e6e9010f6dbaa45db5f85d2d53c0b51e3302a24e7688d1ec65d82c7639ef3b3fb8b1f8d357669dbd1ba502e030f097b03c9f4d216661
7
+ data.tar.gz: e372200ca0b8f0b20cb9cdc13cddbc368f0222427b17fef11998d7f7a212066270772e68ef303c878cca720b1c2b36ad08b52d8d798a22a85e1f47429170d8fc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blsm-mp-wx (0.1.8)
4
+ blsm-mp-wx (0.2.3)
5
5
 
6
6
  GEM
7
7
  remote: https://ruby.taobao.org/
@@ -1,3 +1,3 @@
1
1
  module BlsmMpWx
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
data/lib/blsm-mp-wx.rb CHANGED
@@ -15,10 +15,13 @@ module BlsmMpWx
15
15
  ERROR_CODES = {
16
16
  404 => {code: 404, msg: '未知的公众号,如有疑问,请联系xi.liu@abcomb.com'}
17
17
  }
18
+
18
19
  class << self
19
20
  attr_accessor :APP_ID
20
21
  attr_accessor :APP_ID_2
21
22
 
23
+ MP_MSG_TYPES = %w(new_order balance score_change distribute custom split_order order todo) #微信公众号消息类型
24
+
22
25
  #根据app_id获取access_token
23
26
  #系统会根据当前的access_token即过期时间,自动更新并返回
24
27
  #开发者无需关心这里的access_token怎么更新
@@ -219,17 +222,30 @@ module BlsmMpWx
219
222
  app_id ||= self.APP_ID
220
223
  return nil unless openid
221
224
  return nil unless content[:touser]==openid
222
- return nil unless %w(new_order balance score_change distribute custom split_order order todo).include?(msg_name)
225
+ return nil unless MP_MSG_TYPES.include?(msg_name)
223
226
  VdMpMsg.create({
224
227
  app_id: app_id,
225
228
  openid: openid,
226
229
  content: content.to_json,
227
230
  msg_name: msg_name,
228
- template_msg: %w(new_order balance score_change distribute split_order order todo).include?(msg_name),
231
+ template_msg: MP_MSG_TYPES.include?(msg_name),
229
232
  status: 'none'
230
233
  })
231
234
  end
232
235
 
236
+
237
+ def create_msg!(app_id=nil, openid, content, msg_name)
238
+ app_id ||= self.APP_ID
239
+ VdMpMsg.create!({
240
+ app_id: app_id,
241
+ openid: openid,
242
+ content: content.to_json,
243
+ msg_name: msg_name,
244
+ template_msg: MP_MSG_TYPES.include?(msg_name),
245
+ status: 'none'
246
+ })
247
+ end
248
+
233
249
  #批量获取公众号的素材列表
234
250
  #=====Parameters
235
251
  # * +app_id+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blsm-mp-wx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - saxer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-11 00:00:00.000000000 Z
11
+ date: 2015-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec