Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions packages/optimize/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ This API fetches the propositions for the provided DecisionScope list.

**Syntax**
```typescript
updatePropositions(decisionScopes: Array<DecisionScope>, xdm: ?Map<string, any>, data: ?Map<string, any>)
updatePropositions(decisionScopes: Array<DecisionScope>, xdm?: Map<string, any>, data?: Map<string, any>)
```

**Example**
Expand Down Expand Up @@ -207,7 +207,7 @@ This class represents the decision scope which is used to fetch the decision pro
module.exports = class DecisionScope {
name: string;

constructor(name: ?string, activityId: ?string, placementId: ?string, itemCount: ?number) {
constructor(name?: string, activityId?: string, placementId?: string, itemCount?: number) {
if(name && name.trim()) {
this.name = name;
} else {
Expand Down Expand Up @@ -239,7 +239,7 @@ module.exports = class Proposition {
scope: string;
scopeDetails: Map<string, any>;

constructor(eventData: any) {
constructor(eventData: PropositionEventData) {
this.id = eventData['id'];
this.scope = eventData['scope'];
this.scopeDetails = eventData['scopeDetails'];
Expand Down Expand Up @@ -269,29 +269,31 @@ module.exports = class Offer {
id: string;
etag: string;
schema: string;
data: {string: any};
data: Record<string, any>;
meta?: Record<string, any>;

get content(): ?string {
get content(): string {
return this.data["content"];
}

get format(): ?string {
get format(): string {
return this.data["format"];
}

get language(): ?Array<string> {
get language(): Array<string> {
return this.data["language"];
}

get characteristics(): ?Map<string, any> {
get characteristics(): Map<string, any> {
return this.data["characteristics"];
}

constructor(eventData: any) {
constructor(eventData: OfferEventData) {
this.id = eventData['id'];
this.etag = eventData['etag'];
this.schema = eventData['schema'];
this.data = eventData['data'];
this.meta = eventData['meta']
}

/**
Expand Down
3 changes: 3 additions & 0 deletions packages/optimize/__tests__/OptimizeTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ describe('Optimize', () => {
expect(offer.format).toBe('text/plain');
expect(offer.language).toBe(offerJson.data.language);
expect(offer.characteristics).toBe(offerJson.data.characteristics);
expect(offer.meta).toMatchObject({
"custom": "custom-meta"
})
});

it('Test Offer.displayed', async () => {
Expand Down
3 changes: 3 additions & 0 deletions packages/optimize/__tests__/offer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
"characteristics": {
"mobile": "true"
}
},
"meta": {
"custom": "custom-meta"
}
}
7 changes: 5 additions & 2 deletions packages/optimize/ts/models/Offer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ interface OfferEventData {
id: string;
etag: string;
schema: string;
data: Record<string, any>;
data: Record<string, any>;
meta?: Record<string, any>;
}

class Offer {
id: string;
etag: string;
schema: string;
data: Record<string, any>;
data: Record<string, any>;
meta?: Record<string, any>;

get content(): string {
return this.data["content"];
Expand All @@ -47,6 +49,7 @@ class Offer {
this.etag = eventData['etag'];
this.schema = eventData['schema'];
this.data = eventData['data'];
this.meta = eventData['meta'];
}

/**
Expand Down