Class: WeixinAuthorize::Client
- Inherits:
-
Object
- Object
- WeixinAuthorize::Client
- Includes:
- Api::Custom, Api::Groups, Api::Media, Api::Menu, Api::Qrcode, Api::User
- Defined in:
- lib/weixin_authorize/client.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#app_id ⇒ Object
Time.now + expires_in.
-
#app_secret ⇒ Object
Time.now + expires_in.
-
#expired_at ⇒ Object
Time.now + expires_in.
-
#redis_key ⇒ Object
Returns the value of attribute redis_key.
-
#storage ⇒ Object
Returns the value of attribute storage.
Instance Method Summary collapse
-
#get_access_token ⇒ Object
return token.
-
#initialize(app_id, app_secret, redis_key = nil) ⇒ Client
constructor
A new instance of Client.
-
#is_valid? ⇒ Boolean
检查appid和app_secret是否有效。.
Methods included from Api::Media
#download_media_url, #upload_media
Methods included from Api::Qrcode
#create_qr_limit_scene, #create_qr_scene, #qr_code_url
Methods included from Api::Groups
#create_group, #get_group_for, #groups, #update_group_for_openid, #update_group_name
Methods included from Api::Custom
#send_image_custom, #send_music_custom, #send_news_custom, #send_text_custom, #send_video_custom, #send_voice_custom
Methods included from Api::Menu
#create_menu, #delete_menu, #menu
Methods included from Api::User
Constructor Details
#initialize(app_id, app_secret, redis_key = nil) ⇒ Client
Returns a new instance of Client.
18 19 20 21 22 23 24 |
# File 'lib/weixin_authorize/client.rb', line 18 def initialize(app_id, app_secret, redis_key=nil) @app_id = app_id @app_secret = app_secret @expired_at = Time.now.to_i @redis_key = security_redis_key((redis_key || "weixin_" + app_id)) @storage = Storage.init_with(self) end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
15 16 17 |
# File 'lib/weixin_authorize/client.rb', line 15 def access_token @access_token end |
#app_id ⇒ Object
Time.now + expires_in
14 15 16 |
# File 'lib/weixin_authorize/client.rb', line 14 def app_id @app_id end |
#app_secret ⇒ Object
Time.now + expires_in
14 15 16 |
# File 'lib/weixin_authorize/client.rb', line 14 def app_secret @app_secret end |
#expired_at ⇒ Object
Time.now + expires_in
14 15 16 |
# File 'lib/weixin_authorize/client.rb', line 14 def expired_at @expired_at end |
#redis_key ⇒ Object
Returns the value of attribute redis_key.
15 16 17 |
# File 'lib/weixin_authorize/client.rb', line 15 def redis_key @redis_key end |
#storage ⇒ Object
Returns the value of attribute storage.
16 17 18 |
# File 'lib/weixin_authorize/client.rb', line 16 def storage @storage end |
Instance Method Details
#get_access_token ⇒ Object
return token
27 28 29 |
# File 'lib/weixin_authorize/client.rb', line 27 def get_access_token @storage.access_token end |
#is_valid? ⇒ Boolean
检查appid和app_secret是否有效。
32 33 34 |
# File 'lib/weixin_authorize/client.rb', line 32 def is_valid? @storage.valid? end |