Module: Wechat
- Defined in:
- lib/wechat.rb,
lib/wechat/api.rb,
lib/wechat/cipher.rb,
lib/wechat/mp_api.rb,
lib/wechat/helpers.rb,
lib/wechat/message.rb,
lib/wechat/api_base.rb,
lib/wechat/corp_api.rb,
lib/wechat/responder.rb,
lib/wechat/signature.rb,
lib/wechat/api_loader.rb,
lib/wechat/http_client.rb,
lib/wechat/concern/common.rb,
lib/wechat/controller_api.rb,
lib/wechat/ticket/jsapi_base.rb,
lib/wechat/token/access_token_base.rb,
lib/wechat/token/corp_access_token.rb,
lib/wechat/ticket/corp_jsapi_ticket.rb,
lib/generators/wechat/menu_generator.rb,
lib/wechat/token/public_access_token.rb,
lib/wechat/ticket/public_jsapi_ticket.rb,
lib/generators/wechat/config_generator.rb,
lib/generators/wechat/install_generator.rb,
lib/generators/wechat/session_generator.rb,
lib/generators/wechat/redis_store_generator.rb,
lib/generators/wechat/templates/config/initializers/wechat_redis_store.rb
Defined Under Namespace
Modules: ApiLoader, Cipher, Concern, ControllerApi, Generators, Helpers, Responder, Signature, Ticket, Token
Classes: AccessTokenExpiredError, Api, ApiBase, CorpApi, HttpClient, InvalidCredentialError, Message, MpApi, ResponseError
Class Method Summary
collapse
Class Method Details
.api(account = :default) ⇒ Object
30
31
32
33
|
# File 'lib/wechat.rb', line 30
def self.api(account = :default)
@wechat_apis ||= {}
@wechat_apis[account.to_sym] ||= ApiLoader.with(account: account)
end
|
.config(account = :default) ⇒ Object
26
27
28
|
# File 'lib/wechat.rb', line 26
def self.config(account = :default)
ApiLoader.config(account)
end
|
.decrypt(encrypted_data, session_key, iv) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/wechat.rb', line 39
def self.decrypt(encrypted_data, session_key, iv)
cipher = OpenSSL::Cipher.new('AES-128-CBC')
cipher.decrypt
cipher.key = Base64.decode64(session_key)
cipher.iv = Base64.decode64(iv)
decrypted_data = Base64.decode64(encrypted_data)
JSON.parse(cipher.update(decrypted_data) + cipher.final)
rescue Exception => e
{ 'errcode': 41003, 'errmsg': e.message }
end
|
.redis ⇒ Object
2
3
4
5
|
# File 'lib/generators/wechat/templates/config/initializers/wechat_redis_store.rb', line 2
def self.redis
@redis ||= Redis.new end
|