OLD | NEW |
1 // This is a generated file (see the discoveryapis_generator project). | 1 // This is a generated file (see the discoveryapis_generator project). |
2 | 2 |
3 library googleapis.webfonts.v1; | 3 library googleapis.webfonts.v1; |
4 | 4 |
5 import 'dart:core' as core; | 5 import 'dart:core' as core; |
6 import 'dart:async' as async; | 6 import 'dart:async' as async; |
7 import 'dart:convert' as convert; | 7 import 'dart:convert' as convert; |
8 | 8 |
9 import 'package:_discoveryapis_commons/_discoveryapis_commons.dart' as commons; | 9 import 'package:_discoveryapis_commons/_discoveryapis_commons.dart' as commons; |
10 import 'package:http/http.dart' as http; | 10 import 'package:http/http.dart' as http; |
11 | 11 |
12 export 'package:_discoveryapis_commons/_discoveryapis_commons.dart' show | 12 export 'package:_discoveryapis_commons/_discoveryapis_commons.dart' |
13 ApiRequestError, DetailedApiRequestError; | 13 show ApiRequestError, DetailedApiRequestError; |
14 | 14 |
15 const core.String USER_AGENT = 'dart-api-client webfonts/v1'; | 15 const core.String USER_AGENT = 'dart-api-client webfonts/v1'; |
16 | 16 |
17 /** | 17 /// Accesses the metadata for all families served by Google Fonts, providing a |
18 * Accesses the metadata for all families served by Google Fonts, providing a | 18 /// list of families currently available (including available styles and a list |
19 * list of families currently available (including available styles and a list | 19 /// of supported script subsets). |
20 * of supported script subsets). | |
21 */ | |
22 class WebfontsApi { | 20 class WebfontsApi { |
23 | |
24 final commons.ApiRequester _requester; | 21 final commons.ApiRequester _requester; |
25 | 22 |
26 WebfontsResourceApi get webfonts => new WebfontsResourceApi(_requester); | 23 WebfontsResourceApi get webfonts => new WebfontsResourceApi(_requester); |
27 | 24 |
28 WebfontsApi(http.Client client, {core.String rootUrl: "https://www.googleapis.
com/", core.String servicePath: "webfonts/v1/"}) : | 25 WebfontsApi(http.Client client, |
29 _requester = new commons.ApiRequester(client, rootUrl, servicePath, USER_A
GENT); | 26 {core.String rootUrl: "https://www.googleapis.com/", |
| 27 core.String servicePath: "webfonts/v1/"}) |
| 28 : _requester = |
| 29 new commons.ApiRequester(client, rootUrl, servicePath, USER_AGENT); |
30 } | 30 } |
31 | 31 |
32 | |
33 class WebfontsResourceApi { | 32 class WebfontsResourceApi { |
34 final commons.ApiRequester _requester; | 33 final commons.ApiRequester _requester; |
35 | 34 |
36 WebfontsResourceApi(commons.ApiRequester client) : | 35 WebfontsResourceApi(commons.ApiRequester client) : _requester = client; |
37 _requester = client; | |
38 | 36 |
39 /** | 37 /// Retrieves the list of fonts currently served by the Google Fonts |
40 * Retrieves the list of fonts currently served by the Google Fonts Developer | 38 /// Developer API |
41 * API | 39 /// |
42 * | 40 /// Request parameters: |
43 * Request parameters: | 41 /// |
44 * | 42 /// [sort] - Enables sorting of the list |
45 * [sort] - Enables sorting of the list | 43 /// Possible string values are: |
46 * Possible string values are: | 44 /// - "alpha" : Sort alphabetically |
47 * - "alpha" : Sort alphabetically | 45 /// - "date" : Sort by date added |
48 * - "date" : Sort by date added | 46 /// - "popularity" : Sort by popularity |
49 * - "popularity" : Sort by popularity | 47 /// - "style" : Sort by number of styles |
50 * - "style" : Sort by number of styles | 48 /// - "trending" : Sort by trending |
51 * - "trending" : Sort by trending | 49 /// |
52 * | 50 /// Completes with a [WebfontList]. |
53 * Completes with a [WebfontList]. | 51 /// |
54 * | 52 /// Completes with a [commons.ApiRequestError] if the API endpoint returned |
55 * Completes with a [commons.ApiRequestError] if the API endpoint returned an | 53 /// an error. |
56 * error. | 54 /// |
57 * | 55 /// If the used [http.Client] completes with an error when making a REST |
58 * If the used [http.Client] completes with an error when making a REST call, | 56 /// call, this method will complete with the same error. |
59 * this method will complete with the same error. | |
60 */ | |
61 async.Future<WebfontList> list({core.String sort}) { | 57 async.Future<WebfontList> list({core.String sort}) { |
62 var _url = null; | 58 var _url = null; |
63 var _queryParams = new core.Map(); | 59 var _queryParams = new core.Map(); |
64 var _uploadMedia = null; | 60 var _uploadMedia = null; |
65 var _uploadOptions = null; | 61 var _uploadOptions = null; |
66 var _downloadOptions = commons.DownloadOptions.Metadata; | 62 var _downloadOptions = commons.DownloadOptions.Metadata; |
67 var _body = null; | 63 var _body = null; |
68 | 64 |
69 if (sort != null) { | 65 if (sort != null) { |
70 _queryParams["sort"] = [sort]; | 66 _queryParams["sort"] = [sort]; |
71 } | 67 } |
72 | 68 |
73 _url = 'webfonts'; | 69 _url = 'webfonts'; |
74 | 70 |
75 var _response = _requester.request(_url, | 71 var _response = _requester.request(_url, "GET", |
76 "GET", | 72 body: _body, |
77 body: _body, | 73 queryParams: _queryParams, |
78 queryParams: _queryParams, | 74 uploadOptions: _uploadOptions, |
79 uploadOptions: _uploadOptions, | 75 uploadMedia: _uploadMedia, |
80 uploadMedia: _uploadMedia, | 76 downloadOptions: _downloadOptions); |
81 downloadOptions: _downloadOptions); | |
82 return _response.then((data) => new WebfontList.fromJson(data)); | 77 return _response.then((data) => new WebfontList.fromJson(data)); |
83 } | 78 } |
84 | |
85 } | 79 } |
86 | 80 |
| 81 class Webfont { |
| 82 /// The category of the font. |
| 83 core.String category; |
87 | 84 |
| 85 /// The name of the font. |
| 86 core.String family; |
88 | 87 |
89 class Webfont { | 88 /// The font files (with all supported scripts) for each one of the available |
90 /** The category of the font. */ | 89 /// variants, as a key : value map. |
91 core.String category; | |
92 /** The name of the font. */ | |
93 core.String family; | |
94 /** | |
95 * The font files (with all supported scripts) for each one of the available | |
96 * variants, as a key : value map. | |
97 */ | |
98 core.Map<core.String, core.String> files; | 90 core.Map<core.String, core.String> files; |
99 /** This kind represents a webfont object in the webfonts service. */ | 91 |
| 92 /// This kind represents a webfont object in the webfonts service. |
100 core.String kind; | 93 core.String kind; |
101 /** | 94 |
102 * The date (format "yyyy-MM-dd") the font was modified for the last time. | 95 /// The date (format "yyyy-MM-dd") the font was modified for the last time. |
103 */ | |
104 core.DateTime lastModified; | 96 core.DateTime lastModified; |
105 /** The scripts supported by the font. */ | 97 |
| 98 /// The scripts supported by the font. |
106 core.List<core.String> subsets; | 99 core.List<core.String> subsets; |
107 /** The available variants for the font. */ | 100 |
| 101 /// The available variants for the font. |
108 core.List<core.String> variants; | 102 core.List<core.String> variants; |
109 /** The font version. */ | 103 |
| 104 /// The font version. |
110 core.String version; | 105 core.String version; |
111 | 106 |
112 Webfont(); | 107 Webfont(); |
113 | 108 |
114 Webfont.fromJson(core.Map _json) { | 109 Webfont.fromJson(core.Map _json) { |
115 if (_json.containsKey("category")) { | 110 if (_json.containsKey("category")) { |
116 category = _json["category"]; | 111 category = _json["category"]; |
117 } | 112 } |
118 if (_json.containsKey("family")) { | 113 if (_json.containsKey("family")) { |
119 family = _json["family"]; | 114 family = _json["family"]; |
(...skipping 12 matching lines...) Expand all Loading... |
132 } | 127 } |
133 if (_json.containsKey("variants")) { | 128 if (_json.containsKey("variants")) { |
134 variants = _json["variants"]; | 129 variants = _json["variants"]; |
135 } | 130 } |
136 if (_json.containsKey("version")) { | 131 if (_json.containsKey("version")) { |
137 version = _json["version"]; | 132 version = _json["version"]; |
138 } | 133 } |
139 } | 134 } |
140 | 135 |
141 core.Map<core.String, core.Object> toJson() { | 136 core.Map<core.String, core.Object> toJson() { |
142 final core.Map<core.String, core.Object> _json = new core.Map<core.String, c
ore.Object>(); | 137 final core.Map<core.String, core.Object> _json = |
| 138 new core.Map<core.String, core.Object>(); |
143 if (category != null) { | 139 if (category != null) { |
144 _json["category"] = category; | 140 _json["category"] = category; |
145 } | 141 } |
146 if (family != null) { | 142 if (family != null) { |
147 _json["family"] = family; | 143 _json["family"] = family; |
148 } | 144 } |
149 if (files != null) { | 145 if (files != null) { |
150 _json["files"] = files; | 146 _json["files"] = files; |
151 } | 147 } |
152 if (kind != null) { | 148 if (kind != null) { |
153 _json["kind"] = kind; | 149 _json["kind"] = kind; |
154 } | 150 } |
155 if (lastModified != null) { | 151 if (lastModified != null) { |
156 _json["lastModified"] = "${(lastModified).year.toString().padLeft(4, '0')}
-${(lastModified).month.toString().padLeft(2, '0')}-${(lastModified).day.toStrin
g().padLeft(2, '0')}"; | 152 _json["lastModified"] = |
| 153 "${(lastModified).year.toString().padLeft(4, '0')}-${(lastModified).mo
nth.toString().padLeft(2, '0')}-${(lastModified).day.toString().padLeft(2, '0')}
"; |
157 } | 154 } |
158 if (subsets != null) { | 155 if (subsets != null) { |
159 _json["subsets"] = subsets; | 156 _json["subsets"] = subsets; |
160 } | 157 } |
161 if (variants != null) { | 158 if (variants != null) { |
162 _json["variants"] = variants; | 159 _json["variants"] = variants; |
163 } | 160 } |
164 if (version != null) { | 161 if (version != null) { |
165 _json["version"] = version; | 162 _json["version"] = version; |
166 } | 163 } |
167 return _json; | 164 return _json; |
168 } | 165 } |
169 } | 166 } |
170 | 167 |
171 class WebfontList { | 168 class WebfontList { |
172 /** The list of fonts currently served by the Google Fonts API. */ | 169 /// The list of fonts currently served by the Google Fonts API. |
173 core.List<Webfont> items; | 170 core.List<Webfont> items; |
174 /** | 171 |
175 * This kind represents a list of webfont objects in the webfonts service. | 172 /// This kind represents a list of webfont objects in the webfonts service. |
176 */ | |
177 core.String kind; | 173 core.String kind; |
178 | 174 |
179 WebfontList(); | 175 WebfontList(); |
180 | 176 |
181 WebfontList.fromJson(core.Map _json) { | 177 WebfontList.fromJson(core.Map _json) { |
182 if (_json.containsKey("items")) { | 178 if (_json.containsKey("items")) { |
183 items = _json["items"].map((value) => new Webfont.fromJson(value)).toList(
); | 179 items = |
| 180 _json["items"].map((value) => new Webfont.fromJson(value)).toList(); |
184 } | 181 } |
185 if (_json.containsKey("kind")) { | 182 if (_json.containsKey("kind")) { |
186 kind = _json["kind"]; | 183 kind = _json["kind"]; |
187 } | 184 } |
188 } | 185 } |
189 | 186 |
190 core.Map<core.String, core.Object> toJson() { | 187 core.Map<core.String, core.Object> toJson() { |
191 final core.Map<core.String, core.Object> _json = new core.Map<core.String, c
ore.Object>(); | 188 final core.Map<core.String, core.Object> _json = |
| 189 new core.Map<core.String, core.Object>(); |
192 if (items != null) { | 190 if (items != null) { |
193 _json["items"] = items.map((value) => (value).toJson()).toList(); | 191 _json["items"] = items.map((value) => (value).toJson()).toList(); |
194 } | 192 } |
195 if (kind != null) { | 193 if (kind != null) { |
196 _json["kind"] = kind; | 194 _json["kind"] = kind; |
197 } | 195 } |
198 return _json; | 196 return _json; |
199 } | 197 } |
200 } | 198 } |
OLD | NEW |