Skip to content

Commit

Permalink
feat: add option to pass token to getService and save one line of code
Browse files Browse the repository at this point in the history
  • Loading branch information
thewizarodofoz committed Sep 22, 2019
1 parent 7484129 commit 1edea3c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/dfp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class DFP {
this.options = options;
}

public async getService(service: string): Promise<DFPClient> {
public async getService(service: string, token?: string): Promise<DFPClient> {
const {apiVersion} = this.options;
const serviceUrl = `https://ads.google.com/apis/ads/publisher/${apiVersion}/${service}?wsdl`;
const client = await promiseFromCallback((cb) => createClient(serviceUrl, cb));
Expand All @@ -29,6 +29,10 @@ export class DFP {
client.setSecurity(new BearerSecurity(token));
};

if (token) {
client.setToken(token);
}

return new Proxy(client, {
get: function get(target, propertyKey) {
const method = propertyKey.toString();
Expand Down

0 comments on commit 1edea3c

Please sign in to comment.