class Docproof::Document
Constants
- REGISTER_ENDPOINT
- STATUS_ENDPOINT
Attributes
response[R]
sha256_hash[R]
Public Class Methods
new(sha256_hash)
click to toggle source
# File lib/docproof/document.rb, line 19 def initialize(sha256_hash) @sha256_hash = sha256_hash end
Public Instance Methods
lookup!()
click to toggle source
# File lib/docproof/document.rb, line 37 def lookup! post(STATUS_ENDPOINT) if response['reason'] == 'nonexistent' raise NotFound, "\"#{sha256_hash}\" does not existed." end response end
notarize!()
click to toggle source
# File lib/docproof/document.rb, line 47 def notarize! if response['tx'] raise AlreadyNotarized, "\"#{sha256_hash}\" is already notarized." end PaymentProcessor.new(response).perform! end
register!()
click to toggle source
# File lib/docproof/document.rb, line 23 def register! post(REGISTER_ENDPOINT) if response['reason'] == 'existing' raise Existed, "\"#{sha256_hash}\" already registered" end if response['reason'] && response['reason'][/Invalid/] raise Invalid, "\"#{sha256_hash}\" is invalid" end response end
Private Instance Methods
post(uri)
click to toggle source
# File lib/docproof/document.rb, line 57 def post(uri) @response = JSON.parse( Net::HTTP.post_form(uri, d: sha256_hash).body ).delete_if { |_, value| value == '' } end