google-ad-manager-api
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -12,5 +12,5 @@ import { Client } from 'soap'; | ||
constructor(options: DFPOptions); | ||
getService(service: string): Promise<DFPClient>; | ||
static parse(res: any[]): any; | ||
getService(service: string, token?: string): Promise<DFPClient>; | ||
static parse(res: any): any; | ||
private getSoapHeaders; | ||
} |
@@ -12,2 +12,3 @@ "use strict"; | ||
const soap_1 = require("soap"); | ||
const utils_1 = require("./utils"); | ||
class DFP { | ||
@@ -17,7 +18,7 @@ constructor(options) { | ||
} | ||
getService(service) { | ||
getService(service, token) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { apiVersion } = this.options; | ||
const serviceUrl = `https://ads.google.com/apis/ads/publisher/${apiVersion}/${service}?wsdl`; | ||
const client = yield soap_1.createClientAsync(serviceUrl); | ||
const client = yield utils_1.promiseFromCallback((cb) => soap_1.createClient(serviceUrl, cb)); | ||
client.addSoapHeader(this.getSoapHeaders()); | ||
@@ -27,2 +28,5 @@ client.setToken = function setToken(token) { | ||
}; | ||
if (token) { | ||
client.setToken(token); | ||
} | ||
return new Proxy(client, { | ||
@@ -34,4 +38,3 @@ get: function get(target, propertyKey) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
// @ts-ignore | ||
const res = yield client[method + 'Async'](dto); | ||
const res = yield utils_1.promiseFromCallback((cb) => client[method](dto, cb)); | ||
return DFP.parse(res); | ||
@@ -49,3 +52,3 @@ }); | ||
static parse(res) { | ||
return res[0].rval; | ||
return res.rval; | ||
} | ||
@@ -52,0 +55,0 @@ getSoapHeaders() { |
{ | ||
"name": "google-ad-manager-api", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -0,1 +1,3 @@ | ||
![Langauge](https://badge.langauge.io/thewizarodofoz/google-ad-manager-api) | ||
# Google Ad Manager Node.js API | ||
@@ -42,2 +44,3 @@ A modern wrapper around Google's [Ad Manager API](https://developers.google.com/ad-manager/docs/start). | ||
```ts | ||
import {DFP} from 'google-ad-manager-api'; | ||
const dfp = new DFP({networkCode: '...', apiVersion: 'v201805'}); | ||
@@ -52,2 +55,6 @@ ``` | ||
``` | ||
Or even shorter (pass the token directly to `getService`: | ||
```ts | ||
const lineItemService = await dfp.getService('LineItemService', client.credentials.access_token); | ||
``` | ||
@@ -54,0 +61,0 @@ ### Step #4 |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10106
11
103
76