Skip to content

Commit 114fa48

Browse files
committed
Automated update
0 parents  commit 114fa48

16 files changed

+1659
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
packages
2+
pubspec.lock

LICENSE

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Copyright 2014, the Dart project authors. All rights reserved.
2+
Redistribution and use in source and binary forms, with or without
3+
modification, are permitted provided that the following conditions are
4+
met:
5+
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above
9+
copyright notice, this list of conditions and the following
10+
disclaimer in the documentation and/or other materials provided
11+
with the distribution.
12+
* Neither the name of Google Inc. nor the names of its
13+
contributors may be used to endorse or promote products derived
14+
from this software without specific prior written permission.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# (Deprecated) google_webmasters_v3_api
2+
3+
### See [googleapis](https://pub.dartlang.org/packages/googleapis) or [googleapis_beta](https://pub.dartlang.org/packages/googleapis_beta) for latest libraries.
4+
5+
If you would like to continue to use this library pin version constraint to
6+
`'0.4.0'`
7+
8+
![alt tag](https://cloud.githubusercontent.com/assets/654526/4262495/26e744b4-3ba5-11e4-8b96-bfadd6eeaf9e.png)
9+
10+
### Licenses
11+
12+
```
13+
Copyright 2014, the Dart project authors. All rights reserved.
14+
Redistribution and use in source and binary forms, with or without
15+
modification, are permitted provided that the following conditions are
16+
met:
17+
18+
* Redistributions of source code must retain the above copyright
19+
notice, this list of conditions and the following disclaimer.
20+
* Redistributions in binary form must reproduce the above
21+
copyright notice, this list of conditions and the following
22+
disclaimer in the documentation and/or other materials provided
23+
with the distribution.
24+
* Neither the name of Google Inc. nor the names of its
25+
contributors may be used to endorse or promote products derived
26+
from this software without specific prior written permission.
27+
28+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39+
```

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"uUWyYHXmEn-ab7WLvo8qNz2S8ws/sCAxuVQJb4ynjZxsnsm28T2muEw"

lib/src/browser_client.dart

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
library cloud_api.browser;
2+
3+
import "dart:async";
4+
import "dart:html" as html;
5+
import "dart:convert";
6+
import "dart:js" as js;
7+
import "package:google_oauth2_client/google_oauth2_browser.dart" as oauth;
8+
9+
import 'client_base.dart';
10+
11+
/**
12+
* Base class for all Browser API clients, offering generic methods for HTTP Requests to the API
13+
*/
14+
@deprecated
15+
abstract class BrowserClient implements ClientBase {
16+
17+
static const _corsCallback = 'handleCLientLoad';
18+
19+
oauth.OAuth2 get auth;
20+
bool _jsClientLoaded = false;
21+
22+
/**
23+
* Loads the JS Client Library to make CORS-Requests
24+
*/
25+
Future _loadJsClient() {
26+
27+
if (_jsClientLoaded) {
28+
return new Future.value();
29+
}
30+
31+
var completer = new Completer();
32+
33+
js.context[_corsCallback] = () {
34+
_jsClientLoaded = true;
35+
completer.complete();
36+
};
37+
38+
html.ScriptElement script = new html.ScriptElement();
39+
script.src = "https://apis.google.com/js/client.js?onload=$_corsCallback";
40+
script.type = "text/javascript";
41+
html.document.body.children.add(script);
42+
43+
return completer.future;
44+
}
45+
46+
/**
47+
* Makes a request via the JS Client Library to circumvent CORS-problems
48+
*/
49+
Future<Map<String, dynamic>> _makeJsClientRequest(String requestUrl, String method, {String body, String contentType, Map queryParams}) {
50+
var requestData = new Map();
51+
requestData["path"] = requestUrl;
52+
requestData["method"] = method;
53+
requestData["headers"] = new Map();
54+
55+
if (queryParams != null) {
56+
requestData["params"] = queryParams;
57+
}
58+
59+
if (body != null) {
60+
requestData["body"] = body;
61+
requestData["headers"]["Content-Type"] = contentType;
62+
}
63+
if (makeAuthRequests && auth != null && auth.token != null) {
64+
requestData["headers"]["Authorization"] = "${auth.token.type} ${auth.token.data}";
65+
}
66+
67+
var completer = new Completer();
68+
var request = js.context["gapi"]["client"].callMethod("request",
69+
[new js.JsObject.jsify(requestData)]);
70+
var callback = (jsonResp, rawResp) {
71+
if (jsonResp == null || (jsonResp is bool && jsonResp == false)) {
72+
var raw = JSON.decode(rawResp);
73+
if (raw["gapiRequest"]["data"]["status"] >= 400) {
74+
completer.completeError(new APIRequestError("JS Client - ${raw["gapiRequest"]["data"]["status"]} ${raw["gapiRequest"]["data"]["statusText"]} - ${raw["gapiRequest"]["data"]["body"]}"));
75+
} else {
76+
completer.complete({});
77+
}
78+
} else {
79+
completer.complete(js.context["JSON"].callMethod("stringify", [jsonResp]));
80+
}
81+
};
82+
request.execute(callback);
83+
84+
return completer.future;
85+
}
86+
87+
/**
88+
* Sends a HTTPRequest using [method] (usually GET or POST) to [requestUrl] using the specified [urlParams] and [queryParams]. Optionally include a [body] in the request.
89+
*/
90+
Future<Map<String, dynamic>> request(String requestUrl, String method, {String body, String contentType:"application/json", Map urlParams, Map queryParams}) {
91+
92+
if (urlParams == null) urlParams = {};
93+
if (queryParams == null) queryParams = {};
94+
95+
params.forEach((key, param) {
96+
if (param != null && queryParams[key] == null) {
97+
queryParams[key] = param;
98+
}
99+
});
100+
101+
var path;
102+
if (requestUrl.substring(0,1) == "/") {
103+
path ="$rootUrl${requestUrl.substring(1)}";
104+
} else {
105+
path ="$rootUrl${basePath.substring(1)}$requestUrl";
106+
}
107+
var url = oauth.UrlPattern.generatePattern(path, urlParams, queryParams);
108+
109+
var request = new html.HttpRequest();
110+
var completer = new Completer();
111+
112+
void handleError() {
113+
if (request.status == 0) {
114+
_loadJsClient().then((v) {
115+
if (requestUrl.substring(0,1) == "/") {
116+
path = requestUrl;
117+
} else {
118+
path ="$basePath$requestUrl";
119+
}
120+
url = oauth.UrlPattern.generatePattern(path, urlParams, {});
121+
_makeJsClientRequest(url, method, body: body, contentType: contentType, queryParams: queryParams)
122+
.then((response) {
123+
var data = JSON.decode(response);
124+
completer.complete(data);
125+
})
126+
.catchError((e) {
127+
completer.completeError(e);
128+
return true;
129+
});
130+
});
131+
} else {
132+
var error = "";
133+
if (request.responseText != null) {
134+
var errorJson;
135+
try {
136+
errorJson = JSON.decode(request.responseText);
137+
} on FormatException {
138+
errorJson = null;
139+
}
140+
if (errorJson != null && errorJson.containsKey("error")) {
141+
error = "${errorJson["error"]["code"]} ${errorJson["error"]["message"]}";
142+
}
143+
}
144+
if (error == "") {
145+
error = "${request.status} ${request.statusText}";
146+
}
147+
completer.completeError(new APIRequestError(error));
148+
}
149+
}
150+
151+
request.onLoad.listen((_) {
152+
if (request.status > 0 && request.status < 400) {
153+
var data = {};
154+
if (!request.responseText.isEmpty) {
155+
data = JSON.decode(request.responseText);
156+
}
157+
completer.complete(data);
158+
} else {
159+
handleError();
160+
}
161+
});
162+
163+
request.onError.listen((_) => handleError());
164+
165+
request.open(method, url);
166+
request.setRequestHeader("Content-Type", contentType);
167+
if (makeAuthRequests && auth != null) {
168+
auth.authenticate(request).then((request) => request.send(body));
169+
} else {
170+
request.send(body);
171+
}
172+
173+
return completer.future;
174+
}
175+
}

lib/src/client/client.dart

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
part of webmasters_v3_api;
2+
3+
abstract class Client extends ClientBase {
4+
core.String basePath = "/webmasters/v3/";
5+
core.String rootUrl = "https://www.googleapis.com/";
6+
7+
//
8+
// Resources
9+
//
10+
11+
SitemapsResource_ get sitemaps => new SitemapsResource_(this);
12+
SitesResource_ get sites => new SitesResource_(this);
13+
UrlcrawlerrorscountsResource_ get urlcrawlerrorscounts => new UrlcrawlerrorscountsResource_(this);
14+
UrlcrawlerrorssamplesResource_ get urlcrawlerrorssamples => new UrlcrawlerrorssamplesResource_(this);
15+
16+
//
17+
// Parameters
18+
//
19+
20+
/**
21+
* Data format for the response.
22+
* Added as queryParameter for each request.
23+
*/
24+
core.String get alt => params["alt"];
25+
set alt(core.String value) => params["alt"] = value;
26+
27+
/**
28+
* Selector specifying which fields to include in a partial response.
29+
* Added as queryParameter for each request.
30+
*/
31+
core.String get fields => params["fields"];
32+
set fields(core.String value) => params["fields"] = value;
33+
34+
/**
35+
* API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
36+
* Added as queryParameter for each request.
37+
*/
38+
core.String get key => params["key"];
39+
set key(core.String value) => params["key"] = value;
40+
41+
/**
42+
* OAuth 2.0 token for the current user.
43+
* Added as queryParameter for each request.
44+
*/
45+
core.String get oauth_token => params["oauth_token"];
46+
set oauth_token(core.String value) => params["oauth_token"] = value;
47+
48+
/**
49+
* Returns response with indentations and line breaks.
50+
* Added as queryParameter for each request.
51+
*/
52+
core.bool get prettyPrint => params["prettyPrint"];
53+
set prettyPrint(core.bool value) => params["prettyPrint"] = value;
54+
55+
/**
56+
* Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
57+
* Added as queryParameter for each request.
58+
*/
59+
core.String get quotaUser => params["quotaUser"];
60+
set quotaUser(core.String value) => params["quotaUser"] = value;
61+
62+
/**
63+
* IP address of the site where the request originates. Use this if you want to enforce per-user limits.
64+
* Added as queryParameter for each request.
65+
*/
66+
core.String get userIp => params["userIp"];
67+
set userIp(core.String value) => params["userIp"] = value;
68+
}

0 commit comments

Comments
 (0)