Class: Readiness::Slack::Messages

Inherits:
Client
  • Object
show all
Defined in:
lib/support_readiness/slack/messages.rb

Overview

Defines the class Emails within the module Readiness::Slack.

Author:

  • Jason Colyer

Since:

  • 1.0.12

Class Method Summary collapse

Methods inherited from Client

auth_error, bad_request_error, convert_actions, convert_conditions, convert_standard_names_to_ids, convert_ticket_form_agent_conditions, convert_ticket_form_brands, convert_ticket_form_end_user_conditions, convert_ticket_form_names_to_ids, convert_view_names_to_ids, convert_view_restrictions, covert_ticket_form_field_ids, create_package!, erb_renderer, handle_request_error, not_found_error, not_processible_error, put_into_archive, recursively_deflate_directory, timestamp_filename, to_clean_json, to_clean_json_with_key, to_hash, to_nearly_clean_json, to_nearly_clean_json_with_key, to_param_string, write_entries

Class Method Details

.create!(client, params) ⇒ Boolean

Posts a message via Slack

Examples:

require 'support_readiness'
config = Readiness::Slack::Configuration.new
config.url = 'https://hooks.slack.com/services/T12345678/A12BC3EFGHI/1aBCDefgHIJKlmnOPQRsT1u2'
client = Readiness::Slack::Client.new(config)
message = 'Jason Test'
pp Readiness::Slack::Messages.create!(client, message)
# => true

Parameters:

  • client (Object)

    An instance of Client

  • params

    This is pretty flexible, can be a simply String to a complex Hash

Returns:

  • (Boolean)

Author:

  • Jason Colyer

Since:

  • 1.0.12



29
30
31
32
33
# File 'lib/support_readiness/slack/messages.rb', line 29

def self.create!(client, params)
  response = client.connection.post '', { text: params }.to_json
  handle_request_error(1, 'Slack', response.status,  { action: 'Create a message', id: client.url }) unless response.status == 200
  true
end