Class: Altcha::V2::ServerSignaturePayload

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

Overview

Payload received from the ALTCHA backend for server-side verification.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of ServerSignaturePayload.



166
167
168
169
170
171
172
173
# File 'lib/altcha/v2.rb', line 166

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

Instance Attribute Details

#algorithmObject

Returns the value of attribute algorithm.



164
165
166
# File 'lib/altcha/v2.rb', line 164

def algorithm
  @algorithm
end

#api_keyObject

Returns the value of attribute api_key.



164
165
166
# File 'lib/altcha/v2.rb', line 164

def api_key
  @api_key
end

#idObject

Returns the value of attribute id.



164
165
166
# File 'lib/altcha/v2.rb', line 164

def id
  @id
end

#signatureObject

Returns the value of attribute signature.



164
165
166
# File 'lib/altcha/v2.rb', line 164

def signature
  @signature
end

#verification_dataObject

Returns the value of attribute verification_data.



164
165
166
# File 'lib/altcha/v2.rb', line 164

def verification_data
  @verification_data
end

#verifiedObject

Returns the value of attribute verified.



164
165
166
# File 'lib/altcha/v2.rb', line 164

def verified
  @verified
end

Class Method Details

.from_base64(string) ⇒ Object



202
203
204
# File 'lib/altcha/v2.rb', line 202

def self.from_base64(string)
  from_json(Base64.decode64(string))
end

.from_h(data) ⇒ Object



187
188
189
190
191
192
193
194
195
196
# File 'lib/altcha/v2.rb', line 187

def self.from_h(data)
  new(
    algorithm:         data['algorithm'],
    api_key:           data['apiKey'],
    id:                data['id'],
    signature:         data['signature'],
    verification_data: data['verificationData'],
    verified:          data['verified']
  )
end

.from_json(string) ⇒ Object



198
199
200
# File 'lib/altcha/v2.rb', line 198

def self.from_json(string)
  from_h(JSON.parse(string))
end

Instance Method Details

#to_json(options = {}) ⇒ Object



175
176
177
178
179
180
181
182
183
184
185
# File 'lib/altcha/v2.rb', line 175

def to_json(options = {})
  h = {
    'algorithm'        => algorithm,
    'signature'        => signature,
    'verificationData' => verification_data,
    'verified'         => verified,
  }
  h['apiKey'] = api_key unless api_key.nil?
  h['id']     = id      unless id.nil?
  h.to_json(options)
end