Class: Apologist::Agent::Client
- Inherits:
-
Object
- Object
- Apologist::Agent::Client
- Defined in:
- lib/Apologist/agent/client.rb
Instance Method Summary collapse
- #initialize(client:) ⇒ void constructor
-
#pause_agent(request_options: {}, **_params) ⇒ Apologist::Agent::Types::PauseAgentResponse
Pauses the agent globally and fans out pause transition messages to open conversations.
-
#resume_agent(request_options: {}, **_params) ⇒ Apologist::Agent::Types::ResumeAgentResponse
Resumes the agent globally and fans out resume transition messages to open conversations.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/Apologist/agent/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#pause_agent(request_options: {}, **_params) ⇒ Apologist::Agent::Types::PauseAgentResponse
Pauses the agent globally and fans out pause transition messages to open conversations. Requires an API key.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/Apologist/agent/client.rb', line 27 def pause_agent(request_options: {}, **_params) request = Apologist::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "pause", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Apologist::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Apologist::Agent::Types::PauseAgentResponse.load(response.body) else error_class = Apologist::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#resume_agent(request_options: {}, **_params) ⇒ Apologist::Agent::Types::ResumeAgentResponse
Resumes the agent globally and fans out resume transition messages to open conversations. Requires an API key.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/Apologist/agent/client.rb', line 62 def resume_agent(request_options: {}, **_params) request = Apologist::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "resume", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Apologist::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Apologist::Agent::Types::ResumeAgentResponse.load(response.body) else error_class = Apologist::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |