class YubiOATH::Put

Public Class Methods

new(card) click to toggle source
# File lib/yubioath/put.rb, line 8
def initialize(card)
  @card = card
end

Public Instance Methods

call(name:, secret:, algorithm:, type:, digits:) click to toggle source
# File lib/yubioath/put.rb, line 12
def call(name:, secret:, algorithm:, type:, digits:)
  data = Request::Data.new(
    name: name,
    oath_type: TYPES.fetch(type),
    algorithm: ALGORITHMS.fetch(algorithm),
    digits: digits,
    secret: secret,
  )
  request = Request.new(data: data.to_binary_s)
  bytes = @card.transmit(request.to_binary_s)
  Response.read(bytes).success?
end