Class: TwitterJekyll::ApiClient Private

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-twitter-plugin.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Wrapper around an API

Instance Method Summary collapse

Instance Method Details

#fetch(api_request) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Perform API request; return hash with html content



71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/jekyll-twitter-plugin.rb', line 71

def fetch(api_request)
  uri = api_request.to_uri
  response = Net::HTTP.start(uri.host, use_ssl: api_request.ssl?) do |http|
    http.read_timeout = 5
    http.open_timeout = 5
    http.get uri.request_uri, REQUEST_HEADERS
  end

  handle_response(api_request, response)
rescue Timeout::Error => e
  ErrorResponse.new(api_request, e.class.name).to_h
end