class Icapps::Translations::Http
Public Class Methods
authenticated_response(path, is_json = false)
click to toggle source
# File lib/icapps/translations/http.rb, line 10 def authenticated_response(path, is_json = false) uri = URI("#{config.url}/#{path}") puts "[VERBOSE] Connecting to url '#{uri}'.".colorize(:white) if options[:verbose] http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = uri.scheme == 'https' # Disable SSL for now. http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new(uri) request.add_field 'Authorization', "Token token=#{config.project_key}" response = http.request(request) is_json ? JSON.parse(response.body) : response.body end
Private Class Methods
config()
click to toggle source
# File lib/icapps/translations/http.rb, line 30 def config ::Icapps::Translations.config end
options()
click to toggle source
# File lib/icapps/translations/http.rb, line 26 def options ::Icapps::Translations.options end