Class: EmojiDiffer::SlackApi
- Inherits:
-
Struct
- Object
- Struct
- EmojiDiffer::SlackApi
- Defined in:
- lib/emoji_differ/slack_api.rb
Constant Summary collapse
- API_ENDPOINT =
'https://slack.com/api/emoji.list'
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token
5 6 7 |
# File 'lib/emoji_differ/slack_api.rb', line 5 def token @token end |
Instance Method Details
#emoji ⇒ Object
24 25 26 |
# File 'lib/emoji_differ/slack_api.rb', line 24 def emoji EmojiDiffer::List.from_json(raw_response.body) end |
#raw_response ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/emoji_differ/slack_api.rb', line 8 def raw_response @raw_response ||= Net::HTTP.get_response(uri).tap do |handle| if !handle.is_a?(Net::HTTPSuccess) raise "Slack API is out of business today, #{handle.inspect}" end end end |
#uri ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/emoji_differ/slack_api.rb', line 16 def uri URI(API_ENDPOINT).tap do |uri| uri.query = URI.encode_www_form({ token: token, }) end end |