Class: Yes::Core::ProcessManagers::ServiceClient
- Inherits:
-
Object
- Object
- Yes::Core::ProcessManagers::ServiceClient
- Defined in:
- lib/yes/core/process_managers/service_client.rb
Overview
Handles communication with external command API services.
Instance Method Summary collapse
-
#call(access_token: nil, commands_data: [], channel: nil) ⇒ Faraday::Response
Sends commands to the service.
-
#initialize(service) ⇒ ServiceClient
constructor
Initializes a new ServiceClient.
Constructor Details
#initialize(service) ⇒ ServiceClient
Initializes a new ServiceClient.
19 20 21 22 23 24 |
# File 'lib/yes/core/process_managers/service_client.rb', line 19 def initialize(service) @service_url = ENV.fetch( "#{service.upcase}_SERVICE_URL", "http://#{service.underscore.tr('_', '-')}-cluster-ip-service:3000" ) end |
Instance Method Details
#call(access_token: nil, commands_data: [], channel: nil) ⇒ Faraday::Response
Sends commands to the service.
33 34 35 36 37 38 39 40 |
# File 'lib/yes/core/process_managers/service_client.rb', line 33 def call(access_token: nil, commands_data: [], channel: nil) raise ArgumentError, 'channel and access_token is required' if access_token.nil? || channel.nil? connection(access_token).post do |req| req.url '/v1/commands' req.body = { channel:, commands: commands_data } end end |