Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: respect . in api versions (fix adsense API) #1573

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/apis/adexchangebuyer/index.ts
Expand Up @@ -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;
Expand All @@ -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<T>('adexchangebuyer', versionOrOptions, VERSIONS, this);
}

Expand Down
4 changes: 2 additions & 2 deletions src/apis/adsense/index.ts
Expand Up @@ -20,10 +20,10 @@ export const VERSIONS = {
'v1.4': adsense_v1_4.Adsense,
};

export function adsense(version: 'v1_4'): adsense_v1_4.Adsense;
JustinBeckwith marked this conversation as resolved.
Show resolved Hide resolved
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<T = adsense_v1_4.Adsense>(
this: GoogleConfigurable, versionOrOptions: 'v1_4'|adsense_v1_4.Options) {
this: GoogleConfigurable, versionOrOptions: 'v1.4'|adsense_v1_4.Options) {
return getAPI<T>('adsense', versionOrOptions, VERSIONS, this);
}

Expand Down
4 changes: 2 additions & 2 deletions src/apis/adsensehost/index.ts
Expand Up @@ -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<T = adsensehost_v4_1.Adsensehost>(
this: GoogleConfigurable,
versionOrOptions: 'v4_1'|adsensehost_v4_1.Options) {
versionOrOptions: 'v4.1'|adsensehost_v4_1.Options) {
return getAPI<T>('adsensehost', versionOrOptions, VERSIONS, this);
}

Expand Down
4 changes: 2 additions & 2 deletions src/apis/analytics/index.ts
Expand Up @@ -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;
Expand All @@ -31,7 +31,7 @@ export function analytics(options: analytics_v3.Options):
export function
analytics<T = analytics_v2_4.Analytics | analytics_v3.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<T>('analytics', versionOrOptions, VERSIONS, this);
}

Expand Down
4 changes: 2 additions & 2 deletions src/apis/androidpublisher/index.ts
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/apis/content/index.ts
Expand Up @@ -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<T = content_v2_1.Content | content_v2.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<T>('content', versionOrOptions, VERSIONS, this);
}

Expand Down
6 changes: 3 additions & 3 deletions src/apis/dfareporting/index.ts
Expand Up @@ -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<T>('dfareporting', versionOrOptions, VERSIONS, this);
}
Expand Down
4 changes: 2 additions & 2 deletions src/generator/templates/api-index.njk
Expand Up @@ -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 }}<T = {% for versionName, version in api %}{{ name }}_{{ version|replace('.','_') }}.{{name|capitalize}}{% if not loop.last %}|{% endif %}{% endfor %}>(this: GoogleConfigurable, versionOrOptions: {% for versionName, version in api %}'{{ version|replace('.','_') }}'|{{ name }}_{{ version|replace('.','_') }}.Options{% if not loop.last %}|{% endif %}{% endfor %}) {
export function {{ name }}<T = {% for versionName, version in api %}{{ name }}_{{ version|replace('.','_') }}.{{name|capitalize}}{% if not loop.last %}|{% endif %}{% endfor %}>(this: GoogleConfigurable, versionOrOptions: {% for versionName, version in api %}'{{ version }}'|{{ name }}_{{ version|replace('.','_') }}.Options{% if not loop.last %}|{% endif %}{% endfor %}) {
return getAPI<T>('{{ name }}', versionOrOptions, VERSIONS, this);
}

Expand Down
6 changes: 6 additions & 0 deletions test/test.clients.ts
Expand Up @@ -46,6 +46,12 @@ describe('Clients', () => {
localOauth2 = google.oauth2('v2');
});

it('should load API versions with a dot in the name', async () => {
const google = new GoogleApis();
const ads = google.adsense('v1.4');
assert.ok(ads);
});

it('should create request helpers according to resource on discovery API response',
() => {
let plus = localPlus;
Expand Down