Class: Remitmd::A2ATask

Inherits:
Object
  • Object
show all
Defined in:
lib/remitmd/a2a.rb

Overview

An A2A task returned by message/send, tasks/get, or tasks/cancel.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ A2ATask

Returns a new instance of A2ATask.



90
91
92
93
94
# File 'lib/remitmd/a2a.rb', line 90

def initialize(data)
  @id        = data["id"].to_s
  @status    = A2ATaskStatus.new(data["status"] || {})
  @artifacts = (data["artifacts"] || []).map { |a| A2AArtifact.new(a) }
end

Instance Attribute Details

#artifactsObject (readonly)

Returns the value of attribute artifacts.



88
89
90
# File 'lib/remitmd/a2a.rb', line 88

def artifacts
  @artifacts
end

#idObject (readonly)

Returns the value of attribute id.



88
89
90
# File 'lib/remitmd/a2a.rb', line 88

def id
  @id
end

#statusObject (readonly)

Returns the value of attribute status.



88
89
90
# File 'lib/remitmd/a2a.rb', line 88

def status
  @status
end

Instance Method Details

#tx_hashString?

Extract txHash from task artifacts, if present.

Returns:

  • (String, nil)


98
99
100
101
102
103
104
105
106
# File 'lib/remitmd/a2a.rb', line 98

def tx_hash
  artifacts.each do |artifact|
    artifact.parts.each do |part|
      tx = part.data["txHash"] if part.data.is_a?(Hash)
      return tx if tx.is_a?(String)
    end
  end
  nil
end