OLD | NEW |
(Empty) | |
| 1 library googleapis.pagespeedonline.v1; |
| 2 |
| 3 import "dart:core" as core; |
| 4 import "dart:collection" as collection; |
| 5 import "dart:async" as async; |
| 6 import "dart:convert" as convert; |
| 7 |
| 8 import "package:crypto/crypto.dart" as crypto; |
| 9 import 'package:http/http.dart' as http; |
| 10 import '../src/common_internal.dart' as common_internal; |
| 11 import '../common/common.dart' as common; |
| 12 |
| 13 export '../common/common.dart' show ApiRequestError; |
| 14 export '../common/common.dart' show DetailedApiRequestError; |
| 15 |
| 16 /** |
| 17 * Lets you analyze the performance of a web page and get tailored suggestions |
| 18 * to make that page faster. |
| 19 */ |
| 20 class PagespeedonlineApi { |
| 21 |
| 22 final common_internal.ApiRequester _requester; |
| 23 |
| 24 PagespeedapiResourceApi get pagespeedapi => new PagespeedapiResourceApi(_reque
ster); |
| 25 |
| 26 PagespeedonlineApi(http.Client client) : |
| 27 _requester = new common_internal.ApiRequester(client, "https://www.googlea
pis.com/", "/pagespeedonline/v1/"); |
| 28 } |
| 29 |
| 30 |
| 31 /** Not documented yet. */ |
| 32 class PagespeedapiResourceApi { |
| 33 final common_internal.ApiRequester _requester; |
| 34 |
| 35 PagespeedapiResourceApi(common_internal.ApiRequester client) : |
| 36 _requester = client; |
| 37 |
| 38 /** |
| 39 * Runs Page Speed analysis on the page at the specified URL, and returns a |
| 40 * Page Speed score, a list of suggestions to make that page faster, and other |
| 41 * information. |
| 42 * |
| 43 * Request parameters: |
| 44 * |
| 45 * [url] - The URL to fetch and analyze |
| 46 * Value must have pattern "http(s)?://.*". |
| 47 * |
| 48 * [filterThirdPartyResources] - Indicates if third party resources should be |
| 49 * filtered out before PageSpeed analysis. |
| 50 * |
| 51 * [locale] - The locale used to localize formatted results |
| 52 * Value must have pattern "[a-zA-Z]+(_[a-zA-Z]+)?". |
| 53 * |
| 54 * [rule] - A Page Speed rule to run; if none are given, all rules are run |
| 55 * Value must have pattern "[a-zA-Z]+". |
| 56 * |
| 57 * [screenshot] - Indicates if binary data containing a screenshot should be |
| 58 * included |
| 59 * |
| 60 * [strategy] - The analysis strategy to use |
| 61 * Possible string values are: |
| 62 * - "desktop" : Fetch and analyze the URL for desktop browsers |
| 63 * - "mobile" : Fetch and analyze the URL for mobile devices |
| 64 * |
| 65 * Completes with a [Result]. |
| 66 * |
| 67 * Completes with a [common.ApiRequestError] if the API endpoint returned an |
| 68 * error. |
| 69 * |
| 70 * If the used [http.Client] completes with an error when making a REST call, |
| 71 * this method will complete with the same error. |
| 72 */ |
| 73 async.Future<Result> runpagespeed(core.String url, {core.bool filterThirdParty
Resources, core.String locale, core.List<core.String> rule, core.bool screenshot
, core.String strategy}) { |
| 74 var _url = null; |
| 75 var _queryParams = new core.Map(); |
| 76 var _uploadMedia = null; |
| 77 var _uploadOptions = null; |
| 78 var _downloadOptions = common.DownloadOptions.Metadata; |
| 79 var _body = null; |
| 80 |
| 81 if (url == null) { |
| 82 throw new core.ArgumentError("Parameter url is required."); |
| 83 } |
| 84 _queryParams["url"] = [url]; |
| 85 if (filterThirdPartyResources != null) { |
| 86 _queryParams["filter_third_party_resources"] = ["${filterThirdPartyResourc
es}"]; |
| 87 } |
| 88 if (locale != null) { |
| 89 _queryParams["locale"] = [locale]; |
| 90 } |
| 91 if (rule != null) { |
| 92 _queryParams["rule"] = rule; |
| 93 } |
| 94 if (screenshot != null) { |
| 95 _queryParams["screenshot"] = ["${screenshot}"]; |
| 96 } |
| 97 if (strategy != null) { |
| 98 _queryParams["strategy"] = [strategy]; |
| 99 } |
| 100 |
| 101 |
| 102 _url = 'runPagespeed'; |
| 103 |
| 104 var _response = _requester.request(_url, |
| 105 "GET", |
| 106 body: _body, |
| 107 queryParams: _queryParams, |
| 108 uploadOptions: _uploadOptions, |
| 109 uploadMedia: _uploadMedia, |
| 110 downloadOptions: _downloadOptions); |
| 111 return _response.then((data) => new Result.fromJson(data)); |
| 112 } |
| 113 |
| 114 } |
| 115 |
| 116 |
| 117 |
| 118 /** Not documented yet. */ |
| 119 class ResultFormattedResultsRuleResultsValueUrlBlocksHeaderArgs { |
| 120 /** |
| 121 * Type of argument. One of URL, STRING_LITERAL, INT_LITERAL, BYTES, or |
| 122 * DURATION. |
| 123 */ |
| 124 core.String type; |
| 125 |
| 126 /** Argument value, as a localized string. */ |
| 127 core.String value; |
| 128 |
| 129 |
| 130 ResultFormattedResultsRuleResultsValueUrlBlocksHeaderArgs(); |
| 131 |
| 132 ResultFormattedResultsRuleResultsValueUrlBlocksHeaderArgs.fromJson(core.Map _j
son) { |
| 133 if (_json.containsKey("type")) { |
| 134 type = _json["type"]; |
| 135 } |
| 136 if (_json.containsKey("value")) { |
| 137 value = _json["value"]; |
| 138 } |
| 139 } |
| 140 |
| 141 core.Map toJson() { |
| 142 var _json = new core.Map(); |
| 143 if (type != null) { |
| 144 _json["type"] = type; |
| 145 } |
| 146 if (value != null) { |
| 147 _json["value"] = value; |
| 148 } |
| 149 return _json; |
| 150 } |
| 151 } |
| 152 |
| 153 |
| 154 /** Heading to be displayed with the list of URLs. */ |
| 155 class ResultFormattedResultsRuleResultsValueUrlBlocksHeader { |
| 156 /** List of arguments for the format string. */ |
| 157 core.List<ResultFormattedResultsRuleResultsValueUrlBlocksHeaderArgs> args; |
| 158 |
| 159 /** |
| 160 * A localized format string with $N placeholders, where N is the 1-indexed |
| 161 * argument number, e.g. 'Minifying the following $1 resources would save a |
| 162 * total of $2 bytes'. |
| 163 */ |
| 164 core.String format; |
| 165 |
| 166 |
| 167 ResultFormattedResultsRuleResultsValueUrlBlocksHeader(); |
| 168 |
| 169 ResultFormattedResultsRuleResultsValueUrlBlocksHeader.fromJson(core.Map _json)
{ |
| 170 if (_json.containsKey("args")) { |
| 171 args = _json["args"].map((value) => new ResultFormattedResultsRuleResultsV
alueUrlBlocksHeaderArgs.fromJson(value)).toList(); |
| 172 } |
| 173 if (_json.containsKey("format")) { |
| 174 format = _json["format"]; |
| 175 } |
| 176 } |
| 177 |
| 178 core.Map toJson() { |
| 179 var _json = new core.Map(); |
| 180 if (args != null) { |
| 181 _json["args"] = args.map((value) => (value).toJson()).toList(); |
| 182 } |
| 183 if (format != null) { |
| 184 _json["format"] = format; |
| 185 } |
| 186 return _json; |
| 187 } |
| 188 } |
| 189 |
| 190 |
| 191 /** Not documented yet. */ |
| 192 class ResultFormattedResultsRuleResultsValueUrlBlocksUrlsDetailsArgs { |
| 193 /** |
| 194 * Type of argument. One of URL, STRING_LITERAL, INT_LITERAL, BYTES, or |
| 195 * DURATION. |
| 196 */ |
| 197 core.String type; |
| 198 |
| 199 /** Argument value, as a localized string. */ |
| 200 core.String value; |
| 201 |
| 202 |
| 203 ResultFormattedResultsRuleResultsValueUrlBlocksUrlsDetailsArgs(); |
| 204 |
| 205 ResultFormattedResultsRuleResultsValueUrlBlocksUrlsDetailsArgs.fromJson(core.M
ap _json) { |
| 206 if (_json.containsKey("type")) { |
| 207 type = _json["type"]; |
| 208 } |
| 209 if (_json.containsKey("value")) { |
| 210 value = _json["value"]; |
| 211 } |
| 212 } |
| 213 |
| 214 core.Map toJson() { |
| 215 var _json = new core.Map(); |
| 216 if (type != null) { |
| 217 _json["type"] = type; |
| 218 } |
| 219 if (value != null) { |
| 220 _json["value"] = value; |
| 221 } |
| 222 return _json; |
| 223 } |
| 224 } |
| 225 |
| 226 |
| 227 /** Not documented yet. */ |
| 228 class ResultFormattedResultsRuleResultsValueUrlBlocksUrlsDetails { |
| 229 /** List of arguments for the format string. */ |
| 230 core.List<ResultFormattedResultsRuleResultsValueUrlBlocksUrlsDetailsArgs> args
; |
| 231 |
| 232 /** |
| 233 * A localized format string with $N placeholders, where N is the 1-indexed |
| 234 * argument number, e.g. 'Unnecessary metadata for this resource adds an |
| 235 * additional $1 bytes to its download size'. |
| 236 */ |
| 237 core.String format; |
| 238 |
| 239 |
| 240 ResultFormattedResultsRuleResultsValueUrlBlocksUrlsDetails(); |
| 241 |
| 242 ResultFormattedResultsRuleResultsValueUrlBlocksUrlsDetails.fromJson(core.Map _
json) { |
| 243 if (_json.containsKey("args")) { |
| 244 args = _json["args"].map((value) => new ResultFormattedResultsRuleResultsV
alueUrlBlocksUrlsDetailsArgs.fromJson(value)).toList(); |
| 245 } |
| 246 if (_json.containsKey("format")) { |
| 247 format = _json["format"]; |
| 248 } |
| 249 } |
| 250 |
| 251 core.Map toJson() { |
| 252 var _json = new core.Map(); |
| 253 if (args != null) { |
| 254 _json["args"] = args.map((value) => (value).toJson()).toList(); |
| 255 } |
| 256 if (format != null) { |
| 257 _json["format"] = format; |
| 258 } |
| 259 return _json; |
| 260 } |
| 261 } |
| 262 |
| 263 |
| 264 /** Not documented yet. */ |
| 265 class ResultFormattedResultsRuleResultsValueUrlBlocksUrlsResultArgs { |
| 266 /** |
| 267 * Type of argument. One of URL, STRING_LITERAL, INT_LITERAL, BYTES, or |
| 268 * DURATION. |
| 269 */ |
| 270 core.String type; |
| 271 |
| 272 /** Argument value, as a localized string. */ |
| 273 core.String value; |
| 274 |
| 275 |
| 276 ResultFormattedResultsRuleResultsValueUrlBlocksUrlsResultArgs(); |
| 277 |
| 278 ResultFormattedResultsRuleResultsValueUrlBlocksUrlsResultArgs.fromJson(core.Ma
p _json) { |
| 279 if (_json.containsKey("type")) { |
| 280 type = _json["type"]; |
| 281 } |
| 282 if (_json.containsKey("value")) { |
| 283 value = _json["value"]; |
| 284 } |
| 285 } |
| 286 |
| 287 core.Map toJson() { |
| 288 var _json = new core.Map(); |
| 289 if (type != null) { |
| 290 _json["type"] = type; |
| 291 } |
| 292 if (value != null) { |
| 293 _json["value"] = value; |
| 294 } |
| 295 return _json; |
| 296 } |
| 297 } |
| 298 |
| 299 |
| 300 /** |
| 301 * A format string that gives information about the URL, and a list of arguments |
| 302 * for that format string. |
| 303 */ |
| 304 class ResultFormattedResultsRuleResultsValueUrlBlocksUrlsResult { |
| 305 /** List of arguments for the format string. */ |
| 306 core.List<ResultFormattedResultsRuleResultsValueUrlBlocksUrlsResultArgs> args; |
| 307 |
| 308 /** |
| 309 * A localized format string with $N placeholders, where N is the 1-indexed |
| 310 * argument number, e.g. 'Minifying the resource at URL $1 can save $2 bytes'. |
| 311 */ |
| 312 core.String format; |
| 313 |
| 314 |
| 315 ResultFormattedResultsRuleResultsValueUrlBlocksUrlsResult(); |
| 316 |
| 317 ResultFormattedResultsRuleResultsValueUrlBlocksUrlsResult.fromJson(core.Map _j
son) { |
| 318 if (_json.containsKey("args")) { |
| 319 args = _json["args"].map((value) => new ResultFormattedResultsRuleResultsV
alueUrlBlocksUrlsResultArgs.fromJson(value)).toList(); |
| 320 } |
| 321 if (_json.containsKey("format")) { |
| 322 format = _json["format"]; |
| 323 } |
| 324 } |
| 325 |
| 326 core.Map toJson() { |
| 327 var _json = new core.Map(); |
| 328 if (args != null) { |
| 329 _json["args"] = args.map((value) => (value).toJson()).toList(); |
| 330 } |
| 331 if (format != null) { |
| 332 _json["format"] = format; |
| 333 } |
| 334 return _json; |
| 335 } |
| 336 } |
| 337 |
| 338 |
| 339 /** Not documented yet. */ |
| 340 class ResultFormattedResultsRuleResultsValueUrlBlocksUrls { |
| 341 /** |
| 342 * List of entries that provide additional details about a single URL. |
| 343 * Optional. |
| 344 */ |
| 345 core.List<ResultFormattedResultsRuleResultsValueUrlBlocksUrlsDetails> details; |
| 346 |
| 347 /** |
| 348 * A format string that gives information about the URL, and a list of |
| 349 * arguments for that format string. |
| 350 */ |
| 351 ResultFormattedResultsRuleResultsValueUrlBlocksUrlsResult result; |
| 352 |
| 353 |
| 354 ResultFormattedResultsRuleResultsValueUrlBlocksUrls(); |
| 355 |
| 356 ResultFormattedResultsRuleResultsValueUrlBlocksUrls.fromJson(core.Map _json) { |
| 357 if (_json.containsKey("details")) { |
| 358 details = _json["details"].map((value) => new ResultFormattedResultsRuleRe
sultsValueUrlBlocksUrlsDetails.fromJson(value)).toList(); |
| 359 } |
| 360 if (_json.containsKey("result")) { |
| 361 result = new ResultFormattedResultsRuleResultsValueUrlBlocksUrlsResult.fro
mJson(_json["result"]); |
| 362 } |
| 363 } |
| 364 |
| 365 core.Map toJson() { |
| 366 var _json = new core.Map(); |
| 367 if (details != null) { |
| 368 _json["details"] = details.map((value) => (value).toJson()).toList(); |
| 369 } |
| 370 if (result != null) { |
| 371 _json["result"] = (result).toJson(); |
| 372 } |
| 373 return _json; |
| 374 } |
| 375 } |
| 376 |
| 377 |
| 378 /** Not documented yet. */ |
| 379 class ResultFormattedResultsRuleResultsValueUrlBlocks { |
| 380 /** Heading to be displayed with the list of URLs. */ |
| 381 ResultFormattedResultsRuleResultsValueUrlBlocksHeader header; |
| 382 |
| 383 /** |
| 384 * List of entries that provide information about URLs in the url block. |
| 385 * Optional. |
| 386 */ |
| 387 core.List<ResultFormattedResultsRuleResultsValueUrlBlocksUrls> urls; |
| 388 |
| 389 |
| 390 ResultFormattedResultsRuleResultsValueUrlBlocks(); |
| 391 |
| 392 ResultFormattedResultsRuleResultsValueUrlBlocks.fromJson(core.Map _json) { |
| 393 if (_json.containsKey("header")) { |
| 394 header = new ResultFormattedResultsRuleResultsValueUrlBlocksHeader.fromJso
n(_json["header"]); |
| 395 } |
| 396 if (_json.containsKey("urls")) { |
| 397 urls = _json["urls"].map((value) => new ResultFormattedResultsRuleResultsV
alueUrlBlocksUrls.fromJson(value)).toList(); |
| 398 } |
| 399 } |
| 400 |
| 401 core.Map toJson() { |
| 402 var _json = new core.Map(); |
| 403 if (header != null) { |
| 404 _json["header"] = (header).toJson(); |
| 405 } |
| 406 if (urls != null) { |
| 407 _json["urls"] = urls.map((value) => (value).toJson()).toList(); |
| 408 } |
| 409 return _json; |
| 410 } |
| 411 } |
| 412 |
| 413 |
| 414 /** |
| 415 * The enum-like identifier for this rule. For instance "EnableKeepAlive" or |
| 416 * "AvoidCssImport". Not localized. |
| 417 */ |
| 418 class ResultFormattedResultsRuleResultsValue { |
| 419 /** Localized name of the rule, intended for presentation to a user. */ |
| 420 core.String localizedRuleName; |
| 421 |
| 422 /** |
| 423 * The impact (unbounded floating point value) that implementing the |
| 424 * suggestions for this rule would have on making the page faster. Impact is |
| 425 * comparable between rules to determine which rule's suggestions would have a |
| 426 * higher or lower impact on making a page faster. For instance, if enabling |
| 427 * compression would save 1MB, while optimizing images would save 500kB, the |
| 428 * enable compression rule would have 2x the impact of the image optimization |
| 429 * rule, all other things being equal. |
| 430 */ |
| 431 core.double ruleImpact; |
| 432 |
| 433 /** |
| 434 * List of blocks of URLs. Each block may contain a heading and a list of |
| 435 * URLs. Each URL may optionally include additional details. |
| 436 */ |
| 437 core.List<ResultFormattedResultsRuleResultsValueUrlBlocks> urlBlocks; |
| 438 |
| 439 |
| 440 ResultFormattedResultsRuleResultsValue(); |
| 441 |
| 442 ResultFormattedResultsRuleResultsValue.fromJson(core.Map _json) { |
| 443 if (_json.containsKey("localizedRuleName")) { |
| 444 localizedRuleName = _json["localizedRuleName"]; |
| 445 } |
| 446 if (_json.containsKey("ruleImpact")) { |
| 447 ruleImpact = _json["ruleImpact"]; |
| 448 } |
| 449 if (_json.containsKey("urlBlocks")) { |
| 450 urlBlocks = _json["urlBlocks"].map((value) => new ResultFormattedResultsRu
leResultsValueUrlBlocks.fromJson(value)).toList(); |
| 451 } |
| 452 } |
| 453 |
| 454 core.Map toJson() { |
| 455 var _json = new core.Map(); |
| 456 if (localizedRuleName != null) { |
| 457 _json["localizedRuleName"] = localizedRuleName; |
| 458 } |
| 459 if (ruleImpact != null) { |
| 460 _json["ruleImpact"] = ruleImpact; |
| 461 } |
| 462 if (urlBlocks != null) { |
| 463 _json["urlBlocks"] = urlBlocks.map((value) => (value).toJson()).toList(); |
| 464 } |
| 465 return _json; |
| 466 } |
| 467 } |
| 468 |
| 469 |
| 470 /** |
| 471 * Localized Page Speed results. Contains a ruleResults entry for each Page |
| 472 * Speed rule instantiated and run by the server. |
| 473 */ |
| 474 class ResultFormattedResults { |
| 475 /** The locale of the formattedResults, e.g. "en_US". */ |
| 476 core.String locale; |
| 477 |
| 478 /** |
| 479 * Dictionary of formatted rule results, with one entry for each Page Speed |
| 480 * rule instantiated and run by the server. |
| 481 */ |
| 482 core.Map<core.String, ResultFormattedResultsRuleResultsValue> ruleResults; |
| 483 |
| 484 |
| 485 ResultFormattedResults(); |
| 486 |
| 487 ResultFormattedResults.fromJson(core.Map _json) { |
| 488 if (_json.containsKey("locale")) { |
| 489 locale = _json["locale"]; |
| 490 } |
| 491 if (_json.containsKey("ruleResults")) { |
| 492 ruleResults = common_internal.mapMap(_json["ruleResults"], (item) => new R
esultFormattedResultsRuleResultsValue.fromJson(item)); |
| 493 } |
| 494 } |
| 495 |
| 496 core.Map toJson() { |
| 497 var _json = new core.Map(); |
| 498 if (locale != null) { |
| 499 _json["locale"] = locale; |
| 500 } |
| 501 if (ruleResults != null) { |
| 502 _json["ruleResults"] = common_internal.mapMap(ruleResults, (item) => (item
).toJson()); |
| 503 } |
| 504 return _json; |
| 505 } |
| 506 } |
| 507 |
| 508 |
| 509 /** |
| 510 * Summary statistics for the page, such as number of JavaScript bytes, number |
| 511 * of HTML bytes, etc. |
| 512 */ |
| 513 class ResultPageStats { |
| 514 /** Number of uncompressed response bytes for CSS resources on the page. */ |
| 515 core.String cssResponseBytes; |
| 516 |
| 517 /** Number of response bytes for flash resources on the page. */ |
| 518 core.String flashResponseBytes; |
| 519 |
| 520 /** |
| 521 * Number of uncompressed response bytes for the main HTML document and all |
| 522 * iframes on the page. |
| 523 */ |
| 524 core.String htmlResponseBytes; |
| 525 |
| 526 /** Number of response bytes for image resources on the page. */ |
| 527 core.String imageResponseBytes; |
| 528 |
| 529 /** Number of uncompressed response bytes for JS resources on the page. */ |
| 530 core.String javascriptResponseBytes; |
| 531 |
| 532 /** Number of CSS resources referenced by the page. */ |
| 533 core.int numberCssResources; |
| 534 |
| 535 /** Number of unique hosts referenced by the page. */ |
| 536 core.int numberHosts; |
| 537 |
| 538 /** Number of JavaScript resources referenced by the page. */ |
| 539 core.int numberJsResources; |
| 540 |
| 541 /** Number of HTTP resources loaded by the page. */ |
| 542 core.int numberResources; |
| 543 |
| 544 /** Number of static (i.e. cacheable) resources on the page. */ |
| 545 core.int numberStaticResources; |
| 546 |
| 547 /** Number of response bytes for other resources on the page. */ |
| 548 core.String otherResponseBytes; |
| 549 |
| 550 /** |
| 551 * Number of uncompressed response bytes for text resources not covered by |
| 552 * other statistics (i.e non-HTML, non-script, non-CSS resources) on the page. |
| 553 */ |
| 554 core.String textResponseBytes; |
| 555 |
| 556 /** Total size of all request bytes sent by the page. */ |
| 557 core.String totalRequestBytes; |
| 558 |
| 559 |
| 560 ResultPageStats(); |
| 561 |
| 562 ResultPageStats.fromJson(core.Map _json) { |
| 563 if (_json.containsKey("cssResponseBytes")) { |
| 564 cssResponseBytes = _json["cssResponseBytes"]; |
| 565 } |
| 566 if (_json.containsKey("flashResponseBytes")) { |
| 567 flashResponseBytes = _json["flashResponseBytes"]; |
| 568 } |
| 569 if (_json.containsKey("htmlResponseBytes")) { |
| 570 htmlResponseBytes = _json["htmlResponseBytes"]; |
| 571 } |
| 572 if (_json.containsKey("imageResponseBytes")) { |
| 573 imageResponseBytes = _json["imageResponseBytes"]; |
| 574 } |
| 575 if (_json.containsKey("javascriptResponseBytes")) { |
| 576 javascriptResponseBytes = _json["javascriptResponseBytes"]; |
| 577 } |
| 578 if (_json.containsKey("numberCssResources")) { |
| 579 numberCssResources = _json["numberCssResources"]; |
| 580 } |
| 581 if (_json.containsKey("numberHosts")) { |
| 582 numberHosts = _json["numberHosts"]; |
| 583 } |
| 584 if (_json.containsKey("numberJsResources")) { |
| 585 numberJsResources = _json["numberJsResources"]; |
| 586 } |
| 587 if (_json.containsKey("numberResources")) { |
| 588 numberResources = _json["numberResources"]; |
| 589 } |
| 590 if (_json.containsKey("numberStaticResources")) { |
| 591 numberStaticResources = _json["numberStaticResources"]; |
| 592 } |
| 593 if (_json.containsKey("otherResponseBytes")) { |
| 594 otherResponseBytes = _json["otherResponseBytes"]; |
| 595 } |
| 596 if (_json.containsKey("textResponseBytes")) { |
| 597 textResponseBytes = _json["textResponseBytes"]; |
| 598 } |
| 599 if (_json.containsKey("totalRequestBytes")) { |
| 600 totalRequestBytes = _json["totalRequestBytes"]; |
| 601 } |
| 602 } |
| 603 |
| 604 core.Map toJson() { |
| 605 var _json = new core.Map(); |
| 606 if (cssResponseBytes != null) { |
| 607 _json["cssResponseBytes"] = cssResponseBytes; |
| 608 } |
| 609 if (flashResponseBytes != null) { |
| 610 _json["flashResponseBytes"] = flashResponseBytes; |
| 611 } |
| 612 if (htmlResponseBytes != null) { |
| 613 _json["htmlResponseBytes"] = htmlResponseBytes; |
| 614 } |
| 615 if (imageResponseBytes != null) { |
| 616 _json["imageResponseBytes"] = imageResponseBytes; |
| 617 } |
| 618 if (javascriptResponseBytes != null) { |
| 619 _json["javascriptResponseBytes"] = javascriptResponseBytes; |
| 620 } |
| 621 if (numberCssResources != null) { |
| 622 _json["numberCssResources"] = numberCssResources; |
| 623 } |
| 624 if (numberHosts != null) { |
| 625 _json["numberHosts"] = numberHosts; |
| 626 } |
| 627 if (numberJsResources != null) { |
| 628 _json["numberJsResources"] = numberJsResources; |
| 629 } |
| 630 if (numberResources != null) { |
| 631 _json["numberResources"] = numberResources; |
| 632 } |
| 633 if (numberStaticResources != null) { |
| 634 _json["numberStaticResources"] = numberStaticResources; |
| 635 } |
| 636 if (otherResponseBytes != null) { |
| 637 _json["otherResponseBytes"] = otherResponseBytes; |
| 638 } |
| 639 if (textResponseBytes != null) { |
| 640 _json["textResponseBytes"] = textResponseBytes; |
| 641 } |
| 642 if (totalRequestBytes != null) { |
| 643 _json["totalRequestBytes"] = totalRequestBytes; |
| 644 } |
| 645 return _json; |
| 646 } |
| 647 } |
| 648 |
| 649 |
| 650 /** Base64 encoded screenshot of the page that was analyzed. */ |
| 651 class ResultScreenshot { |
| 652 /** Image data base64 encoded. */ |
| 653 core.String data; |
| 654 |
| 655 core.List<core.int> get dataAsBytes { |
| 656 return crypto.CryptoUtils.base64StringToBytes(data); |
| 657 } |
| 658 |
| 659 void set dataAsBytes(core.List<core.int> _bytes) { |
| 660 data = crypto.CryptoUtils.bytesToBase64(_bytes, urlSafe: true); |
| 661 } |
| 662 |
| 663 /** Height of screenshot in pixels. */ |
| 664 core.int height; |
| 665 |
| 666 /** Mime type of image data. E.g. "image/jpeg". */ |
| 667 core.String mimeType; |
| 668 |
| 669 /** Width of screenshot in pixels. */ |
| 670 core.int width; |
| 671 |
| 672 |
| 673 ResultScreenshot(); |
| 674 |
| 675 ResultScreenshot.fromJson(core.Map _json) { |
| 676 if (_json.containsKey("data")) { |
| 677 data = _json["data"]; |
| 678 } |
| 679 if (_json.containsKey("height")) { |
| 680 height = _json["height"]; |
| 681 } |
| 682 if (_json.containsKey("mime_type")) { |
| 683 mimeType = _json["mime_type"]; |
| 684 } |
| 685 if (_json.containsKey("width")) { |
| 686 width = _json["width"]; |
| 687 } |
| 688 } |
| 689 |
| 690 core.Map toJson() { |
| 691 var _json = new core.Map(); |
| 692 if (data != null) { |
| 693 _json["data"] = data; |
| 694 } |
| 695 if (height != null) { |
| 696 _json["height"] = height; |
| 697 } |
| 698 if (mimeType != null) { |
| 699 _json["mime_type"] = mimeType; |
| 700 } |
| 701 if (width != null) { |
| 702 _json["width"] = width; |
| 703 } |
| 704 return _json; |
| 705 } |
| 706 } |
| 707 |
| 708 |
| 709 /** The version of the Page Speed SDK used to generate these results. */ |
| 710 class ResultVersion { |
| 711 /** |
| 712 * The major version number of the Page Speed SDK used to generate these |
| 713 * results. |
| 714 */ |
| 715 core.int major; |
| 716 |
| 717 /** |
| 718 * The minor version number of the Page Speed SDK used to generate these |
| 719 * results. |
| 720 */ |
| 721 core.int minor; |
| 722 |
| 723 |
| 724 ResultVersion(); |
| 725 |
| 726 ResultVersion.fromJson(core.Map _json) { |
| 727 if (_json.containsKey("major")) { |
| 728 major = _json["major"]; |
| 729 } |
| 730 if (_json.containsKey("minor")) { |
| 731 minor = _json["minor"]; |
| 732 } |
| 733 } |
| 734 |
| 735 core.Map toJson() { |
| 736 var _json = new core.Map(); |
| 737 if (major != null) { |
| 738 _json["major"] = major; |
| 739 } |
| 740 if (minor != null) { |
| 741 _json["minor"] = minor; |
| 742 } |
| 743 return _json; |
| 744 } |
| 745 } |
| 746 |
| 747 |
| 748 /** Not documented yet. */ |
| 749 class Result { |
| 750 /** |
| 751 * Localized Page Speed results. Contains a ruleResults entry for each Page |
| 752 * Speed rule instantiated and run by the server. |
| 753 */ |
| 754 ResultFormattedResults formattedResults; |
| 755 |
| 756 /** |
| 757 * Canonicalized and final URL for the document, after following page |
| 758 * redirects (if any). |
| 759 */ |
| 760 core.String id; |
| 761 |
| 762 /** |
| 763 * List of rules that were specified in the request, but which the server did |
| 764 * not know how to instantiate. |
| 765 */ |
| 766 core.List<core.String> invalidRules; |
| 767 |
| 768 /** Kind of result. */ |
| 769 core.String kind; |
| 770 |
| 771 /** |
| 772 * Summary statistics for the page, such as number of JavaScript bytes, number |
| 773 * of HTML bytes, etc. |
| 774 */ |
| 775 ResultPageStats pageStats; |
| 776 |
| 777 /** |
| 778 * Response code for the document. 200 indicates a normal page load. 4xx/5xx |
| 779 * indicates an error. |
| 780 */ |
| 781 core.int responseCode; |
| 782 |
| 783 /** |
| 784 * The Page Speed Score (0-100), which indicates how much faster a page could |
| 785 * be. A high score indicates little room for improvement, while a lower score |
| 786 * indicates more room for improvement. |
| 787 */ |
| 788 core.int score; |
| 789 |
| 790 /** Base64 encoded screenshot of the page that was analyzed. */ |
| 791 ResultScreenshot screenshot; |
| 792 |
| 793 /** Title of the page, as displayed in the browser's title bar. */ |
| 794 core.String title; |
| 795 |
| 796 /** The version of the Page Speed SDK used to generate these results. */ |
| 797 ResultVersion version; |
| 798 |
| 799 |
| 800 Result(); |
| 801 |
| 802 Result.fromJson(core.Map _json) { |
| 803 if (_json.containsKey("formattedResults")) { |
| 804 formattedResults = new ResultFormattedResults.fromJson(_json["formattedRes
ults"]); |
| 805 } |
| 806 if (_json.containsKey("id")) { |
| 807 id = _json["id"]; |
| 808 } |
| 809 if (_json.containsKey("invalidRules")) { |
| 810 invalidRules = _json["invalidRules"]; |
| 811 } |
| 812 if (_json.containsKey("kind")) { |
| 813 kind = _json["kind"]; |
| 814 } |
| 815 if (_json.containsKey("pageStats")) { |
| 816 pageStats = new ResultPageStats.fromJson(_json["pageStats"]); |
| 817 } |
| 818 if (_json.containsKey("responseCode")) { |
| 819 responseCode = _json["responseCode"]; |
| 820 } |
| 821 if (_json.containsKey("score")) { |
| 822 score = _json["score"]; |
| 823 } |
| 824 if (_json.containsKey("screenshot")) { |
| 825 screenshot = new ResultScreenshot.fromJson(_json["screenshot"]); |
| 826 } |
| 827 if (_json.containsKey("title")) { |
| 828 title = _json["title"]; |
| 829 } |
| 830 if (_json.containsKey("version")) { |
| 831 version = new ResultVersion.fromJson(_json["version"]); |
| 832 } |
| 833 } |
| 834 |
| 835 core.Map toJson() { |
| 836 var _json = new core.Map(); |
| 837 if (formattedResults != null) { |
| 838 _json["formattedResults"] = (formattedResults).toJson(); |
| 839 } |
| 840 if (id != null) { |
| 841 _json["id"] = id; |
| 842 } |
| 843 if (invalidRules != null) { |
| 844 _json["invalidRules"] = invalidRules; |
| 845 } |
| 846 if (kind != null) { |
| 847 _json["kind"] = kind; |
| 848 } |
| 849 if (pageStats != null) { |
| 850 _json["pageStats"] = (pageStats).toJson(); |
| 851 } |
| 852 if (responseCode != null) { |
| 853 _json["responseCode"] = responseCode; |
| 854 } |
| 855 if (score != null) { |
| 856 _json["score"] = score; |
| 857 } |
| 858 if (screenshot != null) { |
| 859 _json["screenshot"] = (screenshot).toJson(); |
| 860 } |
| 861 if (title != null) { |
| 862 _json["title"] = title; |
| 863 } |
| 864 if (version != null) { |
| 865 _json["version"] = (version).toJson(); |
| 866 } |
| 867 return _json; |
| 868 } |
| 869 } |
| 870 |
| 871 |
OLD | NEW |