@maxim_mazurok/gapi.client.adsense-v2 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 +1221 -0
- package/package.json +20 -0
- package/readme.md +86 -0
- package/tests.ts +211 -0
- package/tsconfig.json +18 -0
- package/tslint.json +6 -0
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@maxim_mazurok/gapi.client.adsense-v2",
|
|
3
|
+
"version": "0.0.20220811",
|
|
4
|
+
"description": "TypeScript typings for AdSense Management API v2",
|
|
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,86 @@
|
|
|
1
|
+
# TypeScript typings for AdSense Management API v2
|
|
2
|
+
|
|
3
|
+
The AdSense Management API allows publishers to access their inventory and run earnings and performance reports.
|
|
4
|
+
For detailed description please check [documentation](https://developers.google.com/adsense/management/).
|
|
5
|
+
|
|
6
|
+
## Installing
|
|
7
|
+
|
|
8
|
+
Install typings for AdSense Management API:
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
npm install @types/gapi.client.adsense-v2 --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://adsense.googleapis.com/$discovery/rest?version=v2', () => {
|
|
29
|
+
// now we can use:
|
|
30
|
+
// gapi.client.adsense
|
|
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('adsense', 'v2', () => {
|
|
37
|
+
// now we can use:
|
|
38
|
+
// gapi.client.adsense
|
|
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
|
+
// View and manage your AdSense data
|
|
49
|
+
'https://www.googleapis.com/auth/adsense',
|
|
50
|
+
|
|
51
|
+
// View your AdSense data
|
|
52
|
+
'https://www.googleapis.com/auth/adsense.readonly',
|
|
53
|
+
],
|
|
54
|
+
immediate = true;
|
|
55
|
+
// ...
|
|
56
|
+
|
|
57
|
+
gapi.auth.authorize(
|
|
58
|
+
{ client_id: client_id, scope: scope, immediate: immediate },
|
|
59
|
+
authResult => {
|
|
60
|
+
if (authResult && !authResult.error) {
|
|
61
|
+
/* handle successful authorization */
|
|
62
|
+
} else {
|
|
63
|
+
/* handle authorization error */
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
After that you can use AdSense Management API resources: <!-- TODO: make this work for multiple namespaces -->
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
|
|
72
|
+
/*
|
|
73
|
+
Gets information about the selected AdSense account.
|
|
74
|
+
*/
|
|
75
|
+
await gapi.client.adsense.accounts.get({ name: "name", });
|
|
76
|
+
|
|
77
|
+
/*
|
|
78
|
+
Lists all accounts available to this user.
|
|
79
|
+
*/
|
|
80
|
+
await gapi.client.adsense.accounts.list({ });
|
|
81
|
+
|
|
82
|
+
/*
|
|
83
|
+
Lists all accounts directly managed by the given AdSense account.
|
|
84
|
+
*/
|
|
85
|
+
await gapi.client.adsense.accounts.listChildAccounts({ parent: "parent", });
|
|
86
|
+
```
|
package/tests.ts
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/* This is stub file for gapi.client.adsense-v2 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://adsense.googleapis.com/$discovery/rest?version=v2');
|
|
12
|
+
/** now we can use gapi.client.adsense */
|
|
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
|
+
/** View and manage your AdSense data */
|
|
19
|
+
'https://www.googleapis.com/auth/adsense',
|
|
20
|
+
/** View your AdSense data */
|
|
21
|
+
'https://www.googleapis.com/auth/adsense.readonly',
|
|
22
|
+
];
|
|
23
|
+
const immediate = false;
|
|
24
|
+
gapi.auth.authorize({ client_id, scope, immediate }, authResult => {
|
|
25
|
+
if (authResult && !authResult.error) {
|
|
26
|
+
/** handle successful authorization */
|
|
27
|
+
run();
|
|
28
|
+
} else {
|
|
29
|
+
/** handle authorization error */
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
async function run() {
|
|
34
|
+
/** Gets information about the selected AdSense account. */
|
|
35
|
+
await gapi.client.adsense.accounts.get({
|
|
36
|
+
name: "Test string",
|
|
37
|
+
});
|
|
38
|
+
/** Lists all accounts available to this user. */
|
|
39
|
+
await gapi.client.adsense.accounts.list({
|
|
40
|
+
pageSize: 42,
|
|
41
|
+
pageToken: "Test string",
|
|
42
|
+
});
|
|
43
|
+
/** Lists all accounts directly managed by the given AdSense account. */
|
|
44
|
+
await gapi.client.adsense.accounts.listChildAccounts({
|
|
45
|
+
pageSize: 42,
|
|
46
|
+
pageToken: "Test string",
|
|
47
|
+
parent: "Test string",
|
|
48
|
+
});
|
|
49
|
+
/** Gets the ad client from the given resource name. */
|
|
50
|
+
await gapi.client.adsense.accounts.adclients.get({
|
|
51
|
+
name: "Test string",
|
|
52
|
+
});
|
|
53
|
+
/**
|
|
54
|
+
* Gets the AdSense code for a given ad client. This returns what was previously known as the 'auto ad code'. This is only supported for ad clients with a product_code of AFC. For more
|
|
55
|
+
* information, see [About the AdSense code](https://support.google.com/adsense/answer/9274634).
|
|
56
|
+
*/
|
|
57
|
+
await gapi.client.adsense.accounts.adclients.getAdcode({
|
|
58
|
+
name: "Test string",
|
|
59
|
+
});
|
|
60
|
+
/** Lists all the ad clients available in an account. */
|
|
61
|
+
await gapi.client.adsense.accounts.adclients.list({
|
|
62
|
+
pageSize: 42,
|
|
63
|
+
pageToken: "Test string",
|
|
64
|
+
parent: "Test string",
|
|
65
|
+
});
|
|
66
|
+
/** Gets an ad unit from a specified account and ad client. */
|
|
67
|
+
await gapi.client.adsense.accounts.adclients.adunits.get({
|
|
68
|
+
name: "Test string",
|
|
69
|
+
});
|
|
70
|
+
/**
|
|
71
|
+
* Gets the ad unit code for a given ad unit. For more information, see [About the AdSense code](https://support.google.com/adsense/answer/9274634) and [Where to place the ad code in your
|
|
72
|
+
* HTML](https://support.google.com/adsense/answer/9190028).
|
|
73
|
+
*/
|
|
74
|
+
await gapi.client.adsense.accounts.adclients.adunits.getAdcode({
|
|
75
|
+
name: "Test string",
|
|
76
|
+
});
|
|
77
|
+
/** Lists all ad units under a specified account and ad client. */
|
|
78
|
+
await gapi.client.adsense.accounts.adclients.adunits.list({
|
|
79
|
+
pageSize: 42,
|
|
80
|
+
pageToken: "Test string",
|
|
81
|
+
parent: "Test string",
|
|
82
|
+
});
|
|
83
|
+
/** Lists all the custom channels available for an ad unit. */
|
|
84
|
+
await gapi.client.adsense.accounts.adclients.adunits.listLinkedCustomChannels({
|
|
85
|
+
pageSize: 42,
|
|
86
|
+
pageToken: "Test string",
|
|
87
|
+
parent: "Test string",
|
|
88
|
+
});
|
|
89
|
+
/** Gets information about the selected custom channel. */
|
|
90
|
+
await gapi.client.adsense.accounts.adclients.customchannels.get({
|
|
91
|
+
name: "Test string",
|
|
92
|
+
});
|
|
93
|
+
/** Lists all the custom channels available in an ad client. */
|
|
94
|
+
await gapi.client.adsense.accounts.adclients.customchannels.list({
|
|
95
|
+
pageSize: 42,
|
|
96
|
+
pageToken: "Test string",
|
|
97
|
+
parent: "Test string",
|
|
98
|
+
});
|
|
99
|
+
/** Lists all the ad units available for a custom channel. */
|
|
100
|
+
await gapi.client.adsense.accounts.adclients.customchannels.listLinkedAdUnits({
|
|
101
|
+
pageSize: 42,
|
|
102
|
+
pageToken: "Test string",
|
|
103
|
+
parent: "Test string",
|
|
104
|
+
});
|
|
105
|
+
/** Gets information about the selected url channel. */
|
|
106
|
+
await gapi.client.adsense.accounts.adclients.urlchannels.get({
|
|
107
|
+
name: "Test string",
|
|
108
|
+
});
|
|
109
|
+
/** Lists active url channels. */
|
|
110
|
+
await gapi.client.adsense.accounts.adclients.urlchannels.list({
|
|
111
|
+
pageSize: 42,
|
|
112
|
+
pageToken: "Test string",
|
|
113
|
+
parent: "Test string",
|
|
114
|
+
});
|
|
115
|
+
/** Lists all the alerts available in an account. */
|
|
116
|
+
await gapi.client.adsense.accounts.alerts.list({
|
|
117
|
+
languageCode: "Test string",
|
|
118
|
+
parent: "Test string",
|
|
119
|
+
});
|
|
120
|
+
/** Lists all the payments available for an account. */
|
|
121
|
+
await gapi.client.adsense.accounts.payments.list({
|
|
122
|
+
parent: "Test string",
|
|
123
|
+
});
|
|
124
|
+
/** Generates an ad hoc report. */
|
|
125
|
+
await gapi.client.adsense.accounts.reports.generate({
|
|
126
|
+
account: "Test string",
|
|
127
|
+
currencyCode: "Test string",
|
|
128
|
+
dateRange: "Test string",
|
|
129
|
+
dimensions: "Test string",
|
|
130
|
+
"endDate.day": 42,
|
|
131
|
+
"endDate.month": 42,
|
|
132
|
+
"endDate.year": 42,
|
|
133
|
+
filters: "Test string",
|
|
134
|
+
languageCode: "Test string",
|
|
135
|
+
limit: 42,
|
|
136
|
+
metrics: "Test string",
|
|
137
|
+
orderBy: "Test string",
|
|
138
|
+
reportingTimeZone: "Test string",
|
|
139
|
+
"startDate.day": 42,
|
|
140
|
+
"startDate.month": 42,
|
|
141
|
+
"startDate.year": 42,
|
|
142
|
+
});
|
|
143
|
+
/** Generates a csv formatted ad hoc report. */
|
|
144
|
+
await gapi.client.adsense.accounts.reports.generateCsv({
|
|
145
|
+
account: "Test string",
|
|
146
|
+
currencyCode: "Test string",
|
|
147
|
+
dateRange: "Test string",
|
|
148
|
+
dimensions: "Test string",
|
|
149
|
+
"endDate.day": 42,
|
|
150
|
+
"endDate.month": 42,
|
|
151
|
+
"endDate.year": 42,
|
|
152
|
+
filters: "Test string",
|
|
153
|
+
languageCode: "Test string",
|
|
154
|
+
limit: 42,
|
|
155
|
+
metrics: "Test string",
|
|
156
|
+
orderBy: "Test string",
|
|
157
|
+
reportingTimeZone: "Test string",
|
|
158
|
+
"startDate.day": 42,
|
|
159
|
+
"startDate.month": 42,
|
|
160
|
+
"startDate.year": 42,
|
|
161
|
+
});
|
|
162
|
+
/** Gets the saved report from the given resource name. */
|
|
163
|
+
await gapi.client.adsense.accounts.reports.getSaved({
|
|
164
|
+
name: "Test string",
|
|
165
|
+
});
|
|
166
|
+
/** Generates a saved report. */
|
|
167
|
+
await gapi.client.adsense.accounts.reports.saved.generate({
|
|
168
|
+
currencyCode: "Test string",
|
|
169
|
+
dateRange: "Test string",
|
|
170
|
+
"endDate.day": 42,
|
|
171
|
+
"endDate.month": 42,
|
|
172
|
+
"endDate.year": 42,
|
|
173
|
+
languageCode: "Test string",
|
|
174
|
+
name: "Test string",
|
|
175
|
+
reportingTimeZone: "Test string",
|
|
176
|
+
"startDate.day": 42,
|
|
177
|
+
"startDate.month": 42,
|
|
178
|
+
"startDate.year": 42,
|
|
179
|
+
});
|
|
180
|
+
/** Generates a csv formatted saved report. */
|
|
181
|
+
await gapi.client.adsense.accounts.reports.saved.generateCsv({
|
|
182
|
+
currencyCode: "Test string",
|
|
183
|
+
dateRange: "Test string",
|
|
184
|
+
"endDate.day": 42,
|
|
185
|
+
"endDate.month": 42,
|
|
186
|
+
"endDate.year": 42,
|
|
187
|
+
languageCode: "Test string",
|
|
188
|
+
name: "Test string",
|
|
189
|
+
reportingTimeZone: "Test string",
|
|
190
|
+
"startDate.day": 42,
|
|
191
|
+
"startDate.month": 42,
|
|
192
|
+
"startDate.year": 42,
|
|
193
|
+
});
|
|
194
|
+
/** Lists saved reports. */
|
|
195
|
+
await gapi.client.adsense.accounts.reports.saved.list({
|
|
196
|
+
pageSize: 42,
|
|
197
|
+
pageToken: "Test string",
|
|
198
|
+
parent: "Test string",
|
|
199
|
+
});
|
|
200
|
+
/** Gets information about the selected site. */
|
|
201
|
+
await gapi.client.adsense.accounts.sites.get({
|
|
202
|
+
name: "Test string",
|
|
203
|
+
});
|
|
204
|
+
/** Lists all the sites available in an account. */
|
|
205
|
+
await gapi.client.adsense.accounts.sites.list({
|
|
206
|
+
pageSize: 42,
|
|
207
|
+
pageToken: "Test string",
|
|
208
|
+
parent: "Test string",
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
});
|
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
|
+
}
|