Class: Altcha::V2::Payload
- Inherits:
-
Object
- Object
- Altcha::V2::Payload
- Defined in:
- lib/altcha/v2.rb
Overview
The client payload submitted after solving a v2 challenge.
Instance Attribute Summary collapse
-
#challenge ⇒ Object
Returns the value of attribute challenge.
-
#solution ⇒ Object
Returns the value of attribute solution.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(challenge:, solution:) ⇒ Payload
constructor
A new instance of Payload.
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(challenge:, solution:) ⇒ Payload
Returns a new instance of Payload.
128 129 130 131 |
# File 'lib/altcha/v2.rb', line 128 def initialize(challenge:, solution:) @challenge = challenge @solution = solution end |
Instance Attribute Details
#challenge ⇒ Object
Returns the value of attribute challenge.
126 127 128 |
# File 'lib/altcha/v2.rb', line 126 def challenge @challenge end |
#solution ⇒ Object
Returns the value of attribute solution.
126 127 128 |
# File 'lib/altcha/v2.rb', line 126 def solution @solution end |
Class Method Details
.from_json(string) ⇒ Object
137 138 139 140 141 142 143 144 145 146 |
# File 'lib/altcha/v2.rb', line 137 def self.from_json(string) data = JSON.parse(string) new( challenge: Challenge.from_h(data['challenge']), solution: Solution.new( counter: data['solution']['counter'], derived_key: data['solution']['derivedKey'] ) ) end |
Instance Method Details
#to_json(options = {}) ⇒ Object
133 134 135 |
# File 'lib/altcha/v2.rb', line 133 def to_json( = {}) { 'challenge' => challenge.to_h, 'solution' => solution.to_h }.to_json() end |