class TeamsIncomingClients::Teams::Poster
Constants
- CONTENT_TYPE
Attributes
webhook_uri[R]
webhook_url[R]
Public Class Methods
new(webhook_url)
click to toggle source
# File lib/teams_incoming_clients/models/teams/poster.rb, line 8 def initialize(webhook_url) raise ArgumentError.new("Should be set webhook_url. got: #{webhook_url}") if webhook_url.to_s.empty? @webhook_url = webhook_url @webhook_uri = URI.parse(webhook_url) end
Public Instance Methods
post(message)
click to toggle source
@return [Bool]
# File lib/teams_incoming_clients/models/teams/poster.rb, line 16 def post(message) request = build_post_request(message) result = client.request(request) result.code == "200" end
Private Instance Methods
build_post_request(message)
click to toggle source
# File lib/teams_incoming_clients/models/teams/poster.rb, line 35 def build_post_request(message) request = HTTP::Post.new(webhook_uri.request_uri, CONTENT_TYPE) params = { text: message.to_s } request.body = params.to_json request end
client()
click to toggle source
# File lib/teams_incoming_clients/models/teams/poster.rb, line 26 def client @client ||= begin client = HTTP.new(@webhook_uri.host, @webhook_uri.port) client.use_ssl = true client.verify_mode = OpenSSL::SSL::VERIFY_NONE client end end