class SlackMessenger::Api
Public Class Methods
new(endpoint)
click to toggle source
# File lib/slack_messenger/api.rb, line 6 def initialize(endpoint) @endpoint = endpoint end
send(message, api = nil)
click to toggle source
# File lib/slack_messenger/api.rb, line 14 def self.send(message, api = nil) if api.nil? api = SlackMessenger.default_api end raise ApiNotSetError.new if api.nil? raise EndpointNotSetError.new if api.endpoint.nil? || api.endpoint == "" result = HTTParty.post(api.endpoint, body: message.as_json.to_json) case result.code when 200 true else raise SendError.new result.code end end
Public Instance Methods
endpoint()
click to toggle source
# File lib/slack_messenger/api.rb, line 10 def endpoint @endpoint end