Class: BlsmMpWx::VdMpWx
- Inherits:
-
BaseRecord
- Object
- ActiveRecord::Base
- BaseRecord
- BlsmMpWx::VdMpWx
- Defined in:
- lib/blsm-mp-wx/model/vd_mp_wx.rb
Instance Method Summary collapse
-
#access_token_expired? ⇒ Boolean
判断access_token是否过期了.
-
#js_api_ticket_expired? ⇒ Boolean
判断js_api_ticket是否过期了.
-
#save_access_token(access_token, expires_in) ⇒ Object
保存token的有效期.
-
#save_js_api_ticket(js_api_ticket, expires_in) ⇒ Object
保存js_api_ticket.
Instance Method Details
#access_token_expired? ⇒ Boolean
判断access_token是否过期了
8 9 10 11 12 |
# File 'lib/blsm-mp-wx/model/vd_mp_wx.rb', line 8 def access_token_expired? return true unless self.access_token return true unless self.access_token_expire DateTime.now.to_time > self.access_token_expire.to_time end |
#js_api_ticket_expired? ⇒ Boolean
判断js_api_ticket是否过期了
15 16 17 18 19 |
# File 'lib/blsm-mp-wx/model/vd_mp_wx.rb', line 15 def js_api_ticket_expired? return true unless self.js_api_ticket return true unless self.js_api_ticket_expire DateTime.now.to_time > self.js_api_ticket_expire.to_time end |
#save_access_token(access_token, expires_in) ⇒ Object
保存token的有效期
22 23 24 25 26 27 |
# File 'lib/blsm-mp-wx/model/vd_mp_wx.rb', line 22 def save_access_token(access_token, expires_in) update_attributes({ access_token: access_token, access_token_expire: Time.at(DateTime.now.to_time.to_i + expires_in.to_i/4) }) end |
#save_js_api_ticket(js_api_ticket, expires_in) ⇒ Object
保存js_api_ticket
30 31 32 33 34 35 |
# File 'lib/blsm-mp-wx/model/vd_mp_wx.rb', line 30 def save_js_api_ticket(js_api_ticket, expires_in) update_attributes({ js_api_ticket: js_api_ticket, js_api_ticket_expire: Time.at(DateTime.now.to_time.to_i + expires_in.to_i/4) }) end |