Class: GoogleMobileFriendly::Request
- Inherits:
-
Object
- Object
- GoogleMobileFriendly::Request
- Defined in:
- lib/google_mobile_friendly/request.rb
Constant Summary collapse
- GOOGLE_TEST_REQUEST_URI =
see searchconsole.googleapis.com/$discovery/rest?version=v1 for more info
'https://searchconsole.googleapis.com/v1/urlTestingTools/mobileFriendlyTest:run'
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(url, api_key) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(url, api_key) ⇒ Request
Returns a new instance of Request.
9 10 11 12 |
# File 'lib/google_mobile_friendly/request.rb', line 9 def initialize url, api_key @url = url @api_key = api_key end |
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 |
# 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 |