Class: A2A::Operation::SendMessage
- Inherits:
-
Object
- Object
- A2A::Operation::SendMessage
- Includes:
- Executable
- Defined in:
- lib/a2a/operation/send_message.rb,
lib/a2a/operation/send_message/configuration.rb
Defined Under Namespace
Classes: Configuration
Constant Summary collapse
- METHOD =
"SendMessage"
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#tenant ⇒ Object
readonly
Returns the value of attribute tenant.
Instance Method Summary collapse
- #execute_http_json(protocol) ⇒ Object
- #execute_json_rpc(protocol) ⇒ Object
-
#initialize(message, configuration: {}, metadata: nil, tenant: nil) ⇒ SendMessage
constructor
A new instance of SendMessage.
- #params ⇒ Object
Methods included from Executable
Constructor Details
#initialize(message, configuration: {}, metadata: nil, tenant: nil) ⇒ SendMessage
Returns a new instance of SendMessage.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/a2a/operation/send_message.rb', line 14 def initialize(, configuration: {}, metadata: nil, tenant: nil) @message = .is_a?(Message) ? : Message.from_h() @configuration = if configuration.is_a?(Configuration) configuration else Configuration.new(**configuration.transform_keys(&:to_sym)) end @metadata = @tenant = tenant end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
12 13 14 |
# File 'lib/a2a/operation/send_message.rb', line 12 def configuration @configuration end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
12 13 14 |
# File 'lib/a2a/operation/send_message.rb', line 12 def @message end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
12 13 14 |
# File 'lib/a2a/operation/send_message.rb', line 12 def @metadata end |
#tenant ⇒ Object (readonly)
Returns the value of attribute tenant.
12 13 14 |
# File 'lib/a2a/operation/send_message.rb', line 12 def tenant @tenant end |
Instance Method Details
#execute_http_json(protocol) ⇒ Object
32 33 34 |
# File 'lib/a2a/operation/send_message.rb', line 32 def execute_http_json(protocol) parse_result(protocol.post("/message:send", body: params)) end |
#execute_json_rpc(protocol) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/a2a/operation/send_message.rb', line 25 def execute_json_rpc(protocol) raw = protocol.post(METHOD, params) raise A2A.from_json_rpc_error(raw["error"]) if raw["error"] parse_result(Hash(raw["result"])) end |
#params ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/a2a/operation/send_message.rb', line 36 def params p = { "message" => .to_h } config_h = configuration.to_h p["configuration"] = config_h unless config_h.empty? p["metadata"] = if p["tenant"] = tenant if tenant p end |