Class: A2A::Operation::GetTask

Inherits:
Object
  • Object
show all
Includes:
Executable
Defined in:
lib/a2a/operation/get_task.rb

Constant Summary collapse

METHOD =
"GetTask"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Executable

#execute

Constructor Details

#initialize(id:, history_length: nil, tenant: nil) ⇒ GetTask

Returns a new instance of GetTask.



12
13
14
15
16
# File 'lib/a2a/operation/get_task.rb', line 12

def initialize(id:, history_length: nil, tenant: nil)
  @id = id
  @history_length = history_length
  @tenant = tenant
end

Instance Attribute Details

#history_lengthObject (readonly)

Returns the value of attribute history_length.



10
11
12
# File 'lib/a2a/operation/get_task.rb', line 10

def history_length
  @history_length
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/a2a/operation/get_task.rb', line 10

def id
  @id
end

#tenantObject (readonly)

Returns the value of attribute tenant.



10
11
12
# File 'lib/a2a/operation/get_task.rb', line 10

def tenant
  @tenant
end

Instance Method Details

#execute_http_json(protocol) ⇒ Object



25
26
27
28
# File 'lib/a2a/operation/get_task.rb', line 25

def execute_http_json(protocol)
  query = { "historyLength" => history_length }.compact
  Task.from_h(protocol.get("/tasks/#{id}", query: query))
end

#execute_json_rpc(protocol) ⇒ Object



18
19
20
21
22
23
# File 'lib/a2a/operation/get_task.rb', line 18

def execute_json_rpc(protocol)
  raw = protocol.post(METHOD, params)
  raise A2A.from_json_rpc_error(raw["error"]) if raw["error"]

  Task.from_h(Hash(raw["result"]))
end

#paramsObject



30
31
32
33
34
35
36
# File 'lib/a2a/operation/get_task.rb', line 30

def params
  {
    "id" => id,
    "historyLength" => history_length,
    "tenant" => tenant
  }.compact
end