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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(algorithm:, verification_data:, signature:, verified:) ⇒ ServerSignaturePayload

Returns a new instance of ServerSignaturePayload.



109
110
111
112
113
114
# File 'lib/altcha.rb', line 109

def initialize(algorithm:, verification_data:, signature:, verified:)
  @algorithm = algorithm
  @verification_data = verification_data
  @signature = signature
  @verified = verified
end

Instance Attribute Details

#algorithmObject

Returns the value of attribute algorithm.



107
108
109
# File 'lib/altcha.rb', line 107

def algorithm
  @algorithm
end

#signatureObject

Returns the value of attribute signature.



107
108
109
# File 'lib/altcha.rb', line 107

def signature
  @signature
end

#verification_dataObject

Returns the value of attribute verification_data.



107
108
109
# File 'lib/altcha.rb', line 107

def verification_data
  @verification_data
end

#verifiedObject

Returns the value of attribute verified.



107
108
109
# File 'lib/altcha.rb', line 107

def verified
  @verified
end

Class Method Details

.from_json(string) ⇒ ServerSignaturePayload

Creates a ServerSignaturePayload object from a JSON string.

Parameters:

  • string (String)

    JSON string to parse.

Returns:



131
132
133
134
135
136
137
138
139
# File 'lib/altcha.rb', line 131

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

Instance Method Details

#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.



119
120
121
122
123
124
125
126
# File 'lib/altcha.rb', line 119

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