Sha256: 38bacd4457acfe733a0fc1e4c0cc302b73f26c3394e5ccd11ccff0e41fda72d5
Contents?: true
Size: 885 Bytes
Versions: 1
Compression:
Stored size: 885 Bytes
Contents
# frozen_string_literal: true module Chainpoint class ProofHandle attr_reader :uri, :node_hash_id 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 def proof data = request_proof return unless data['proof'] Chainpoint::Proof.new(data['proof'], data['hash_id_node'], data['anchors_complete']) end def to_h { uri: @uri, node_hash_id: @node_hash_id } end private 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 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
chainpoint-1.1.0 | lib/chainpoint/proof_handle.rb |