Skip to content

Commit

Permalink
Merge pull request #67 from mxenabled/jameson/CT-447
Browse files Browse the repository at this point in the history
Jameson/CT-447
  • Loading branch information
Jameson13B authored Mar 4, 2024
2 parents f849754 + cdadf6f commit 6110b5a
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/post_message_definition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ post_messages:
context:
type: string
optional: true
invalidData:
payload:
<<: *user_session_properties
member_guid: string
code: number
pulse:
overdraftWarning/cta/transferFunds:
payload:
Expand Down
19 changes: 19 additions & 0 deletions packages/swift/Sources/Generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,19 @@ public enum ConnectWidgetEvent {
&& lhs.context == rhs.context
}
}
public struct InvalidData: Event {
public var userGuid: String
public var sessionGuid: String
public var memberGuid: String
public var code: Double

public static func == (lhs: ConnectWidgetEvent.InvalidData, rhs: ConnectWidgetEvent.InvalidData) -> Bool {
return lhs.userGuid == rhs.userGuid
&& lhs.sessionGuid == rhs.sessionGuid
&& lhs.memberGuid == rhs.memberGuid
&& lhs.code == rhs.code
}
}
}

public enum PulseWidgetEvent {
Expand Down Expand Up @@ -326,6 +339,7 @@ public protocol ConnectWidgetEventDelegate: WidgetEventDelegate {
func widgetEvent(_ payload: ConnectWidgetEvent.SubmitMFA)
func widgetEvent(_ payload: ConnectWidgetEvent.UpdateCredentials)
func widgetEvent(_ payload: ConnectWidgetEvent.BackToSearch)
func widgetEvent(_ payload: ConnectWidgetEvent.InvalidData)
}

public extension ConnectWidgetEventDelegate {
Expand All @@ -344,6 +358,7 @@ public extension ConnectWidgetEventDelegate {
func widgetEvent(_: ConnectWidgetEvent.SubmitMFA) {}
func widgetEvent(_: ConnectWidgetEvent.UpdateCredentials) {}
func widgetEvent(_: ConnectWidgetEvent.BackToSearch) {}
func widgetEvent(_: ConnectWidgetEvent.InvalidData) {}
}

public protocol PulseWidgetEventDelegate: WidgetEventDelegate {
Expand Down Expand Up @@ -480,6 +495,8 @@ class ConnectWidgetEventDispatcher: Dispatcher {
delegate.widgetEvent(event)
case let event as ConnectWidgetEvent.BackToSearch:
delegate.widgetEvent(event)
case let event as ConnectWidgetEvent.InvalidData:
delegate.widgetEvent(event)
default:
// Unreachable
return nil
Expand Down Expand Up @@ -532,6 +549,8 @@ class ConnectWidgetEventDispatcher: Dispatcher {
return try? decode(ConnectWidgetEvent.UpdateCredentials.self, metadata)
case ("connect", "/backToSearch"):
return try? decode(ConnectWidgetEvent.BackToSearch.self, metadata)
case ("connect", "/invalidData"):
return try? decode(ConnectWidgetEvent.InvalidData.self, metadata)
default:
return .none
}
Expand Down
30 changes: 30 additions & 0 deletions packages/typescript/docs/react-native-sdk-generated.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,3 +464,33 @@ import { ConnectWidget } from "@mxenabled/react-native-widget-sdk"
</details>
---
### Invalid data (`mx/connect/invalidData`)
- Widget callback prop name: `onInvalidData`
- Payload fields:
- `user_guid` (`string`)
- `session_guid` (`string`)
- `member_guid` (`string`)
- `code` (`number`)
<details>
<summary>Click here to view a sample usage of <code>onInvalidData</code>.</summary>
```jsx
import { ConnectWidget } from "@mxenabled/react-native-widget-sdk"

<ConnectWidget
url="https://widgets.moneydesktop.com/md/connect/..."

onInvalidData={(payload) => {
console.log(`User guid: ${payload.user_guid}`)
console.log(`Session guid: ${payload.session_guid}`)
console.log(`Member guid: ${payload.member_guid}`)
console.log(`Code: ${payload.code}`)
}
/>
```
</details>
28 changes: 28 additions & 0 deletions packages/typescript/docs/web-sdk-generated.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,3 +434,31 @@ const widget = widgetSdk.ConnectWidget({

</details>

---
### Invalid data (`mx/connect/invalidData`)

- Widget callback prop name: `onInvalidData`
- Payload fields:
- `user_guid` (`string`)
- `session_guid` (`string`)
- `member_guid` (`string`)
- `code` (`number`)

<details>
<summary>Click here to view a sample usage of <code>onInvalidData</code>.</summary>

```javascript
const widget = widgetSdk.ConnectWidget({
url: "https://widgets.moneydesktop.com/md/connect/...",

onInvalidData: (payload) => {
console.log(`User guid: ${payload.user_guid}`)
console.log(`Session guid: ${payload.session_guid}`)
console.log(`Member guid: ${payload.member_guid}`)
console.log(`Code: ${payload.code}`)
}
})
```

</details>

4 changes: 2 additions & 2 deletions packages/typescript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mxenabled/widget-post-message-definitions",
"version": "1.3.0",
"version": "1.4.0",
"description": "Widget Post Message Definitions for use in SDKs",
"main": "dist/index.js",
"license": "MIT",
Expand Down
31 changes: 31 additions & 0 deletions packages/typescript/src/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export enum Type {
ConnectSubmitMFA = "mx/connect/submitMFA",
ConnectUpdateCredentials = "mx/connect/updateCredentials",
ConnectBackToSearch = "mx/connect/backToSearch",
ConnectInvalidData = "mx/connect/invalidData",
PulseOverdraftWarningCtaTransferFunds = "mx/pulse/overdraftWarning/cta/transferFunds",
AccountCreated = "mx/account/created",
}
Expand Down Expand Up @@ -78,6 +79,8 @@ const typeLookup: Record<string, Type> = {
"mx/connect/updatecredentials": Type.ConnectUpdateCredentials, // cspell:disable-line
[Type.ConnectBackToSearch]: Type.ConnectBackToSearch,
"mx/connect/backtosearch": Type.ConnectBackToSearch, // cspell:disable-line
[Type.ConnectInvalidData]: Type.ConnectInvalidData,
"mx/connect/invaliddata": Type.ConnectInvalidData, // cspell:disable-line
[Type.PulseOverdraftWarningCtaTransferFunds]: Type.PulseOverdraftWarningCtaTransferFunds,
"mx/pulse/overdraftwarning/cta/transferfunds": Type.PulseOverdraftWarningCtaTransferFunds, // cspell:disable-line
[Type.AccountCreated]: Type.AccountCreated,
Expand Down Expand Up @@ -224,6 +227,14 @@ export type ConnectBackToSearchPayload = {
context?: string,
}

export type ConnectInvalidDataPayload = {
type: Type.ConnectInvalidData,
user_guid: string,
session_guid: string,
member_guid: string,
code: number,
}

export type PulseOverdraftWarningCtaTransferFundsPayload = {
type: Type.PulseOverdraftWarningCtaTransferFunds,
account_guid: string,
Expand Down Expand Up @@ -257,6 +268,7 @@ export type WidgetPayload =
| ConnectSubmitMFAPayload
| ConnectUpdateCredentialsPayload
| ConnectBackToSearchPayload
| ConnectInvalidDataPayload
| PulseOverdraftWarningCtaTransferFundsPayload

export type EntityPayload =
Expand Down Expand Up @@ -520,6 +532,20 @@ function buildPayload(type: Type, metadata: Metadata): Payload {
context: metadata.context as string | undefined,
}

case Type.ConnectInvalidData:
assertMessageProp(metadata, "mx/connect/invalidData", "user_guid", "string")
assertMessageProp(metadata, "mx/connect/invalidData", "session_guid", "string")
assertMessageProp(metadata, "mx/connect/invalidData", "member_guid", "string")
assertMessageProp(metadata, "mx/connect/invalidData", "code", "number")

return {
type,
user_guid: metadata.user_guid as string,
session_guid: metadata.session_guid as string,
member_guid: metadata.member_guid as string,
code: metadata.code as number,
}

case Type.PulseOverdraftWarningCtaTransferFunds:
assertMessageProp(metadata, "mx/pulse/overdraftWarning/cta/transferFunds", "account_guid", "string")
assertMessageProp(metadata, "mx/pulse/overdraftWarning/cta/transferFunds", "amount", "number")
Expand Down Expand Up @@ -621,6 +647,7 @@ export type ConnectPostMessageCallbackProps<T> = WidgetPostMessageCallbackProps<
onSubmitMFA?: (payload: ConnectSubmitMFAPayload) => void
onUpdateCredentials?: (payload: ConnectUpdateCredentialsPayload) => void
onBackToSearch?: (payload: ConnectBackToSearchPayload) => void
onInvalidData?: (payload: ConnectInvalidDataPayload) => void
}

export type PulsePostMessageCallbackProps<T> = WidgetPostMessageCallbackProps<T> & {
Expand Down Expand Up @@ -840,6 +867,10 @@ function dispatchConnectInternalMessage<T>(payload: Payload, callbacks: ConnectP
callbacks.onBackToSearch?.(payload)
break

case Type.ConnectInvalidData:
callbacks.onInvalidData?.(payload)
break

default:
throw new PostMessageUnknownTypeError(payload.type)
}
Expand Down

0 comments on commit 6110b5a

Please sign in to comment.