class Poke::API::Auth::Ticket
Attributes
ends[R]
expire[R]
start[R]
Public Class Methods
new()
click to toggle source
# File lib/poke-api/auth/ticket.rb, line 8 def initialize @expire = nil @start = nil @ends = nil end
Public Instance Methods
get_ticket()
click to toggle source
# File lib/poke-api/auth/ticket.rb, line 30 def get_ticket return false unless check_ticket true end
has_ticket?()
click to toggle source
# File lib/poke-api/auth/ticket.rb, line 14 def has_ticket? return true if @start && @ends && @expire false end
is_new_ticket?(new_ticket_time)
click to toggle source
# File lib/poke-api/auth/ticket.rb, line 25 def is_new_ticket?(new_ticket_time) return true unless @expire && new_ticket_time > @expire false end
set_ticket(auth)
click to toggle source
# File lib/poke-api/auth/ticket.rb, line 19 def set_ticket(auth) @expire = auth[:expire_timestamp_ms] @start = auth[:start] @ends = auth[:end] end
Private Instance Methods
check_ticket()
click to toggle source
# File lib/poke-api/auth/ticket.rb, line 37 def check_ticket return false unless has_ticket? now = Helpers.fetch_time if now < (@expire - 10000) duration = format('%02d:%02d:%02d', *Helpers.format_time_diff(now, @expire)) logger.info "[+] Auth ticket is valid for #{duration}" return true end @expire, @start, @ends = nil logger.info '[+] Removed expired auth ticket' false end