PagespeedInsights.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. /*
  3. * Copyright 2014 Google Inc.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  6. * use this file except in compliance with the License. You may obtain a copy of
  7. * the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  14. * License for the specific language governing permissions and limitations under
  15. * the License.
  16. */
  17. namespace Google\Service;
  18. use Google\Client;
  19. /**
  20. * Service definition for PagespeedInsights (v5).
  21. *
  22. * <p>
  23. * The PageSpeed Insights API lets you analyze the performance of your website
  24. * with a simple API. It offers tailored suggestions for how you can optimize
  25. * your site, and lets you easily integrate PageSpeed Insights analysis into
  26. * your development tools and workflow.</p>
  27. *
  28. * <p>
  29. * For more information about this service, see the API
  30. * <a href="https://developers.google.com/speed/docs/insights/v5/about" target="_blank">Documentation</a>
  31. * </p>
  32. *
  33. * @author Google, Inc.
  34. */
  35. class PagespeedInsights extends \Google\Service
  36. {
  37. /** Associate you with your personal info on Google. */
  38. const OPENID =
  39. "openid";
  40. public $pagespeedapi;
  41. public $rootUrlTemplate;
  42. /**
  43. * Constructs the internal representation of the PagespeedInsights service.
  44. *
  45. * @param Client|array $clientOrConfig The client used to deliver requests, or a
  46. * config array to pass to a new Client instance.
  47. * @param string $rootUrl The root URL used for requests to the service.
  48. */
  49. public function __construct($clientOrConfig = [], $rootUrl = null)
  50. {
  51. parent::__construct($clientOrConfig);
  52. $this->rootUrl = $rootUrl ?: 'https://pagespeedonline.googleapis.com/';
  53. $this->rootUrlTemplate = $rootUrl ?: 'https://pagespeedonline.UNIVERSE_DOMAIN/';
  54. $this->servicePath = '';
  55. $this->batchPath = 'batch';
  56. $this->version = 'v5';
  57. $this->serviceName = 'pagespeedonline';
  58. $this->pagespeedapi = new PagespeedInsights\Resource\Pagespeedapi(
  59. $this,
  60. $this->serviceName,
  61. 'pagespeedapi',
  62. [
  63. 'methods' => [
  64. 'runpagespeed' => [
  65. 'path' => 'pagespeedonline/v5/runPagespeed',
  66. 'httpMethod' => 'GET',
  67. 'parameters' => [
  68. 'url' => [
  69. 'location' => 'query',
  70. 'type' => 'string',
  71. 'required' => true,
  72. ],
  73. 'captchaToken' => [
  74. 'location' => 'query',
  75. 'type' => 'string',
  76. ],
  77. 'category' => [
  78. 'location' => 'query',
  79. 'type' => 'string',
  80. 'repeated' => true,
  81. ],
  82. 'locale' => [
  83. 'location' => 'query',
  84. 'type' => 'string',
  85. ],
  86. 'strategy' => [
  87. 'location' => 'query',
  88. 'type' => 'string',
  89. ],
  90. 'utm_campaign' => [
  91. 'location' => 'query',
  92. 'type' => 'string',
  93. ],
  94. 'utm_source' => [
  95. 'location' => 'query',
  96. 'type' => 'string',
  97. ],
  98. ],
  99. ],
  100. ]
  101. ]
  102. );
  103. }
  104. }
  105. // Adding a class alias for backwards compatibility with the previous class name.
  106. class_alias(PagespeedInsights::class, 'Google_Service_PagespeedInsights');