Skip to content

Commit 681557a

Browse files
committed
[ADD] readme
1 parent 33d973b commit 681557a

File tree

8 files changed

+889
-30
lines changed

8 files changed

+889
-30
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module.exports = {
2424
'@typescript-eslint/ban-types': ['error', {
2525
'types': {
2626
'Function': false,
27+
"{}": false
2728
}
2829
}],
2930
},

README.md

+96-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,96 @@
1-
# googleads-node-lib
1+
<p align="center">
2+
<a href="https://developers.google.com/ad-manager/api/start" target="blank"><img src="https://developers.google.com/ads/images/logo_admanager_192px.svg" width="120" alt="Ad Manager Logo" /></a>
3+
</p>
4+
5+
[circleci-image]: https://img.shields.io/circleci/build/github/Niurmiguel/google-admanager-api/master?token=abc123def456
6+
[circleci-url]: https://circleci.com/gh/Niurmiguel/google-admanager-api
7+
8+
<p align="center"><a href="https://developers.google.com/ad-manager/api/start" target="_blank">Google Ad Manager API</a> Client Library for NodeJs.</p>
9+
<p align="center">
10+
<a href="https://www.npmjs.com/~niur" target="_blank"><img src="https://img.shields.io/npm/v/@niur/google-admanager-node-lib.svg" alt="NPM Version" /></a>
11+
<a href="https://www.npmjs.com/~niur" target="_blank"><img src="https://img.shields.io/npm/l/@niur/google-admanager-node-lib.svg" alt="Package License" /></a>
12+
<a href="https://www.npmjs.com/~niur" target="_blank"><img src="https://img.shields.io/npm/dm/@niur/google-admanager-node-lib.svg" alt="NPM Downloads" /></a>
13+
</p>
14+
15+
## Description
16+
17+
Developers can use the Google Ad Manager API to build applications that manage inventory, create orders, pull reports, and more.
18+
19+
### Installing the library
20+
21+
```bash
22+
$ npm install @niur/google-admanager-node-lib
23+
```
24+
### Overview
25+
26+
#### Authentication
27+
28+
All Google Ad Manager API calls must be authorized through OAuth2 an open standard that allows users to grant permissions to third-party applications, so the application can interact with web services on the user's behalf. OAuth2 enables your Ad Manager API client application to access a user's Ad Manager account without having to handle or store the user's username or password.
29+
30+
##### Generate OAuth2 credentials
31+
32+
```typescript
33+
34+
const credential = new GoogleSACredential({
35+
"type": "service_account",
36+
"project_id": "...",
37+
"private_key_id": "...",
38+
"private_key": "...",
39+
"client_email": "...",
40+
"client_id": "...",
41+
"auth_uri": "...",
42+
"token_uri": "...",
43+
...
44+
}, ['ad_manager']);
45+
46+
//or
47+
48+
const credential = new GoogleSAFileCredential('./credentials.json', ['ad_manager']);
49+
50+
```
51+
52+
##### Use a client library
53+
54+
```typescript
55+
56+
const adManagerClient = new AdManagerClient('network code',credential,'application name');
57+
58+
const orderService = await adManagerClient.getService("OrderService");
59+
const statement = new StatementBuilder().limit(10);
60+
const orderPage = await orderService.getOrdersByStatement(statement.toStatement())
61+
62+
/**
63+
* {
64+
* results: [],
65+
* totalResultSetSize: 0,
66+
* startIndex: 0
67+
* }
68+
* /
69+
```
70+
71+
##### Options
72+
73+
<table>
74+
<tr>
75+
<td><code><b>networkCode</b></code></td>
76+
<td><code>Number</code></td>
77+
<td>The network code of the network being addressed (<b>required</b>).</td>
78+
</tr>
79+
<tr>
80+
<td><code><b>credential</b></code></td>
81+
<td><code>SACredential</code></td>
82+
<td>OAuth2 credential (<b>required</b>).</td>
83+
</tr>
84+
<tr>
85+
<td><code><b>applicationName</b></code></td>
86+
<td><code>String</code></td>
87+
<td>An arbitrary string name identifying your application. This will be shown in Google's log files. For example: "My Inventory Application" or "App_1" (<b>optional</b>).</td>
88+
</tr>
89+
</table>
90+
91+
## Stay in touch
92+
93+
* Author - [Niurmiguel](https://github.com/Niurmiguel)
94+
95+
## License
96+
Nestjs Azure Service Bus is [MIT licensed](LICENSE).

jestconfig.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"transform": {
3+
"^.+\\.(t|j)sx?$": "ts-jest"
4+
},
5+
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
6+
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"]
7+
}

lib/admanager/googleSoap.service.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@ export class GoogleSoapService<T extends keyof typeof SERVICE_MAP> {
1919
}
2020

2121
public async createClient(): Promise<ImportClass<typeof SERVICE_MAP, T>> {
22-
const self = this;
2322
const serviceUrl = `https://ads.google.com/apis/ads/publisher/${API_VERSION}/${this.service}?wsdl`;
2423
const client = await createClientAsync(serviceUrl);
25-
client.addSoapHeader(self.getSoapHeaders());
24+
client.addSoapHeader(this.getSoapHeaders());
2625
client.setToken = function setToken(token: string) {
2726
client.setSecurity(new BearerSecurity(token));
2827
};
2928

30-
if (this.token) client.setToken(self.token);
29+
if (this.token) client.setToken(this.token);
3130

3231
this._client = new Proxy(client, {
3332
get: function get(target, propertyKey) {

lib/common/utils/statementBuilder.util.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import {
77
} from '../../common/types';
88

99
export class StatementBuilder {
10-
static SUGGESTED_PAGE_LIMIT: number = 500;
11-
private SELECT: string = 'SELECT';
12-
private FROM: string = 'FROM';
13-
private WHERE: string = 'WHERE';
14-
private LIMIT: string = 'LIMIT';
15-
private OFFSET: string = 'OFFSET';
16-
private ORDER_BY: string = 'ORDER BY';
10+
static SUGGESTED_PAGE_LIMIT = 500;
11+
private SELECT = 'SELECT';
12+
private FROM = 'FROM';
13+
private WHERE = 'WHERE';
14+
private LIMIT = 'LIMIT';
15+
private OFFSET = 'OFFSET';
16+
private ORDER_BY = 'ORDER BY';
1717

1818
private _select: string;
1919
private _from: string;

0 commit comments

Comments
 (0)