Skip to content

Commit

Permalink
Merge pull request #53 from Relewise/fix/integrator-multilingual-coll…
Browse files Browse the repository at this point in the history
…ection

Fix: type generated in request for multilingual collection
  • Loading branch information
mzanoni authored Jan 17, 2024
2 parents 2ca2be2 + 8e02cc8 commit f6157a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/client/src/models/dataValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export interface CollectionWithType<T> {
$values: T[];
}

export interface MultilingualCollectionWithType<T> {
$type: string;
values: T[];
}

export interface MultiCurrencyWithType extends MultiCurrency {
$type: string;
}
Expand Down Expand Up @@ -51,12 +56,12 @@ export class StringCollectionDataValue extends DataValueBase<CollectionWithType<
readonly isCollection = true;
}

export class MultilingualCollectionDataValue extends DataValueBase<CollectionWithType<MultilingualCollectionValue>> {
export class MultilingualCollectionDataValue extends DataValueBase<MultilingualCollectionWithType<MultilingualCollectionValue>> {
constructor(values: { values: string[], language: string }[]) {
super('MultilingualCollection',
{
$type: 'System.Collections.Generic.List`1[[Relewise.Client.DataTypes.Multilingual, Relewise.Client]], System.Private.CoreLib',
$values: values.map(x => ({ values: x.values, language: { value: x.language } })),
$type: 'Relewise.Client.DataTypes.MultilingualCollection, Relewise.Client',
values: values.map(x => ({ values: x.values, language: { value: x.language } })),
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ test('Create Product', async() => {
'Tags': DataValueFactory.stringCollection(['fall collection', 'blue', 'good-deal']),
'InStock': DataValueFactory.boolean(true),
'Removed': null,
'Materials': DataValueFactory.multilingualCollection([{ values: ['Wood', 'Metal'], language: 'da' }]),
'Complex': DataValueFactory.object({
'nestedDataKey': DataValueFactory.string('Key'),
}),
Expand Down

0 comments on commit f6157a1

Please sign in to comment.