Class: Altcha::V1::Payload

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

Overview

The client-submitted solution payload.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(algorithm:, challenge:, number:, salt:, signature:) ⇒ Payload

Returns a new instance of Payload.



67
68
69
70
71
72
73
# File 'lib/altcha/v1.rb', line 67

def initialize(algorithm:, challenge:, number:, salt:, signature:)
  @algorithm = algorithm
  @challenge = challenge
  @number    = number
  @salt      = salt
  @signature = signature
end

Instance Attribute Details

#algorithmObject

Returns the value of attribute algorithm.



65
66
67
# File 'lib/altcha/v1.rb', line 65

def algorithm
  @algorithm
end

#challengeObject

Returns the value of attribute challenge.



65
66
67
# File 'lib/altcha/v1.rb', line 65

def challenge
  @challenge
end

#numberObject

Returns the value of attribute number.



65
66
67
# File 'lib/altcha/v1.rb', line 65

def number
  @number
end

#saltObject

Returns the value of attribute salt.



65
66
67
# File 'lib/altcha/v1.rb', line 65

def salt
  @salt
end

#signatureObject

Returns the value of attribute signature.



65
66
67
# File 'lib/altcha/v1.rb', line 65

def signature
  @signature
end

Class Method Details

.from_json(string) ⇒ Object



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

def self.from_json(string)
  data = JSON.parse(string)
  new(
    algorithm: data['algorithm'],
    challenge: data['challenge'],
    number:    data['number'],
    salt:      data['salt'],
    signature: data['signature']
  )
end

Instance Method Details

#to_json(options = {}) ⇒ Object



75
76
77
78
79
80
81
82
83
# File 'lib/altcha/v1.rb', line 75

def to_json(options = {})
  {
    algorithm: @algorithm,
    challenge: @challenge,
    number:    @number,
    salt:      @salt,
    signature: @signature
  }.to_json(options)
end