Class: Outhad::Integrations::Destination::Slack::Client
- Inherits:
-
DestinationConnector
- Object
- DestinationConnector
- Outhad::Integrations::Destination::Slack::Client
- Includes:
- Core::RateLimiter
- Defined in:
- lib/outhad/integrations/destination/slack/client.rb
Instance Attribute Summary collapse
-
#channel_id ⇒ Object
Returns the value of attribute channel_id.
Instance Method Summary collapse
- #check_connection(connection_config) ⇒ Object
- #discover(_connection_config = nil) ⇒ Object
- #write(sync_config, records, action = "create") ⇒ Object
Instance Attribute Details
#channel_id ⇒ Object
Returns the value of attribute channel_id.
11 12 13 |
# File 'lib/outhad/integrations/destination/slack/client.rb', line 11 def channel_id @channel_id end |
Instance Method Details
#check_connection(connection_config) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/outhad/integrations/destination/slack/client.rb', line 13 def check_connection(connection_config) configure_slack(connection_config[:api_token]) client = ::Slack::Web::Client.new client.auth_test success_status rescue StandardError => e failure_status(e) end |
#discover(_connection_config = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/outhad/integrations/destination/slack/client.rb', line 22 def discover(_connection_config = nil) catalog = build_catalog(load_catalog) catalog. rescue StandardError => e handle_exception(e, { context: "SLACK:DISCOVER:EXCEPTION", type: "error" }) end |
#write(sync_config, records, action = "create") ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/outhad/integrations/destination/slack/client.rb', line 32 def write(sync_config, records, action = "create") # Currently as we only create a message for each record in slack, we are not using actions. # This will be changed in future. @sync_config = sync_config @action = sync_config.stream.action || action connection_config = sync_config.destination.connection_specification.with_indifferent_access configure_slack(connection_config[:api_token]) @client = ::Slack::Web::Client.new @channel_id = connection_config[:channel_id] process_records(records, sync_config.stream) rescue StandardError => e handle_exception(e, { context: "SLACK:WRITE:EXCEPTION", type: "error", sync_id: @sync_config.sync_id, sync_run_id: @sync_config.sync_run_id }) end |