-
Notifications
You must be signed in to change notification settings - Fork 39
Evan/mob 11436 add serialization of placements android #732
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
Draft
lposen
wants to merge
48
commits into
master
Choose a base branch
from
evan/MOB-11436-add-serialization-of-placements-android
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+636
−1
Draft
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
376abd1
feat: updates bridge
616503e
feat: adds base embedded files
75c7f1e
feat: adds enableEmbeddedMessaging flag to config object
ca6911f
feat: adds serialization of enableEmbeddedMessaging flag
c8409f7
chore: reverts version number
5164c44
Merge pull request #646 from Iterable/evan/MOB-8751
evantk91 8c8a174
Merge branch 'evan/feature/embedded' into evan/MOB-11561-enableEmbedd…
evantk91 a591d39
feat: test calling native method
5366d3a
feat: adds serialization functions
a546287
Merge branch 'evan/MOB-11561-enableEmbeddedMessaging-flag' into evan/…
evantk91 aac04d5
chore: resets version number
7316098
feat: adds IterableEmbeddedMetadata class
e121bc6
feat: adds unit tests
1c56ff1
feat: adds button class and associated classes
4578c01
feat: adds unit tests
57f48a3
feat: adds elements class and associated classes
a3397a4
feat: adds unit tests
79e7225
feat: adds message class and unit tests
a6efa27
Merge branch 'evan/MOB-7936-iterable-embedded-message-class' into eva…
904676b
Merge pull request #647 from Iterable/evan/MOB-11561-enableEmbeddedMe…
evantk91 6f08aed
feat: adds enableEmbeddedMessaging to iOS config
1ad97cd
Merge branch 'evan/feature/embedded' into evan/MOB-11549-iterable-emb…
evantk91 ef639f5
Merge pull request #654 from Iterable/evan/MOB-11549-iterable-embedde…
evantk91 50053fd
Merge branch 'evan/feature/embedded' into evan/MOB-11561-enableEmbedd…
evantk91 034f677
Merge pull request #659 from Iterable/evan/MOB-11561-enableEmbeddedMe…
evantk91 38eddb9
feat: passes converted messages into promise
6f1c83d
feat: adds placement id as a parameter to get embedded messages
c35774b
feat: adds null check
27af816
Merge branch 'evan/embedded-message-class' into evan/MOB-11550-iterab…
evantk91 12ac9b6
Merge pull request #655 from Iterable/evan/MOB-11550-iterable-embedde…
evantk91 80d7981
feat: adds labels for dict
aa2be62
Merge branch 'evan/embedded-message-class' into evan/MOB-11550-iterab…
evantk91 d6b0a0a
Merge pull request #667 from Iterable/evan/MOB-11550-iterable-embedde…
evantk91 a292556
Merge branch 'evan/embedded-message-class' into evan/MOB-11551-iterab…
evantk91 58fe64e
chore: adds comments to props
2b2899c
Merge pull request #656 from Iterable/evan/MOB-11551-iterable-embedde…
evantk91 3a486d6
Merge branch 'evan/embedded-message-class' into evan/MOB-7936-iterabl…
evantk91 84e6a68
chore: adds comments to props
8df97eb
Merge pull request #657 from Iterable/evan/MOB-7936-iterable-embedded…
evantk91 cad9c3e
feat: merges action into button
5f51526
feat: updates IterableEmbeddedMessageText class
7c2c8aa
feat: converts IterableEmbeddedMessageElements constructor
3c0e01d
feat: removes default action class
56b33b0
feat: converts IterableEmbeddedMessage constructor
1db3333
feat: converts IterableEmbeddedMessage constructor
2b627f3
feat: removes embedded metadata class
6701a64
feat: combines message and elements in one class
3ea79fe
Merge branch 'evan/MOB-11649' into evan/MOB-11436-add-serialization-o…
evantk91 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
import { IterableEmbeddedMessage } from '../embedded/classes/IterableEmbeddedMessage'; | ||
import { Iterable } from '../core/classes/Iterable'; | ||
|
||
describe('IterableEmbeddedMessage', () => { | ||
it('should create an instance with all properties', () => { | ||
Iterable.logger.log('iterableEmbeddedMessage_fromDict_all_properties'); | ||
|
||
const dict = { | ||
metadata: { | ||
messageId: 'msg-123', | ||
placementId: 1, | ||
campaignId: 456, | ||
isProof: false, | ||
}, | ||
elements: { | ||
title: 'Awesome Title', | ||
body: 'Radical Body Text', | ||
mediaUrl: 'https://example.com/image.jpg', | ||
mediaUrlCaption: 'Check out this sick image!', | ||
defaultAction: { | ||
type: 'openUrl', | ||
data: 'https://example.com', | ||
}, | ||
buttons: [ | ||
{ | ||
id: 'button-1', | ||
title: 'Click Me!', | ||
action: { | ||
type: 'openUrl', | ||
data: 'https://example.com/button1', | ||
}, | ||
}, | ||
], | ||
text: [ | ||
{ | ||
id: 'text-1', | ||
text: 'Some cool text', | ||
type: 'body', | ||
}, | ||
], | ||
}, | ||
payload: { | ||
customKey: 'customValue', | ||
anotherKey: 123, | ||
}, | ||
}; | ||
|
||
const message = new IterableEmbeddedMessage(dict); | ||
|
||
expect(message).toBeInstanceOf(IterableEmbeddedMessage); | ||
|
||
// Check metadata | ||
expect(message.metadata).toBeInstanceOf(Object); | ||
expect(message.metadata.messageId).toBe('msg-123'); | ||
expect(message.metadata.placementId).toBe(1); | ||
expect(message.metadata.campaignId).toBe(456); | ||
expect(message.metadata.isProof).toBe(false); | ||
|
||
// Check elements | ||
expect(message.elements).toBeInstanceOf(Object); | ||
expect(message.elements?.title).toBe('Awesome Title'); | ||
expect(message.elements?.body).toBe('Radical Body Text'); | ||
expect(message.elements?.mediaUrl).toBe('https://example.com/image.jpg'); | ||
expect(message.elements?.mediaUrlCaption).toBe( | ||
'Check out this sick image!' | ||
); | ||
|
||
// Check payload | ||
expect(message.payload).toEqual({ | ||
customKey: 'customValue', | ||
anotherKey: 123, | ||
}); | ||
}); | ||
|
||
it('should create an instance with only required metadata', () => { | ||
Iterable.logger.log('iterableEmbeddedMessage_fromDict_required_only'); | ||
|
||
const dict = { | ||
metadata: { | ||
messageId: 'msg-123', | ||
placementId: 1, | ||
isProof: false, | ||
}, | ||
}; | ||
|
||
const message = new IterableEmbeddedMessage(dict); | ||
|
||
expect(message).toBeInstanceOf(IterableEmbeddedMessage); | ||
expect(message.metadata).toBeInstanceOf(Object); | ||
expect(message.metadata.messageId).toBe('msg-123'); | ||
expect(message.metadata.placementId).toBe(1); | ||
expect(message.metadata.campaignId).toBeUndefined(); | ||
expect(message.metadata.isProof).toBe(false); | ||
expect(message.elements).toBeUndefined(); | ||
expect(message.payload).toBeUndefined(); | ||
}); | ||
|
||
it('should throw an error if metadata is missing', () => { | ||
Iterable.logger.log('iterableEmbeddedMessage_fromDict_missing_metadata'); | ||
|
||
const dict = { | ||
elements: { | ||
title: 'Some Title', | ||
body: 'Some Body', | ||
}, | ||
}; | ||
|
||
// @ts-expect-error - metadata is purposely missing | ||
expect(() => new IterableEmbeddedMessage(dict)).toThrow( | ||
'metadata is required' | ||
); | ||
}); | ||
|
||
it('should create an instance with elements but no payload', () => { | ||
Iterable.logger.log('iterableEmbeddedMessage_fromDict_elements_only'); | ||
|
||
const dict = { | ||
metadata: { | ||
messageId: 'msg-123', | ||
placementId: 1, | ||
isProof: false, | ||
}, | ||
elements: { | ||
title: 'Elements Only', | ||
body: 'No payload here', | ||
}, | ||
}; | ||
|
||
const message = new IterableEmbeddedMessage(dict); | ||
|
||
expect(message).toBeInstanceOf(IterableEmbeddedMessage); | ||
expect(message.metadata).toBeInstanceOf(Object); | ||
expect(message.elements).toBeInstanceOf(Object); | ||
expect(message.elements?.title).toBe('Elements Only'); | ||
expect(message.elements?.body).toBe('No payload here'); | ||
expect(message.payload).toBeUndefined(); | ||
}); | ||
|
||
it('should create an instance with payload but no elements', () => { | ||
Iterable.logger.log('iterableEmbeddedMessage_fromDict_payload_only'); | ||
|
||
const dict = { | ||
metadata: { | ||
messageId: 'msg-123', | ||
placementId: 1, | ||
isProof: false, | ||
}, | ||
payload: { | ||
someData: 'someValue', | ||
}, | ||
}; | ||
|
||
const message = new IterableEmbeddedMessage(dict); | ||
|
||
expect(message).toBeInstanceOf(IterableEmbeddedMessage); | ||
expect(message.metadata).toBeInstanceOf(Object); | ||
expect(message.elements).toBeUndefined(); | ||
expect(message.payload).toEqual({ | ||
someData: 'someValue', | ||
}); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { IterableEmbeddedMessageButton } from '../embedded/classes/IterableEmbeddedMessageButton'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
import { Iterable } from '../core/classes/Iterable'; | ||
|
||
describe('IterableEmbeddedMessageButton', () => { | ||
it('should create an instance with all properties including button action', () => { | ||
Iterable.logger.log( | ||
'iterableEmbeddedMessageButton_fromDict_all_properties' | ||
); | ||
|
||
const dict = { | ||
id: 'button-123', | ||
title: 'Click Me!', | ||
action: { type: 'openUrl', data: 'https://example.com' }, | ||
}; | ||
|
||
const button = new IterableEmbeddedMessageButton(dict); | ||
|
||
expect(button).toBeInstanceOf(IterableEmbeddedMessageButton); | ||
expect(button.id).toBe('button-123'); | ||
expect(button.title).toBe('Click Me!'); | ||
expect(button.action).toBeInstanceOf(Object); | ||
expect(button.action?.type).toBe('openUrl'); | ||
expect(button.action?.data).toBe('https://example.com'); | ||
}); | ||
|
||
it('should create an instance with only required properties', () => { | ||
Iterable.logger.log('iterableEmbeddedMessageButton_fromDict_required_only'); | ||
|
||
const dict = { id: 'button-123' }; | ||
|
||
const button = new IterableEmbeddedMessageButton(dict); | ||
|
||
expect(button).toBeInstanceOf(IterableEmbeddedMessageButton); | ||
expect(button.id).toBe('button-123'); | ||
expect(button.title).toBeUndefined(); | ||
expect(button.action).toBeUndefined(); | ||
}); | ||
|
||
it('should create an instance with title but no action', () => { | ||
Iterable.logger.log('iterableEmbeddedMessageButton_fromDict_title_only'); | ||
|
||
const dict = { | ||
id: 'button-123', | ||
title: 'Click Me!', | ||
}; | ||
|
||
const button = new IterableEmbeddedMessageButton(dict); | ||
|
||
expect(button).toBeInstanceOf(IterableEmbeddedMessageButton); | ||
expect(button.id).toBe('button-123'); | ||
expect(button.title).toBe('Click Me!'); | ||
expect(button.action).toBeUndefined(); | ||
}); | ||
|
||
it('should throw an error if id is missing', () => { | ||
Iterable.logger.log('iterableEmbeddedMessageButton_fromDict_missing_id'); | ||
|
||
const dict = { | ||
title: 'Click Me!', | ||
action: { type: 'openUrl', data: 'https://example.com' }, | ||
}; | ||
// @ts-expect-error - id is purposely missing | ||
expect(() => new IterableEmbeddedMessageButton(dict)).toThrow( | ||
'id is required' | ||
); | ||
}); | ||
|
||
it('should handle button action with only type', () => { | ||
Iterable.logger.log( | ||
'iterableEmbeddedMessageButton_fromDict_action_type_only' | ||
); | ||
|
||
const dict = { | ||
id: 'button-123', | ||
action: { type: 'close' }, | ||
}; | ||
|
||
const button = new IterableEmbeddedMessageButton(dict); | ||
|
||
expect(button).toBeInstanceOf(IterableEmbeddedMessageButton); | ||
expect(button.id).toBe('button-123'); | ||
expect(button.action).toBeInstanceOf(Object); | ||
expect(button.action?.type).toBe('close'); | ||
expect(button.action?.data).toBeUndefined(); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]