Class: TruthID::AuthChallenge

Inherits:
Object
  • Object
show all
Defined in:
lib/truthid/types.rb

Overview

AuthChallenge precisa de to_h com camelCase — por isso classe manual, não Struct

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, nonce:, issued_at:, origin:) ⇒ AuthChallenge

Returns a new instance of AuthChallenge.



8
9
10
11
12
13
# File 'lib/truthid/types.rb', line 8

def initialize(type:, nonce:, issued_at:, origin:)
  @type      = type
  @nonce     = nonce
  @issued_at = issued_at
  @origin    = origin
end

Instance Attribute Details

#issued_atObject (readonly)

Returns the value of attribute issued_at.



6
7
8
# File 'lib/truthid/types.rb', line 6

def issued_at
  @issued_at
end

#nonceObject (readonly)

Returns the value of attribute nonce.



6
7
8
# File 'lib/truthid/types.rb', line 6

def nonce
  @nonce
end

#originObject (readonly)

Returns the value of attribute origin.



6
7
8
# File 'lib/truthid/types.rb', line 6

def origin
  @origin
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/truthid/types.rb', line 6

def type
  @type
end

Instance Method Details

#to_hObject

JSON.generate(challenge.to_h) → formato exato que o mobile assina



16
17
18
# File 'lib/truthid/types.rb', line 16

def to_h
  { "type" => @type, "nonce" => @nonce, "issuedAt" => @issued_at, "origin" => @origin }
end

#to_json(*args) ⇒ Object



20
21
22
# File 'lib/truthid/types.rb', line 20

def to_json(*args)
  JSON.generate(to_h)
end