diff --git a/lib/didkit/plc_operation.rb b/lib/didkit/plc_operation.rb index 4b4fbef..4bf8485 100644 --- a/lib/didkit/plc_operation.rb +++ b/lib/didkit/plc_operation.rb @@ -12,7 +12,7 @@ class FormatError < StandardError include AtHandles include Services - attr_reader :json, :did, :created_at, :type, :handles, :services + attr_reader :json, :did, :cid, :created_at, :type, :handles, :services def initialize(json) @json = json @@ -20,6 +20,10 @@ def initialize(json) raise FormatError, "Missing DID: #{json}" if @did.nil? raise FormatError, "Invalid DID: #{@did}" unless @did.is_a?(String) && @did.start_with?('did:') + @cid = json['cid'] + raise FormatError, "Missing CID: #{json}" if @cid.nil? + raise FormatError, "Invalid CID: #{@cid}" unless @cid.is_a?(String) + timestamp = json['createdAt'] raise FormatError, "Missing createdAt: #{json}" if timestamp.nil? raise FormatError, "Invalid createdAt: #{timestamp.inspect}" unless timestamp.is_a?(String)