Class: WeixinJsSDK::Ticket
- Inherits:
-
Object
- Object
- WeixinJsSDK::Ticket
- Defined in:
- lib/weixin_js_sdk/ticket.rb
Constant Summary collapse
- URI_TEMPLATE =
'https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=%{access_token}&type=jsapi'.freeze
Instance Attribute Summary collapse
-
#expires_in ⇒ Object
readonly
Returns the value of attribute expires_in.
-
#token ⇒ Object
(also: #ticket)
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#fetch ⇒ Object
DEPRECATED: Please use
token
instead. -
#initialize(access_token: '') ⇒ Ticket
constructor
A new instance of Ticket.
Constructor Details
#initialize(access_token: '') ⇒ Ticket
Returns a new instance of Ticket.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/weixin_js_sdk/ticket.rb', line 7 def initialize(access_token: '') url = URI_TEMPLATE % { access_token: access_token } json = Util.get_json(url) @token = json['ticket'] @expires_in = json['expires_in'] end |
Instance Attribute Details
#expires_in ⇒ Object (readonly)
Returns the value of attribute expires_in.
5 6 7 |
# File 'lib/weixin_js_sdk/ticket.rb', line 5 def expires_in @expires_in end |
#token ⇒ Object (readonly) Also known as: ticket
Returns the value of attribute token.
5 6 7 |
# File 'lib/weixin_js_sdk/ticket.rb', line 5 def token @token end |
Instance Method Details
#fetch ⇒ Object
DEPRECATED: Please use token
instead.
19 20 21 22 |
# File 'lib/weixin_js_sdk/ticket.rb', line 19 def fetch warn "[DEPRECATION] `fetch` is deprecated. Please use `token` instead." token end |