Skip to content

Commit

Permalink
[refactor] remove httparty dependency
Browse files Browse the repository at this point in the history
HTTParty is the only gem dependency of the bot.
I thought it was redundant to maintain a single
dependency especially when it was achievable with
the standard net/http library except that it would
some extra lines of code.
I thought the extra lines of code was worth it
rather than having to maintain a single dependency.
  • Loading branch information
shinenelson committed Nov 21, 2019
1 parent dc537ca commit 5fa8750
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 25 deletions.
3 changes: 0 additions & 3 deletions Gemfile

This file was deleted.

17 changes: 0 additions & 17 deletions Gemfile.lock

This file was deleted.

18 changes: 13 additions & 5 deletions lib/birthday_bot.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'httparty'
require 'net/http'
require 'config_reader'
require 'birthday_reader'

Expand All @@ -17,10 +17,18 @@ def start!
birthdays_today = birthdays[Time.now.month.to_s][Time.now.day.to_s]
users = build_user_list(birthdays_today)
message = "#{users} #{@config.greeting_message}"
HTTParty.post(@config.slack_url, body: { channel: @config.channel_name,
username: @config.bot_name,
text: message,
icon_emoji: @config.bot_emoji }.to_json)
payload = { channel: @config.channel_name,
username: @config.bot_name,
text: message,
icon_emoji: @config.bot_emoji }.to_json

uri = URI.parse(@config.slack_url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri.path)
request.body = payload
http.request(request)
else
puts "Today is a day that no one was born"
end
Expand Down

0 comments on commit 5fa8750

Please sign in to comment.