From b8c629ee8b3cafa60926a3d2afb234e38b5f29d0 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 30 Jan 2019 13:41:24 -0500 Subject: [PATCH 1/7] correct version syntax --- src/apis/adsense/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/apis/adsense/index.ts b/src/apis/adsense/index.ts index c32d1c61c1e..8a8ad87494b 100644 --- a/src/apis/adsense/index.ts +++ b/src/apis/adsense/index.ts @@ -20,10 +20,10 @@ export const VERSIONS = { 'v1.4': adsense_v1_4.Adsense, }; -export function adsense(version: 'v1_4'): adsense_v1_4.Adsense; +export function adsense(version: 'v1.4'): adsense_v1_4.Adsense; export function adsense(options: adsense_v1_4.Options): adsense_v1_4.Adsense; export function adsense( - this: GoogleConfigurable, versionOrOptions: 'v1_4'|adsense_v1_4.Options) { + this: GoogleConfigurable, versionOrOptions: 'v1.4'|adsense_v1_4.Options) { return getAPI('adsense', versionOrOptions, VERSIONS, this); } From e042cb83f06d4004a57b22c1a4f1356a3cbc644c Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 30 Jan 2019 14:16:20 -0500 Subject: [PATCH 2/7] add unit test --- test/test.adsense.ts | 47 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 test/test.adsense.ts diff --git a/test/test.adsense.ts b/test/test.adsense.ts new file mode 100644 index 00000000000..29108b40bcd --- /dev/null +++ b/test/test.adsense.ts @@ -0,0 +1,47 @@ +// Copyright 2019 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import * as assert from 'assert'; +import {adsense_v1_4, GoogleApis} from '../src'; +import {Utils} from './utils'; + +const googleapis = new GoogleApis(); + +describe('adsense:1.4', () => { + let localAdsense: adsense_v1_4.Adsense, remoteAdsense: adsense_v1_4.Adsense; + + before(async () => { + remoteAdsense = await Utils.loadApi(googleapis, 'adsense', 'v1.4'); + }); + + beforeEach(() => { + localAdsense = googleapis.adsense('v1.4'); + }) + + it('should exist', (done) => { + assert.notEqual(typeof googleapis.adsense, null); + done(); + }); + + it('should be a function', (done) => { + assert.strictEqual(typeof googleapis.adsense, 'function'); + done(); + }); + + it('should create an adsence object on default', (done) => { + assert.notEqual(typeof localAdsense, 'undefined'); + assert.notEqual(typeof remoteAdsense, 'undefined'); + done(); + }); +}) \ No newline at end of file From b7270d907d2f3313fb4fe82c2fda3c87f4e936c9 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 30 Jan 2019 16:12:03 -0500 Subject: [PATCH 3/7] fix genarator api-index template --- src/generator/templates/api-index.njk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/generator/templates/api-index.njk b/src/generator/templates/api-index.njk index 1ba6a506360..3432482d242 100644 --- a/src/generator/templates/api-index.njk +++ b/src/generator/templates/api-index.njk @@ -26,10 +26,10 @@ export const VERSIONS = { {% for versionName, version in api %} {% set Version = version|replace('.','_') %} - export function {{ name }}(version: '{{ Version }}'): {{ name }}_{{ Version }}.{{ name|capitalize }}; + export function {{ name }}(version: '{{ version }}'): {{ name }}_{{ Version }}.{{ name|capitalize }}; export function {{ name }}(options: {{ name }}_{{ Version }}.Options): {{ name }}_{{ Version }}.{{ name|capitalize }}; {% endfor %} -export function {{ name }}(this: GoogleConfigurable, versionOrOptions: {% for versionName, version in api %}'{{ version|replace('.','_') }}'|{{ name }}_{{ version|replace('.','_') }}.Options{% if not loop.last %}|{% endif %}{% endfor %}) { +export function {{ name }}(this: GoogleConfigurable, versionOrOptions: {% for versionName, version in api %}'{{ version }}'|{{ name }}_{{ version|replace('.','_') }}.Options{% if not loop.last %}|{% endif %}{% endfor %}) { return getAPI('{{ name }}', versionOrOptions, VERSIONS, this); } From 1d59ebf3661f5c31b462a8e3f84cd6ac220bc197 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 30 Jan 2019 16:13:04 -0500 Subject: [PATCH 4/7] fix lint in test --- test/test.adsense.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/test/test.adsense.ts b/test/test.adsense.ts index 29108b40bcd..3cd1b5bef38 100644 --- a/test/test.adsense.ts +++ b/test/test.adsense.ts @@ -20,28 +20,29 @@ const googleapis = new GoogleApis(); describe('adsense:1.4', () => { let localAdsense: adsense_v1_4.Adsense, remoteAdsense: adsense_v1_4.Adsense; - - before(async () => { - remoteAdsense = await Utils.loadApi(googleapis, 'adsense', 'v1.4'); + + before(async () => { + remoteAdsense = await Utils.loadApi( + googleapis, 'adsense', 'v1.4'); }); beforeEach(() => { localAdsense = googleapis.adsense('v1.4'); - }) + }); it('should exist', (done) => { assert.notEqual(typeof googleapis.adsense, null); done(); }); - + it('should be a function', (done) => { assert.strictEqual(typeof googleapis.adsense, 'function'); done(); }); - + it('should create an adsence object on default', (done) => { assert.notEqual(typeof localAdsense, 'undefined'); assert.notEqual(typeof remoteAdsense, 'undefined'); done(); - }); -}) \ No newline at end of file + }); +}); \ No newline at end of file From 65980ee21349cf2f96bb5bf5fdfe91026ef4882f Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 30 Jan 2019 22:05:19 -0500 Subject: [PATCH 5/7] other related updates --- src/apis/adexchangebuyer/index.ts | 12 ++++++------ src/apis/adsensehost/index.ts | 4 ++-- src/apis/analytics/index.ts | 4 ++-- src/apis/androidpublisher/index.ts | 4 ++-- src/apis/content/index.ts | 4 ++-- src/apis/dfareporting/index.ts | 6 +++--- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/apis/adexchangebuyer/index.ts b/src/apis/adexchangebuyer/index.ts index 48c862a6b4a..0ae811f0211 100644 --- a/src/apis/adexchangebuyer/index.ts +++ b/src/apis/adexchangebuyer/index.ts @@ -24,15 +24,15 @@ export const VERSIONS = { 'v1.4': adexchangebuyer_v1_4.Adexchangebuyer, }; -export function adexchangebuyer(version: 'v1_2'): +export function adexchangebuyer(version: 'v1.2'): adexchangebuyer_v1_2.Adexchangebuyer; export function adexchangebuyer(options: adexchangebuyer_v1_2.Options): adexchangebuyer_v1_2.Adexchangebuyer; -export function adexchangebuyer(version: 'v1_3'): +export function adexchangebuyer(version: 'v1.3'): adexchangebuyer_v1_3.Adexchangebuyer; export function adexchangebuyer(options: adexchangebuyer_v1_3.Options): adexchangebuyer_v1_3.Adexchangebuyer; -export function adexchangebuyer(version: 'v1_4'): +export function adexchangebuyer(version: 'v1.4'): adexchangebuyer_v1_4.Adexchangebuyer; export function adexchangebuyer(options: adexchangebuyer_v1_4.Options): adexchangebuyer_v1_4.Adexchangebuyer; @@ -41,9 +41,9 @@ export function adexchangebuyer< adexchangebuyer_v1_3.Adexchangebuyer | adexchangebuyer_v1_4.Adexchangebuyer>( this: GoogleConfigurable, - versionOrOptions: 'v1_2'| - adexchangebuyer_v1_2.Options|'v1_3'| - adexchangebuyer_v1_3.Options|'v1_4'|adexchangebuyer_v1_4.Options) { + versionOrOptions: 'v1.2'| + adexchangebuyer_v1_2.Options|'v1.3'| + adexchangebuyer_v1_3.Options|'v1.4'|adexchangebuyer_v1_4.Options) { return getAPI('adexchangebuyer', versionOrOptions, VERSIONS, this); } diff --git a/src/apis/adsensehost/index.ts b/src/apis/adsensehost/index.ts index b095cc4ef58..3416614ea1c 100644 --- a/src/apis/adsensehost/index.ts +++ b/src/apis/adsensehost/index.ts @@ -20,12 +20,12 @@ export const VERSIONS = { 'v4.1': adsensehost_v4_1.Adsensehost, }; -export function adsensehost(version: 'v4_1'): adsensehost_v4_1.Adsensehost; +export function adsensehost(version: 'v4.1'): adsensehost_v4_1.Adsensehost; export function adsensehost(options: adsensehost_v4_1.Options): adsensehost_v4_1.Adsensehost; export function adsensehost( this: GoogleConfigurable, - versionOrOptions: 'v4_1'|adsensehost_v4_1.Options) { + versionOrOptions: 'v4.1'|adsensehost_v4_1.Options) { return getAPI('adsensehost', versionOrOptions, VERSIONS, this); } diff --git a/src/apis/analytics/index.ts b/src/apis/analytics/index.ts index 67bdbb5eaca..e2c44f58cf3 100644 --- a/src/apis/analytics/index.ts +++ b/src/apis/analytics/index.ts @@ -22,7 +22,7 @@ export const VERSIONS = { 'v3': analytics_v3.Analytics, }; -export function analytics(version: 'v2_4'): analytics_v2_4.Analytics; +export function analytics(version: 'v2.4'): analytics_v2_4.Analytics; export function analytics(options: analytics_v2_4.Options): analytics_v2_4.Analytics; export function analytics(version: 'v3'): analytics_v3.Analytics; @@ -31,7 +31,7 @@ export function analytics(options: analytics_v3.Options): export function analytics( this: GoogleConfigurable, - versionOrOptions: 'v2_4'|analytics_v2_4.Options|'v3'|analytics_v3.Options) { + versionOrOptions: 'v2.4'|analytics_v2_4.Options|'v3'|analytics_v3.Options) { return getAPI('analytics', versionOrOptions, VERSIONS, this); } diff --git a/src/apis/androidpublisher/index.ts b/src/apis/androidpublisher/index.ts index 71ad4e97fce..7339d027ad2 100644 --- a/src/apis/androidpublisher/index.ts +++ b/src/apis/androidpublisher/index.ts @@ -27,7 +27,7 @@ export const VERSIONS = { 'v3': androidpublisher_v3.Androidpublisher, }; -export function androidpublisher(version: 'v1_1'): +export function androidpublisher(version: 'v1.1'): androidpublisher_v1_1.Androidpublisher; export function androidpublisher(options: androidpublisher_v1_1.Options): androidpublisher_v1_1.Androidpublisher; @@ -49,7 +49,7 @@ export function androidpublisher< androidpublisher_v2.Androidpublisher | androidpublisher_v3.Androidpublisher>( this: GoogleConfigurable, - versionOrOptions: 'v1_1'| + versionOrOptions: 'v1.1'| androidpublisher_v1_1.Options|'v1'| androidpublisher_v1.Options|'v2'| androidpublisher_v2.Options|'v3'|androidpublisher_v3.Options) { diff --git a/src/apis/content/index.ts b/src/apis/content/index.ts index f511ac2c7f4..e94364c784f 100644 --- a/src/apis/content/index.ts +++ b/src/apis/content/index.ts @@ -23,13 +23,13 @@ export const VERSIONS = { 'v2': content_v2.Content, }; -export function content(version: 'v2_1'): content_v2_1.Content; +export function content(version: 'v2.1'): content_v2_1.Content; export function content(options: content_v2_1.Options): content_v2_1.Content; export function content(version: 'v2'): content_v2.Content; export function content(options: content_v2.Options): content_v2.Content; export function content( this: GoogleConfigurable, - versionOrOptions: 'v2_1'|content_v2_1.Options|'v2'|content_v2.Options) { + versionOrOptions: 'v2.1'|content_v2_1.Options|'v2'|content_v2.Options) { return getAPI('content', versionOrOptions, VERSIONS, this); } diff --git a/src/apis/dfareporting/index.ts b/src/apis/dfareporting/index.ts index 179f2266382..87eba0fba0b 100644 --- a/src/apis/dfareporting/index.ts +++ b/src/apis/dfareporting/index.ts @@ -22,16 +22,16 @@ export const VERSIONS = { 'v3.2': dfareporting_v3_2.Dfareporting, }; -export function dfareporting(version: 'v3_1'): dfareporting_v3_1.Dfareporting; +export function dfareporting(version: 'v3.1'): dfareporting_v3_1.Dfareporting; export function dfareporting(options: dfareporting_v3_1.Options): dfareporting_v3_1.Dfareporting; -export function dfareporting(version: 'v3_2'): dfareporting_v3_2.Dfareporting; +export function dfareporting(version: 'v3.2'): dfareporting_v3_2.Dfareporting; export function dfareporting(options: dfareporting_v3_2.Options): dfareporting_v3_2.Dfareporting; export function dfareporting< T = dfareporting_v3_1.Dfareporting | dfareporting_v3_2.Dfareporting>( this: GoogleConfigurable, - versionOrOptions: 'v3_1'|dfareporting_v3_1.Options|'v3_2'| + versionOrOptions: 'v3.1'|dfareporting_v3_1.Options|'v3.2'| dfareporting_v3_2.Options) { return getAPI('dfareporting', versionOrOptions, VERSIONS, this); } From a06269ad2c17f81c108f6f36f5e9b37fb4c7e293 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 30 Jan 2019 23:10:03 -0500 Subject: [PATCH 6/7] test for versions with a dot in the name --- test/test.adsense.ts | 48 -------------------------------------------- test/test.clients.ts | 10 +++++++++ 2 files changed, 10 insertions(+), 48 deletions(-) delete mode 100644 test/test.adsense.ts diff --git a/test/test.adsense.ts b/test/test.adsense.ts deleted file mode 100644 index 3cd1b5bef38..00000000000 --- a/test/test.adsense.ts +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2019 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import * as assert from 'assert'; -import {adsense_v1_4, GoogleApis} from '../src'; -import {Utils} from './utils'; - -const googleapis = new GoogleApis(); - -describe('adsense:1.4', () => { - let localAdsense: adsense_v1_4.Adsense, remoteAdsense: adsense_v1_4.Adsense; - - before(async () => { - remoteAdsense = await Utils.loadApi( - googleapis, 'adsense', 'v1.4'); - }); - - beforeEach(() => { - localAdsense = googleapis.adsense('v1.4'); - }); - - it('should exist', (done) => { - assert.notEqual(typeof googleapis.adsense, null); - done(); - }); - - it('should be a function', (done) => { - assert.strictEqual(typeof googleapis.adsense, 'function'); - done(); - }); - - it('should create an adsence object on default', (done) => { - assert.notEqual(typeof localAdsense, 'undefined'); - assert.notEqual(typeof remoteAdsense, 'undefined'); - done(); - }); -}); \ No newline at end of file diff --git a/test/test.clients.ts b/test/test.clients.ts index 6ee94f54292..1080ba0a661 100644 --- a/test/test.clients.ts +++ b/test/test.clients.ts @@ -46,6 +46,16 @@ describe('Clients', () => { localOauth2 = google.oauth2('v2'); }); + it('should load API versions with a dot in the name', async () => { + const google = new GoogleApis(); + nock.enableNetConnect(); + const remoteAdsense = await Utils.loadApi(google, 'adsense', 'v1.4'); + nock.disableNetConnect(); + const localAdsense = google.adsense('v1.4'); + assert.notEqual(typeof localAdsense, 'undefined'); + assert.notEqual(typeof remoteAdsense, 'undefined'); + }); + it('should create request helpers according to resource on discovery API response', () => { let plus = localPlus; From 1c34f9bb0ca22812b177e465d14ac3cad6a0d78e Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Wed, 30 Jan 2019 21:02:48 -0800 Subject: [PATCH 7/7] Update test.clients.ts --- test/test.clients.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/test/test.clients.ts b/test/test.clients.ts index 1080ba0a661..8425ec7ff33 100644 --- a/test/test.clients.ts +++ b/test/test.clients.ts @@ -48,12 +48,8 @@ describe('Clients', () => { it('should load API versions with a dot in the name', async () => { const google = new GoogleApis(); - nock.enableNetConnect(); - const remoteAdsense = await Utils.loadApi(google, 'adsense', 'v1.4'); - nock.disableNetConnect(); - const localAdsense = google.adsense('v1.4'); - assert.notEqual(typeof localAdsense, 'undefined'); - assert.notEqual(typeof remoteAdsense, 'undefined'); + const ads = google.adsense('v1.4'); + assert.ok(ads); }); it('should create request helpers according to resource on discovery API response',