Class: A2A::Protocol::JsonRpc
- Inherits:
-
Object
- Object
- A2A::Protocol::JsonRpc
- Defined in:
- lib/a2a/protocol/json_rpc.rb,
lib/a2a/protocol/json_rpc/transport.rb
Defined Under Namespace
Classes: Transport
Instance Attribute Summary collapse
-
#extensions ⇒ Object
readonly
Returns the value of attribute extensions.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(url:, version: Versioning::CURRENT, headers: {}, extensions: [], transport: Transport.new) ⇒ JsonRpc
constructor
A new instance of JsonRpc.
- #post(method, params = {}) ⇒ Object
- #stream(method, params = {}) ⇒ Object
Constructor Details
#initialize(url:, version: Versioning::CURRENT, headers: {}, extensions: [], transport: Transport.new) ⇒ JsonRpc
Returns a new instance of JsonRpc.
11 12 13 14 15 16 17 18 |
# File 'lib/a2a/protocol/json_rpc.rb', line 11 def initialize(url:, version: Versioning::CURRENT, headers: {}, extensions: [], transport: Transport.new) @url = url @version = version @headers = headers @extensions = extensions @transport = transport @built_headers = build_headers end |
Instance Attribute Details
#extensions ⇒ Object (readonly)
Returns the value of attribute extensions.
9 10 11 |
# File 'lib/a2a/protocol/json_rpc.rb', line 9 def extensions @extensions end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
9 10 11 |
# File 'lib/a2a/protocol/json_rpc.rb', line 9 def headers @headers end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
9 10 11 |
# File 'lib/a2a/protocol/json_rpc.rb', line 9 def url @url end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
9 10 11 |
# File 'lib/a2a/protocol/json_rpc.rb', line 9 def version @version end |
Instance Method Details
#post(method, params = {}) ⇒ Object
20 21 22 |
# File 'lib/a2a/protocol/json_rpc.rb', line 20 def post(method, params = {}) @transport.post(@url, body: build_envelope(method, params), headers: @built_headers) end |
#stream(method, params = {}) ⇒ Object
24 25 26 27 |
# File 'lib/a2a/protocol/json_rpc.rb', line 24 def stream(method, params = {}, &) sse_headers = @built_headers.merge("Accept" => "text/event-stream") @transport.stream(@url, headers: sse_headers, method: :post, body: build_envelope(method, params), &) end |