Sha256: 0645a8ea481a6419da4efa995cff1a6843db81a47af5dd2c19cd4c59364ace6d

Contents?: true

Size: 439 Bytes

Versions: 1

Compression:

Stored size: 439 Bytes

Contents

module Wechat
  module Api

    class JsTicket
      attr_reader :client, :ticket, :expires_at
      def initialize(client)
        @client = client
      end

      def refresh
        js = client.js_ticket
        @ticket = js[:ticket]
        @expires_at = DateTime.now + Rational(js[:expires_in].to_i, 3600*24)
        self
      end

      def expired?
        expires_at.nil? || DateTime.now > expires_at
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wechat-api-0.4.0 lib/wechat/api/js_ticket.rb