@maxim_mazurok/gapi.client.gmailpostmastertools-v1 0.0.20220811

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts ADDED
@@ -0,0 +1,254 @@
1
+ /* Type definitions for non-npm package Gmail Postmaster Tools API v1 0.0 */
2
+ // Project: https://developers.google.com/gmail/postmaster
3
+ // Definitions by: Maxim Mazurok <https://github.com/Maxim-Mazurok>
4
+ // Nick Amoscato <https://github.com/namoscato>
5
+ // Declan Vong <https://github.com/declanvong>
6
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
7
+ // TypeScript Version: 2.8
8
+
9
+ // IMPORTANT
10
+ // This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator. Please do not edit it manually.
11
+ // In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator
12
+ // Generated from: https://gmailpostmastertools.googleapis.com/$discovery/rest?version=v1
13
+ // Revision: 20220811
14
+
15
+ /// <reference types="gapi.client" />
16
+
17
+ declare namespace gapi.client {
18
+ /** Load Gmail Postmaster Tools API v1 */
19
+ function load(urlOrObject: "https://gmailpostmastertools.googleapis.com/$discovery/rest?version=v1"): Promise<void>;
20
+ /** @deprecated Please load APIs with discovery documents. */
21
+ function load(name: "gmailpostmastertools", version: "v1"): Promise<void>;
22
+ /** @deprecated Please load APIs with discovery documents. */
23
+ function load(name: "gmailpostmastertools", version: "v1", callback: () => any): void;
24
+
25
+ namespace gmailpostmastertools {
26
+ interface DeliveryError {
27
+ /** The class of delivery error. */
28
+ errorClass?: string;
29
+ /** The ratio of messages where the error occurred vs all authenticated traffic. */
30
+ errorRatio?: number;
31
+ /** The type of delivery error. */
32
+ errorType?: string;
33
+ }
34
+ interface Domain {
35
+ /** Timestamp when the user registered this domain. Assigned by the server. */
36
+ createTime?: string;
37
+ /** The resource name of the Domain. Domain names have the form `domains/{domain_name}`, where domain_name is the fully qualified domain name (i.e., mymail.mydomain.com). */
38
+ name?: string;
39
+ /** User’s permission for this domain. Assigned by the server. */
40
+ permission?: string;
41
+ }
42
+ interface FeedbackLoop {
43
+ /** Feedback loop identifier that uniquely identifies individual campaigns. */
44
+ id?: string;
45
+ /** The ratio of user marked spam messages with the identifier vs the total number of inboxed messages with that identifier. */
46
+ spamRatio?: number;
47
+ }
48
+ interface IpReputation {
49
+ /** Total number of unique IPs in this reputation category. This metric only pertains to traffic that passed [SPF](http://www.openspf.org/) or [DKIM](http://www.dkim.org/). */
50
+ ipCount?: string;
51
+ /** The reputation category this IP reputation represents. */
52
+ reputation?: string;
53
+ /** A sample of IPs in this reputation category. */
54
+ sampleIps?: string[];
55
+ }
56
+ interface ListDomainsResponse {
57
+ /** The list of domains. */
58
+ domains?: Domain[];
59
+ /** Token to retrieve the next page of results, or empty if there are no more results in the list. */
60
+ nextPageToken?: string;
61
+ }
62
+ interface ListTrafficStatsResponse {
63
+ /** Token to retrieve the next page of results, or empty if there are no more results in the list. */
64
+ nextPageToken?: string;
65
+ /** The list of TrafficStats. */
66
+ trafficStats?: TrafficStats[];
67
+ }
68
+ interface TrafficStats {
69
+ /** Delivery errors for the domain. This metric only pertains to traffic that passed [SPF](http://www.openspf.org/) or [DKIM](http://www.dkim.org/). */
70
+ deliveryErrors?: DeliveryError[];
71
+ /** The ratio of mail that successfully authenticated with DKIM vs. all mail that attempted to authenticate with [DKIM](http://www.dkim.org/). Spoofed mail is excluded. */
72
+ dkimSuccessRatio?: number;
73
+ /**
74
+ * The ratio of mail that passed [DMARC](https://dmarc.org/) alignment checks vs all mail received from the domain that successfully authenticated with either of
75
+ * [SPF](http://www.openspf.org/) or [DKIM](http://www.dkim.org/).
76
+ */
77
+ dmarcSuccessRatio?: number;
78
+ /** Reputation of the domain. */
79
+ domainReputation?: string;
80
+ /**
81
+ * The ratio of incoming mail (to Gmail), that passed secure transport (TLS) vs all mail received from that domain. This metric only pertains to traffic that passed
82
+ * [SPF](http://www.openspf.org/) or [DKIM](http://www.dkim.org/).
83
+ */
84
+ inboundEncryptionRatio?: number;
85
+ /**
86
+ * Reputation information pertaining to the IP addresses of the email servers for the domain. There is exactly one entry for each reputation category except
87
+ * REPUTATION_CATEGORY_UNSPECIFIED.
88
+ */
89
+ ipReputations?: IpReputation[];
90
+ /**
91
+ * The resource name of the traffic statistics. Traffic statistic names have the form `domains/{domain}/trafficStats/{date}`, where domain_name is the fully qualified domain name
92
+ * (i.e., mymail.mydomain.com) of the domain this traffic statistics pertains to and date is the date in yyyymmdd format that these statistics corresponds to. For example:
93
+ * domains/mymail.mydomain.com/trafficStats/20160807
94
+ */
95
+ name?: string;
96
+ /** The ratio of outgoing mail (from Gmail) that was accepted over secure transport (TLS). */
97
+ outboundEncryptionRatio?: number;
98
+ /**
99
+ * Spammy [Feedback loop identifiers] (https://support.google.com/mail/answer/6254652) with their individual spam rates. This metric only pertains to traffic that is authenticated by
100
+ * [DKIM](http://www.dkim.org/).
101
+ */
102
+ spammyFeedbackLoops?: FeedbackLoop[];
103
+ /** The ratio of mail that successfully authenticated with SPF vs. all mail that attempted to authenticate with [SPF](http://www.openspf.org/). Spoofed mail is excluded. */
104
+ spfSuccessRatio?: number;
105
+ /** The ratio of user-report spam vs. email that was sent to the inbox. This metric only pertains to emails authenticated by [DKIM](http://www.dkim.org/). */
106
+ userReportedSpamRatio?: number;
107
+ }
108
+ interface TrafficStatsResource {
109
+ /** Get traffic statistics for a domain on a specific date. Returns PERMISSION_DENIED if user does not have permission to access TrafficStats for the domain. */
110
+ get(request?: {
111
+ /** V1 error format. */
112
+ "$.xgafv"?: string;
113
+ /** OAuth access token. */
114
+ access_token?: string;
115
+ /** Data format for response. */
116
+ alt?: string;
117
+ /** JSONP */
118
+ callback?: string;
119
+ /** Selector specifying which fields to include in a partial response. */
120
+ fields?: string;
121
+ /** 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. */
122
+ key?: string;
123
+ /** The resource name of the traffic statistics to get. E.g., domains/mymail.mydomain.com/trafficStats/20160807. */
124
+ name: string;
125
+ /** OAuth 2.0 token for the current user. */
126
+ oauth_token?: string;
127
+ /** Returns response with indentations and line breaks. */
128
+ prettyPrint?: boolean;
129
+ /** 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. */
130
+ quotaUser?: string;
131
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
132
+ upload_protocol?: string;
133
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
134
+ uploadType?: string;
135
+ }): Request<TrafficStats>;
136
+ /** List traffic statistics for all available days. Returns PERMISSION_DENIED if user does not have permission to access TrafficStats for the domain. */
137
+ list(request?: {
138
+ /** V1 error format. */
139
+ "$.xgafv"?: string;
140
+ /** OAuth access token. */
141
+ access_token?: string;
142
+ /** Data format for response. */
143
+ alt?: string;
144
+ /** JSONP */
145
+ callback?: string;
146
+ /** Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant. */
147
+ "endDate.day"?: number;
148
+ /** Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day. */
149
+ "endDate.month"?: number;
150
+ /** Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year. */
151
+ "endDate.year"?: number;
152
+ /** Selector specifying which fields to include in a partial response. */
153
+ fields?: string;
154
+ /** 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. */
155
+ key?: string;
156
+ /** OAuth 2.0 token for the current user. */
157
+ oauth_token?: string;
158
+ /** Requested page size. Server may return fewer TrafficStats than requested. If unspecified, server will pick an appropriate default. */
159
+ pageSize?: number;
160
+ /**
161
+ * The next_page_token value returned from a previous List request, if any. This is the value of ListTrafficStatsResponse.next_page_token returned from the previous call to
162
+ * `ListTrafficStats` method.
163
+ */
164
+ pageToken?: string;
165
+ /**
166
+ * The resource name of the domain whose traffic statistics we'd like to list. It should have the form `domains/{domain_name}`, where domain_name is the fully qualified domain
167
+ * name.
168
+ */
169
+ parent: string;
170
+ /** Returns response with indentations and line breaks. */
171
+ prettyPrint?: boolean;
172
+ /** 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. */
173
+ quotaUser?: string;
174
+ /** Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant. */
175
+ "startDate.day"?: number;
176
+ /** Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day. */
177
+ "startDate.month"?: number;
178
+ /** Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year. */
179
+ "startDate.year"?: number;
180
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
181
+ upload_protocol?: string;
182
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
183
+ uploadType?: string;
184
+ }): Request<ListTrafficStatsResponse>;
185
+ }
186
+ interface DomainsResource {
187
+ /** Gets a specific domain registered by the client. Returns NOT_FOUND if the domain does not exist. */
188
+ get(request?: {
189
+ /** V1 error format. */
190
+ "$.xgafv"?: string;
191
+ /** OAuth access token. */
192
+ access_token?: string;
193
+ /** Data format for response. */
194
+ alt?: string;
195
+ /** JSONP */
196
+ callback?: string;
197
+ /** Selector specifying which fields to include in a partial response. */
198
+ fields?: string;
199
+ /** 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. */
200
+ key?: string;
201
+ /** The resource name of the domain. It should have the form `domains/{domain_name}`, where domain_name is the fully qualified domain name. */
202
+ name: string;
203
+ /** OAuth 2.0 token for the current user. */
204
+ oauth_token?: string;
205
+ /** Returns response with indentations and line breaks. */
206
+ prettyPrint?: boolean;
207
+ /** 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. */
208
+ quotaUser?: string;
209
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
210
+ upload_protocol?: string;
211
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
212
+ uploadType?: string;
213
+ }): Request<Domain>;
214
+ /**
215
+ * Lists the domains that have been registered by the client. The order of domains in the response is unspecified and non-deterministic. Newly created domains will not necessarily be
216
+ * added to the end of this list.
217
+ */
218
+ list(request?: {
219
+ /** V1 error format. */
220
+ "$.xgafv"?: string;
221
+ /** OAuth access token. */
222
+ access_token?: string;
223
+ /** Data format for response. */
224
+ alt?: string;
225
+ /** JSONP */
226
+ callback?: string;
227
+ /** Selector specifying which fields to include in a partial response. */
228
+ fields?: string;
229
+ /** 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. */
230
+ key?: string;
231
+ /** OAuth 2.0 token for the current user. */
232
+ oauth_token?: string;
233
+ /** Requested page size. Server may return fewer domains than requested. If unspecified, server will pick an appropriate default. */
234
+ pageSize?: number;
235
+ /**
236
+ * The next_page_token value returned from a previous List request, if any. This is the value of ListDomainsResponse.next_page_token returned from the previous call to
237
+ * `ListDomains` method.
238
+ */
239
+ pageToken?: string;
240
+ /** Returns response with indentations and line breaks. */
241
+ prettyPrint?: boolean;
242
+ /** 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. */
243
+ quotaUser?: string;
244
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
245
+ upload_protocol?: string;
246
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
247
+ uploadType?: string;
248
+ }): Request<ListDomainsResponse>;
249
+ trafficStats: TrafficStatsResource;
250
+ }
251
+
252
+ const domains: DomainsResource;
253
+ }
254
+ }
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@maxim_mazurok/gapi.client.gmailpostmastertools-v1",
3
+ "version": "0.0.20220811",
4
+ "description": "TypeScript typings for Gmail Postmaster Tools API v1",
5
+ "license": "MIT",
6
+ "author": {
7
+ "email": "maxim@mazurok.com",
8
+ "name": "Maxim Mazurok",
9
+ "url": "https://maxim.mazurok.com"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/Maxim-Mazurok/google-api-typings-generator.git"
14
+ },
15
+ "types": "index.d.ts",
16
+ "dependencies": {
17
+ "@types/gapi.client": "*",
18
+ "@types/gapi.client.discovery": "*"
19
+ }
20
+ }
package/readme.md ADDED
@@ -0,0 +1,78 @@
1
+ # TypeScript typings for Gmail Postmaster Tools API v1
2
+
3
+ The Postmaster Tools API is a RESTful API that provides programmatic access to email traffic metrics (like spam reports, delivery errors etc) otherwise available through the Gmail Postmaster Tools UI currently.
4
+ For detailed description please check [documentation](https://developers.google.com/gmail/postmaster).
5
+
6
+ ## Installing
7
+
8
+ Install typings for Gmail Postmaster Tools API:
9
+
10
+ ```
11
+ npm install @types/gapi.client.gmailpostmastertools-v1 --save-dev
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ You need to initialize Google API client in your code:
17
+
18
+ ```typescript
19
+ gapi.load('client', () => {
20
+ // now we can use gapi.client
21
+ // ...
22
+ });
23
+ ```
24
+
25
+ Then load api client wrapper:
26
+
27
+ ```typescript
28
+ gapi.client.load('https://gmailpostmastertools.googleapis.com/$discovery/rest?version=v1', () => {
29
+ // now we can use:
30
+ // gapi.client.gmailpostmastertools
31
+ });
32
+ ```
33
+
34
+ ```typescript
35
+ // Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
36
+ gapi.client.load('gmailpostmastertools', 'v1', () => {
37
+ // now we can use:
38
+ // gapi.client.gmailpostmastertools
39
+ });
40
+ ```
41
+
42
+ Don't forget to authenticate your client before sending any request to resources:
43
+
44
+ ```typescript
45
+ // declare client_id registered in Google Developers Console
46
+ var client_id = '',
47
+ scope = [
48
+ // See email traffic metrics for the domains you have registered in Gmail Postmaster Tools
49
+ 'https://www.googleapis.com/auth/postmaster.readonly',
50
+ ],
51
+ immediate = true;
52
+ // ...
53
+
54
+ gapi.auth.authorize(
55
+ { client_id: client_id, scope: scope, immediate: immediate },
56
+ authResult => {
57
+ if (authResult && !authResult.error) {
58
+ /* handle successful authorization */
59
+ } else {
60
+ /* handle authorization error */
61
+ }
62
+ });
63
+ ```
64
+
65
+ After that you can use Gmail Postmaster Tools API resources: <!-- TODO: make this work for multiple namespaces -->
66
+
67
+ ```typescript
68
+
69
+ /*
70
+ Gets a specific domain registered by the client. Returns NOT_FOUND if the domain does not exist.
71
+ */
72
+ await gapi.client.gmailpostmastertools.domains.get({ name: "name", });
73
+
74
+ /*
75
+ Lists the domains that have been registered by the client. The order of domains in the response is unspecified and non-deterministic. Newly created domains will not necessarily be added to the end of this list.
76
+ */
77
+ await gapi.client.gmailpostmastertools.domains.list({ });
78
+ ```
package/tests.ts ADDED
@@ -0,0 +1,61 @@
1
+ /* This is stub file for gapi.client.gmailpostmastertools-v1 definition tests */
2
+ // IMPORTANT
3
+ // This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator. Please do not edit it manually.
4
+ // In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator
5
+
6
+ // Revision: 20220811
7
+
8
+ gapi.load('client', async () => {
9
+ /** now we can use gapi.client */
10
+
11
+ await gapi.client.load('https://gmailpostmastertools.googleapis.com/$discovery/rest?version=v1');
12
+ /** now we can use gapi.client.gmailpostmastertools */
13
+
14
+ /** don't forget to authenticate your client before sending any request to resources: */
15
+ /** declare client_id registered in Google Developers Console */
16
+ const client_id = '<<PUT YOUR CLIENT ID HERE>>';
17
+ const scope = [
18
+ /** See email traffic metrics for the domains you have registered in Gmail Postmaster Tools */
19
+ 'https://www.googleapis.com/auth/postmaster.readonly',
20
+ ];
21
+ const immediate = false;
22
+ gapi.auth.authorize({ client_id, scope, immediate }, authResult => {
23
+ if (authResult && !authResult.error) {
24
+ /** handle successful authorization */
25
+ run();
26
+ } else {
27
+ /** handle authorization error */
28
+ }
29
+ });
30
+
31
+ async function run() {
32
+ /** Gets a specific domain registered by the client. Returns NOT_FOUND if the domain does not exist. */
33
+ await gapi.client.gmailpostmastertools.domains.get({
34
+ name: "Test string",
35
+ });
36
+ /**
37
+ * Lists the domains that have been registered by the client. The order of domains in the response is unspecified and non-deterministic. Newly created domains will not necessarily be added
38
+ * to the end of this list.
39
+ */
40
+ await gapi.client.gmailpostmastertools.domains.list({
41
+ pageSize: 42,
42
+ pageToken: "Test string",
43
+ });
44
+ /** Get traffic statistics for a domain on a specific date. Returns PERMISSION_DENIED if user does not have permission to access TrafficStats for the domain. */
45
+ await gapi.client.gmailpostmastertools.domains.trafficStats.get({
46
+ name: "Test string",
47
+ });
48
+ /** List traffic statistics for all available days. Returns PERMISSION_DENIED if user does not have permission to access TrafficStats for the domain. */
49
+ await gapi.client.gmailpostmastertools.domains.trafficStats.list({
50
+ "endDate.day": 42,
51
+ "endDate.month": 42,
52
+ "endDate.year": 42,
53
+ pageSize: 42,
54
+ pageToken: "Test string",
55
+ parent: "Test string",
56
+ "startDate.day": 42,
57
+ "startDate.month": 42,
58
+ "startDate.year": 42,
59
+ });
60
+ }
61
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "lib": ["es6", "dom"],
5
+ "noImplicitAny": true,
6
+ "noImplicitThis": true,
7
+ "strictNullChecks": true,
8
+ "baseUrl": "../",
9
+ "typeRoots": [
10
+ "../"
11
+ ],
12
+ "types": [],
13
+ "noEmit": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "strictFunctionTypes": true
16
+ },
17
+ "files": ["index.d.ts", "tests.ts"]
18
+ }
package/tslint.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "dtslint/dtslint.json",
3
+ "rules": {
4
+ "no-redundant-jsdoc": false
5
+ }
6
+ }