From e611e739d7177fbe5ee404e8b77e00bb584721cc Mon Sep 17 00:00:00 2001 From: Jonathan B Date: Wed, 14 Aug 2019 21:39:18 +0200 Subject: Add require --- src/twitch/rest.cr | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 src/twitch/rest.cr (limited to 'src/twitch/rest.cr') diff --git a/src/twitch/rest.cr b/src/twitch/rest.cr deleted file mode 100644 index 1de8d6f..0000000 --- a/src/twitch/rest.cr +++ /dev/null @@ -1,50 +0,0 @@ -require "http" -require "json" -require "./mappings/*" - -module Twitcr::REST - # Mixin for interacting with Twitch's REST API - SSL_CONTEXT = OpenSSL::SSL::Context::Client.new - API_BASE = "https://api.twitch.tv/helix" - - EMPTY_RESULT = Exception.new("Empty Result") - - # Executes an HTTP request against the API_BASE url - def request(method : String, route : String, version = "5", headers = HTTP::Headers.new, body : String? = nil) - headers["Authorization"] = @token - headers["Client-ID"] = @client_id - - response = HTTP::Client.exec( - method, - API_BASE + route, - headers, - tls: SSL_CONTEXT - ) - - response.body - end - - def get_user_by_login(login : String) - response = request( - "GET", - "/users?login=" + login - ) - - list = UserList.from_json(response) - raise EMPTY_RESULT if list.data.empty? - - list.data.first - end - - def get_user_by_id(id : Int64) - response = request( - "GET", - "/users?id=" + id.to_s - ) - - list = UserList.from_json(response) - raise EMPTY_RESULT if list.data.empty? - - list.data.first - end -end -- cgit v1.2.3