class Chainpoint::ProofHandle

Attributes

node_hash_id[R]
uri[R]

Public Class Methods

new(uri, node_hash_id) click to toggle source
# File lib/chainpoint/proof_handle.rb, line 7
def initialize(uri, node_hash_id)
  raise ArgumentError, 'Proof Handle uri not specified' unless uri
  raise ArgumentError, 'Proof Handle node_hash_id not specified' unless node_hash_id

  @uri = uri
  @node_hash_id = node_hash_id
end

Public Instance Methods

proof() click to toggle source
# File lib/chainpoint/proof_handle.rb, line 15
def proof
  data = request_proof
  return unless data['proof']

  Chainpoint::Proof.new(data['proof'], data['hash_id_node'], data['anchors_complete'])
end
to_h() click to toggle source
# File lib/chainpoint/proof_handle.rb, line 22
def to_h
  { uri: @uri, node_hash_id: @node_hash_id }
end

Private Instance Methods

request_proof() click to toggle source
# File lib/chainpoint/proof_handle.rb, line 28
def request_proof
  response = Net::HTTP.get_response(URI(@uri + '/proofs/' + @node_hash_id))
  body = JSON.parse(response.body)
  raise ArgumentError, body['message'] unless response.is_a? Net::HTTPSuccess

  body.first
end