@maxim_mazurok/gapi.client.webcontentpublisher-v1 0.0.0 → 0.0.20260602
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 +71 -1
- package/package.json +16 -3
- package/readme.md +97 -0
- package/README.md +0 -3
package/index.d.ts
CHANGED
|
@@ -1 +1,71 @@
|
|
|
1
|
-
|
|
1
|
+
/* Type definitions for non-npm package Web Content Publisher API v1 0.0 */
|
|
2
|
+
// Project: https://developers.google.com/news/subscribe
|
|
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
|
+
|
|
8
|
+
// IMPORTANT
|
|
9
|
+
// This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator. Please do not edit it manually.
|
|
10
|
+
// In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator
|
|
11
|
+
// Generated from: https://webcontentpublisher.googleapis.com/$discovery/rest?version=v1
|
|
12
|
+
// Revision: 20260602
|
|
13
|
+
|
|
14
|
+
/// <reference types="gapi.client" />
|
|
15
|
+
|
|
16
|
+
declare namespace gapi.client {
|
|
17
|
+
/** Load Web Content Publisher API v1 */
|
|
18
|
+
function load(
|
|
19
|
+
urlOrObject: 'https://webcontentpublisher.googleapis.com/$discovery/rest?version=v1',
|
|
20
|
+
): Promise<void>;
|
|
21
|
+
/** @deprecated Please load APIs with discovery documents. */
|
|
22
|
+
function load(name: 'webcontentpublisher', version: 'v1'): Promise<void>;
|
|
23
|
+
/** @deprecated Please load APIs with discovery documents. */
|
|
24
|
+
function load(
|
|
25
|
+
name: 'webcontentpublisher',
|
|
26
|
+
version: 'v1',
|
|
27
|
+
callback: () => any,
|
|
28
|
+
): void;
|
|
29
|
+
|
|
30
|
+
namespace webcontentpublisher {
|
|
31
|
+
interface CheckFreeAccessResponse {
|
|
32
|
+
/** True if free access should be allowed, false otherwise. */
|
|
33
|
+
isAllowed?: boolean;
|
|
34
|
+
}
|
|
35
|
+
interface PublicationsResource {
|
|
36
|
+
/** Checks if a user is eligible for free article access. */
|
|
37
|
+
checkFreeAccess(request?: {
|
|
38
|
+
/** V1 error format. */
|
|
39
|
+
'$.xgafv'?: '1' | '2';
|
|
40
|
+
/** OAuth access token. */
|
|
41
|
+
access_token?: string;
|
|
42
|
+
/** Data format for response. */
|
|
43
|
+
alt?: 'json' | 'media' | 'proto';
|
|
44
|
+
/** JSONP */
|
|
45
|
+
callback?: string;
|
|
46
|
+
/** Selector specifying which fields to include in a partial response. */
|
|
47
|
+
fields?: string;
|
|
48
|
+
/** Required. The HTTP referrer. */
|
|
49
|
+
httpReferrer?: string;
|
|
50
|
+
/** 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. */
|
|
51
|
+
key?: string;
|
|
52
|
+
/** Required. The resource name of the publication. Format: publications/{publication_id} */
|
|
53
|
+
name: string;
|
|
54
|
+
/** OAuth 2.0 token for the current user. */
|
|
55
|
+
oauth_token?: string;
|
|
56
|
+
/** Returns response with indentations and line breaks. */
|
|
57
|
+
prettyPrint?: boolean;
|
|
58
|
+
/** 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. */
|
|
59
|
+
quotaUser?: string;
|
|
60
|
+
/** Upload protocol for media (e.g. "raw", "multipart"). */
|
|
61
|
+
upload_protocol?: string;
|
|
62
|
+
/** Legacy upload protocol for media (e.g. "media", "multipart"). */
|
|
63
|
+
uploadType?: string;
|
|
64
|
+
/** Required. The URI of the content. */
|
|
65
|
+
uri?: string;
|
|
66
|
+
}): Request<CheckFreeAccessResponse>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const publications: PublicationsResource;
|
|
70
|
+
}
|
|
71
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maxim_mazurok/gapi.client.webcontentpublisher-v1",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.20260602",
|
|
4
|
+
"description": "TypeScript typings for Web Content Publisher API v1",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/Maxim-Mazurok/google-api-typings-generator.git"
|
|
8
|
+
},
|
|
5
9
|
"license": "MIT",
|
|
6
|
-
"
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "Maxim Mazurok",
|
|
12
|
+
"email": "maxim@mazurok.com",
|
|
13
|
+
"url": "https://maxim.mazurok.com"
|
|
14
|
+
},
|
|
15
|
+
"types": "index.d.ts",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@types/gapi.client": "*",
|
|
18
|
+
"@types/gapi.client.discovery-v1": "*"
|
|
19
|
+
}
|
|
7
20
|
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# TypeScript typings for Web Content Publisher API v1
|
|
2
|
+
|
|
3
|
+
webcontentpublisher.googleapis.com API, a service for web content publishers.
|
|
4
|
+
For detailed description please check [documentation](https://developers.google.com/news/subscribe).
|
|
5
|
+
|
|
6
|
+
## Installing
|
|
7
|
+
|
|
8
|
+
Install typings for Web Content Publisher API:
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
npm install @types/gapi.client.webcontentpublisher-v1 --save-dev
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## TypeScript 6.0+
|
|
15
|
+
|
|
16
|
+
TypeScript 6.0 changed `types` to default to `[]`. You must now explicitly list type packages in `tsconfig.json`:
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"compilerOptions": {
|
|
21
|
+
"types": [
|
|
22
|
+
"gapi",
|
|
23
|
+
"gapi.auth2",
|
|
24
|
+
"gapi.client",
|
|
25
|
+
"gapi.client.webcontentpublisher-v1"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
You need to initialize Google API client in your code:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
gapi.load('client', () => {
|
|
37
|
+
// now we can use gapi.client
|
|
38
|
+
// ...
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Then load api client wrapper:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
gapi.client.load(
|
|
46
|
+
'https://webcontentpublisher.googleapis.com/$discovery/rest?version=v1',
|
|
47
|
+
() => {
|
|
48
|
+
// now we can use:
|
|
49
|
+
// gapi.client.webcontentpublisher
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
// Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
|
|
56
|
+
gapi.client.load('webcontentpublisher', 'v1', () => {
|
|
57
|
+
// now we can use:
|
|
58
|
+
// gapi.client.webcontentpublisher
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Don't forget to authenticate your client before sending any request to resources:
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
// declare client_id registered in Google Developers Console
|
|
66
|
+
var client_id = '',
|
|
67
|
+
scope = [
|
|
68
|
+
// See and review your subscription information
|
|
69
|
+
'https://www.googleapis.com/auth/subscribewithgoogle.publications.entitlements.readonly',
|
|
70
|
+
],
|
|
71
|
+
immediate = true;
|
|
72
|
+
// ...
|
|
73
|
+
|
|
74
|
+
gapi.auth.authorize(
|
|
75
|
+
{client_id: client_id, scope: scope, immediate: immediate},
|
|
76
|
+
authResult => {
|
|
77
|
+
if (authResult && !authResult.error) {
|
|
78
|
+
/* handle successful authorization */
|
|
79
|
+
} else {
|
|
80
|
+
/* handle authorization error */
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
After that you can use Web Content Publisher API resources: <!-- TODO: make this work for multiple namespaces -->
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
/*
|
|
90
|
+
Checks if a user is eligible for free article access.
|
|
91
|
+
*/
|
|
92
|
+
await gapi.client.webcontentpublisher.publications.checkFreeAccess({
|
|
93
|
+
name: 'name',
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
For provenance information see [Provenance section on NPM](https://www.npmjs.com/package/@maxim_mazurok/gapi.client.webcontentpublisher-v1#Provenance:~:text=none-,Provenance,-Built%20and%20signed)
|
package/README.md
DELETED