@maxim_mazurok/gapi.client.tagmanager-v2 0.0.20220810

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/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@maxim_mazurok/gapi.client.tagmanager-v2",
3
+ "version": "0.0.20220810",
4
+ "description": "TypeScript typings for Tag Manager 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,101 @@
1
+ # TypeScript typings for Tag Manager API v2
2
+
3
+ This API allows clients to access and modify container and tag configuration.
4
+ For detailed description please check [documentation](https://developers.google.com/tag-manager).
5
+
6
+ ## Installing
7
+
8
+ Install typings for Tag Manager API:
9
+
10
+ ```
11
+ npm install @types/gapi.client.tagmanager-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://tagmanager.googleapis.com/$discovery/rest?version=v2', () => {
29
+ // now we can use:
30
+ // gapi.client.tagmanager
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('tagmanager', 'v2', () => {
37
+ // now we can use:
38
+ // gapi.client.tagmanager
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
+ // Delete your Google Tag Manager containers
49
+ 'https://www.googleapis.com/auth/tagmanager.delete.containers',
50
+
51
+ // Manage your Google Tag Manager container and its subcomponents, excluding versioning and publishing
52
+ 'https://www.googleapis.com/auth/tagmanager.edit.containers',
53
+
54
+ // Manage your Google Tag Manager container versions
55
+ 'https://www.googleapis.com/auth/tagmanager.edit.containerversions',
56
+
57
+ // View and manage your Google Tag Manager accounts
58
+ 'https://www.googleapis.com/auth/tagmanager.manage.accounts',
59
+
60
+ // Manage user permissions of your Google Tag Manager account and container
61
+ 'https://www.googleapis.com/auth/tagmanager.manage.users',
62
+
63
+ // Publish your Google Tag Manager container versions
64
+ 'https://www.googleapis.com/auth/tagmanager.publish',
65
+
66
+ // View your Google Tag Manager container and its subcomponents
67
+ 'https://www.googleapis.com/auth/tagmanager.readonly',
68
+ ],
69
+ immediate = true;
70
+ // ...
71
+
72
+ gapi.auth.authorize(
73
+ { client_id: client_id, scope: scope, immediate: immediate },
74
+ authResult => {
75
+ if (authResult && !authResult.error) {
76
+ /* handle successful authorization */
77
+ } else {
78
+ /* handle authorization error */
79
+ }
80
+ });
81
+ ```
82
+
83
+ After that you can use Tag Manager API resources: <!-- TODO: make this work for multiple namespaces -->
84
+
85
+ ```typescript
86
+
87
+ /*
88
+ Gets a GTM Account.
89
+ */
90
+ await gapi.client.tagmanager.accounts.get({ path: "path", });
91
+
92
+ /*
93
+ Lists all GTM Accounts that a user has access to.
94
+ */
95
+ await gapi.client.tagmanager.accounts.list({ });
96
+
97
+ /*
98
+ Updates a GTM Account.
99
+ */
100
+ await gapi.client.tagmanager.accounts.update({ path: "path", });
101
+ ```