class Telegram::Auth::Fields

Public Class Methods

new(hash) click to toggle source
# File lib/telegram/auth/fields.rb, line 3
def initialize(hash)
  @hash = hash
end

Public Instance Methods

expired?(time = Time.now.to_i) click to toggle source
# File lib/telegram/auth/fields.rb, line 7
def expired?(time = Time.now.to_i)
  return false unless Configuration.instance.auth_expires_in.present?
  time > @hash[:auth_date] + Configuration.instance.auth_expires_in
end
hash() click to toggle source
# File lib/telegram/auth/fields.rb, line 12
def hash
  token_sha = OpenSSL::Digest::SHA256.new.digest(Configuration.instance.token)
  OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new, token_sha, to_s)
end
to_s() click to toggle source
# File lib/telegram/auth/fields.rb, line 17
def to_s
  permitted_hash = @hash.slice(:auth_date, :id, :username, :first_name, :last_name, :photo_url)
  permitted_hash.map { |k,v| "#{k}=#{v}" }.sort.join("\n")
end