Class: Prove::Verification
- Inherits:
-
Object
- Object
- Prove::Verification
- Defined in:
- lib/prove/verification.rb
Constant Summary collapse
- ACCESSORS =
[:id, :tel, :text, :call, :verified]
Class Method Summary collapse
- .create(*args) ⇒ Object
- .from_json(verification_hash) ⇒ Object
- .from_json_array(verifications) ⇒ Object
- .list ⇒ Object
- .retrieve(*args) ⇒ Object
- .verify(*args) ⇒ Object
Instance Method Summary collapse
-
#initialize(attr_hash = {}) ⇒ Verification
constructor
A new instance of Verification.
- #retrieve ⇒ Object
- #to_json ⇒ Object
- #verify(*args) ⇒ Object
Constructor Details
#initialize(attr_hash = {}) ⇒ Verification
Returns a new instance of Verification.
6 7 8 9 10 |
# File 'lib/prove/verification.rb', line 6 def initialize(attr_hash={}) attr_hash.each do |key, val| self.instance_variable_set("@#{key}", val) end end |
Class Method Details
.create(*args) ⇒ Object
12 13 14 15 16 |
# File 'lib/prove/verification.rb', line 12 def self.create(*args) = args.last.is_a?(Hash) ? args.pop : {} tel = args[0] || [:tel] from_json Prove.client.post('/api/v1/verify', {tel: tel}).body end |
.from_json(verification_hash) ⇒ Object
54 55 56 |
# File 'lib/prove/verification.rb', line 54 def self.from_json(verification_hash) return Verification.new(verification_hash) end |
.from_json_array(verifications) ⇒ Object
58 59 60 |
# File 'lib/prove/verification.rb', line 58 def self.from_json_array(verifications) return verifications.map{|attr_hash| Verification.new(attr_hash)} end |
.list ⇒ Object
18 19 20 |
# File 'lib/prove/verification.rb', line 18 def self.list from_json_array Prove.client.get('/api/v1/verify').body end |
Instance Method Details
#retrieve ⇒ Object
42 43 44 |
# File 'lib/prove/verification.rb', line 42 def retrieve self.class.retrieve(self.id) end |
#to_json ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/prove/verification.rb', line 46 def to_json return {id: self.id, tel: self.tel, text: self.text, call: self.call, verified: self.verified}.to_json end |
#verify(*args) ⇒ Object
36 37 38 39 40 |
# File 'lib/prove/verification.rb', line 36 def verify(*args) = args.last.is_a?(Hash) ? args.pop : {} pin = args[0] || [:pin] self.class.verify(self.id, pin) end |