Class: Altcha::ServerSignaturePayload

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

Overview

Class representing the payload for server signatures.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#algorithmObject

Returns the value of attribute algorithm.



82
83
84
# File 'lib/altcha.rb', line 82

def algorithm
  @algorithm
end

#signatureObject

Returns the value of attribute signature.



82
83
84
# File 'lib/altcha.rb', line 82

def signature
  @signature
end

#verification_dataObject

Returns the value of attribute verification_data.



82
83
84
# File 'lib/altcha.rb', line 82

def verification_data
  @verification_data
end

#verifiedObject

Returns the value of attribute verified.



82
83
84
# File 'lib/altcha.rb', line 82

def verified
  @verified
end

Instance Method Details

#from_json(string) ⇒ ServerSignaturePayload

Creates a ServerSignaturePayload object from a JSON string.

Parameters:

  • string (String)

    JSON string to parse.

Returns:



99
100
101
102
# File 'lib/altcha.rb', line 99

def from_json(string)
  data = JSON.parse(string)
  new data['algorithm'], data['verificationData'], data['signature'], data['verified']
end

#to_json(options = {}) ⇒ String

Converts the ServerSignaturePayload object to a JSON string.

Parameters:

  • options (Hash) (defaults to: {})

    options to customize JSON encoding.

Returns:

  • (String)

    JSON representation of the ServerSignaturePayload object.



87
88
89
90
91
92
93
94
# File 'lib/altcha.rb', line 87

def to_json(options = {})
  {
    algorithm: @algorithm,
    verificationData: @verification_data,
    signature: @signature,
    verified: @verified
  }.to_json(options)
end