weixin_rails_middleware 1.2.4 → 1.2.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
  SHA1:
3
- metadata.gz: f46938e87116ddd8d66f7862ec7a695463b4f989
4
- data.tar.gz: 63672ab0ec80e69d443a58128db43a2a4f424baf
3
+ metadata.gz: 521f1caac9da8ab56239995a813114366042f253
4
+ data.tar.gz: 015b026de7eb83c13d4f9cd53bb7ed13982d72de
5
5
  SHA512:
6
- metadata.gz: be1a1c9bc714f6b654dcee5d187057ae7c6ea4dbdb6e6352b19e14add8aabc34f4b6b6814d4c1d99c8fcfc44974458c0cd74e29593bd920772efd9ea2f593bf8
7
- data.tar.gz: 2c36247b32a22c04f817fca2e73e640706852a29c405c26f4d8e1eba3fd988a983e2279a3bcc22435b087a7258b2127634eb0720ec509e4b086f5139525a2068
6
+ metadata.gz: 063ae33e0a11cb94c92a753818727ffbd6f08d8423360d934de4e7c21d8a035633193f81d70d2d832ee46f3dff32d65fb23dcc60303a1663444f558e4d590d62
7
+ data.tar.gz: 33fd80806fc3210db265bdb5b0847fcd2cff95b205ac501274411e78b4e9e83d799c9507ab7ac746f8fd2d6d87aaaf294932e5632e73e4d23bac8a99de400887
@@ -16,4 +16,8 @@ WeixinRailsMiddleware.configure do |config|
16
16
  # using to weixin server url to validate the token can be trusted.
17
17
  # config.weixin_secret_string = '<%= WeiXinUniqueToken.generate(generator: :urlsafe_base64, size: 24) %>'
18
18
 
19
+ ## You can custom your adapter to validate your weixin account ##
20
+ # Wiki https://github.com/lanrion/weixin_rails_middleware/wiki/Custom-Adapter
21
+ # config.custom_adapter = "MyCustomAdapter"
22
+
19
23
  end
@@ -18,6 +18,12 @@ module WeixinRailsMiddleware
18
18
  end
19
19
 
20
20
  def self.init_with(weixin_params)
21
+ if custom_adapter.present?
22
+ if custom_adapter.superclass != self
23
+ raise "#{custcurrent_weixin_tokenom_adapter.to_s} must inherite WexinAdapter"
24
+ end
25
+ return custom_adapter.new(weixin_params)
26
+ end
21
27
  if weixin_token_string.present?
22
28
  SinglePublicAccount.new(weixin_params)
23
29
  else
@@ -17,6 +17,7 @@ module WeixinRailsMiddleware
17
17
  class Configuration
18
18
  attr_accessor :public_account_class
19
19
  attr_accessor :weixin_secret_string, :weixin_token_string
20
+ attr_accessor :custom_adapter
20
21
  end
21
22
 
22
23
  module ConfigurationHelpers
@@ -38,7 +39,11 @@ module WeixinRailsMiddleware
38
39
  if token_model.blank?
39
40
  raise "You need to config `public_account_class` in 'config/initializers/weixin_rails_middleware.rb'"
40
41
  end
41
- @token_model_class_name ||= token_model.constantize
42
+ @token_model_class_name ||= token_model.to_s.constantize
43
+ end
44
+
45
+ def custom_adapter
46
+ @custom_adapter ||= WeixinRailsMiddleware.config.custom_adapter.to_s.constantize
42
47
  end
43
48
  end
44
49
  end
@@ -105,5 +105,12 @@ module WeixinRailsMiddleware
105
105
  message.to_xml
106
106
  end
107
107
 
108
+
109
+ def reply_transfer_customer_service_message(from=nil, to=nil)
110
+ message = TransferCustomerServiceReplyMessage.new
111
+ message.FromUserName = from || @weixin_message.ToUserName
112
+ message.ToUserName = to || @weixin_message.FromUserName
113
+ message.to_xml
114
+ end
108
115
  end
109
116
  end
@@ -179,4 +179,17 @@ module WeixinRailsMiddleware
179
179
  end
180
180
  end
181
181
 
182
+ # <xml>
183
+ # <ToUserName><![CDATA[touser]]></ToUserName>
184
+ # <FromUserName><![CDATA[fromuser]]></FromUserName>
185
+ # <CreateTime>1399197672</CreateTime>
186
+ # <MsgType><![CDATA[transfer_customer_service]]></MsgType>
187
+ # </xml>
188
+ class TransferCustomerServiceReplyMessage < ReplyMessage
189
+ def initialize
190
+ super
191
+ @MsgType = 'transfer_customer_service'
192
+ end
193
+ end
194
+
182
195
  end
@@ -1,3 +1,3 @@
1
1
  module WeixinRailsMiddleware
2
- VERSION = "1.2.4"
2
+ VERSION = "1.2.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weixin_rails_middleware
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - lanrion
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-30 00:00:00.000000000 Z
11
+ date: 2014-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -132,3 +132,4 @@ signing_key:
132
132
  specification_version: 4
133
133
  summary: weixin_rails_middleware for integration weixin
134
134
  test_files: []
135
+ has_rdoc: