Class: TeamsIncomingClients::Teams::Poster

Inherits:
Object
  • Object
show all
Includes:
Net
Defined in:
lib/teams_incoming_clients/models/teams/poster.rb

Constant Summary collapse

CONTENT_TYPE =
{ 'Content-Type' => 'application/json' }

Instance Method Summary collapse

Constructor Details

#initialize(webhook_url) ⇒ Poster

Returns a new instance of Poster.

Raises:

  • (ArgumentError)


8
9
10
11
12
13
# 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

Instance Method Details

#post(message) ⇒ Bool

Returns:

  • (Bool)


16
17
18
19
20
21
# 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