class GoogleMobileFriendly::Request

Constants

GOOGLE_TEST_REQUEST_URI

see searchconsole.googleapis.com/$discovery/rest?version=v1 for more info

Public Class Methods

new(url, api_key) click to toggle source
# File lib/google_mobile_friendly/request.rb, line 9
def initialize url, api_key
  @url = url
  @api_key = api_key
end

Public Instance Methods

execute() click to toggle source
# File lib/google_mobile_friendly/request.rb, line 14
def execute
  uri = URI(GOOGLE_TEST_REQUEST_URI)
  params = {:key => @api_key}
  uri.query = URI.encode_www_form(params)
  http_result = Net::HTTP.post_form(uri, 'url' => @url)
  response = JSON.parse(http_result.body, symbolize_names: true)
  GoogleMobileFriendly::TestPage.new response
end