Skip to content

Commit

Permalink
fix: Cant set consentLanguage with custom GVL InteractiveAdvertisingB…
Browse files Browse the repository at this point in the history
…ureau#211, GVL object is being constructed with the gvl json, and setting consentLanguage forces another fetch InteractiveAdvertisingBureau#405
  • Loading branch information
ccartesonetrust committed May 22, 2024
1 parent c847c08 commit 07c7cdc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
19 changes: 10 additions & 9 deletions modules/core/src/GVL.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Cloneable} from './Cloneable.js';
import {GVLError} from './errors/index.js';
import {Json} from './Json.js';
import {ConsentLanguages, IntMap} from './model/index.js';
import {ByPurposeVendorMap, Declarations, Feature, IDSetMap, Purpose, Stack, Vendor, VendorList, DataCategory} from './model/gvl/index.js';
import { Cloneable } from './Cloneable.js';
import { GVLError } from './errors/index.js';
import { Json } from './Json.js';
import { ConsentLanguages, IntMap } from './model/index.js';
import { ByPurposeVendorMap, Declarations, Feature, IDSetMap, Purpose, Stack, Vendor, VendorList, DataCategory, GvlCreationOption } from './model/gvl/index.js';

export type VersionOrVendorList = string | number | VendorList;
type PurposeOrFeature = 'purpose' | 'feature';
Expand Down Expand Up @@ -236,8 +236,9 @@ export class GVL extends Cloneable<GVL> implements VendorList {
* [[VendorList]] object or a version number represented as a string or
* number to download. If nothing is passed the latest version of the GVL
* will be loaded
* @param options - it is an optional object where the default language can be set
*/
public constructor(versionOrVendorList?: VersionOrVendorList) {
public constructor(versionOrVendorList?: VersionOrVendorList, options?: GvlCreationOption) {

super();

Expand All @@ -247,8 +248,8 @@ export class GVL extends Cloneable<GVL> implements VendorList {
*/
let url = GVL.baseUrl;

this.lang_ = GVL.DEFAULT_LANGUAGE;
this.cacheLang_ = GVL.DEFAULT_LANGUAGE;
this.lang_ = options?.language || GVL.DEFAULT_LANGUAGE;
this.cacheLang_ = options?.language || GVL.DEFAULT_LANGUAGE;

if (this.isVendorList(versionOrVendorList as GVL)) {

Expand Down Expand Up @@ -689,7 +690,7 @@ export class GVL extends Cloneable<GVL> implements VendorList {

} else {

vendorSet = this['by' + (special ? 'Special' : '' ) + properPurposeOrFeature + 'VendorMap'][String(id)];
vendorSet = this['by' + (special ? 'Special' : '') + properPurposeOrFeature + 'VendorMap'][String(id)];

}

Expand Down
3 changes: 3 additions & 0 deletions modules/core/src/model/gvl/GvlCreationOptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface GvlCreationOptions {
language: string;
}
1 change: 1 addition & 0 deletions modules/core/src/model/gvl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export * from './Stack.js';
export * from './Vendor.js';
export * from './VendorList.js';
export * from './DataCategory.js';
export * from './GvlCreationOptions.js';

0 comments on commit 07c7cdc

Please sign in to comment.