@pinwheel/react-native-pinwheel 3.5.2 → 3.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,7 +32,7 @@ repositories {
32
32
  google()
33
33
  }
34
34
 
35
- def PW_ANDROID_SDK_VERSION = '3.5.1'
35
+ def PW_ANDROID_SDK_VERSION = '3.5.2'
36
36
 
37
37
  dependencies {
38
38
  def pwVersion = rootProject.hasProperty('pwVersion') ? rootProject.pwVersion : PW_ANDROID_SDK_VERSION
@@ -89,7 +89,7 @@ class Pinwheel : FrameLayout {
89
89
  Handler(Looper.getMainLooper()).post {
90
90
  if (this.pinwheelFragment == null) {
91
91
  this.token?.let {
92
- val pinwheelFragment = PinwheelFragment.newInstanceWithAdvancedOptions(it, "react native", "3.5.2", getReactNativeVersion(), this.handleInsets, this.useDarkMode)
92
+ val pinwheelFragment = PinwheelFragment.newInstanceWithAdvancedOptions(it, "react native", "3.5.4", getReactNativeVersion(), this.handleInsets, this.useDarkMode)
93
93
  pinwheelEventListener?.let { listener ->
94
94
  pinwheelFragment.pinwheelEventListener = listener
95
95
  }
@@ -14,6 +14,7 @@ import com.underdog_tech.pinwheel_android.model.PinwheelEventType
14
14
  import com.underdog_tech.pinwheel_android.model.PinwheelInputAllocationPayload
15
15
  import com.underdog_tech.pinwheel_android.model.PinwheelTarget
16
16
  import com.underdog_tech.pinwheel_android.model.PinwheelAllocation
17
+ import com.underdog_tech.pinwheel_android.model.PinwheelBillSwitchEventPayload
17
18
  import com.underdog_tech.pinwheel_android.model.PinwheelParams
18
19
  import com.underdog_tech.pinwheel_android.model.PinwheelResult
19
20
  import com.underdog_tech.pinwheel_android.model.PinwheelError
@@ -22,56 +23,58 @@ import com.underdog_tech.pinwheel_android.model.PinwheelSelectedPlatformPayload
22
23
  import com.underdog_tech.pinwheel_android.model.PinwheelLoginPayload
23
24
  import com.underdog_tech.pinwheel_android.model.PinwheelLoginAttemptPayload
24
25
  import com.underdog_tech.pinwheel_android.model.PinwheelDDFormCreatePayload
26
+ import com.underdog_tech.pinwheel_android.model.PinwheelExternalAccountConnectedPayload
27
+ import com.underdog_tech.pinwheel_android.model.PinwheelOtherEventPayload
25
28
  import com.underdog_tech.pinwheel_android.model.PinwheelScreenTransitionPayload
26
29
 
27
30
  @ReactModule(name = PinwheelEventsModule.NAME)
28
31
  class PinwheelEventsModule(private val context: ReactApplicationContext) : ReactContextBaseJavaModule(context), PinwheelEventListener {
29
- init {
30
- Companion.context = context
31
- }
32
+ init {
33
+ Companion.context = context
34
+ }
32
35
 
33
- override fun getName(): String = NAME
36
+ override fun getName(): String = NAME
34
37
 
35
- @ReactMethod
36
- fun setListener() {
37
- hasListeners = true;
38
- }
38
+ @ReactMethod
39
+ fun setListener() {
40
+ hasListeners = true;
41
+ }
39
42
 
40
- @ReactMethod
41
- fun removeListener() {
42
- hasListeners = false;
43
- }
43
+ @ReactMethod
44
+ fun removeListener() {
45
+ hasListeners = false;
46
+ }
44
47
 
45
- @ReactMethod
46
- fun addListener(eventName: String) {
47
- // Keep: Required for RN built in Event Emitter Calls.
48
- }
48
+ @ReactMethod
49
+ fun addListener(eventName: String) {
50
+ // Keep: Required for RN built in Event Emitter Calls.
51
+ }
49
52
 
50
- @ReactMethod
51
- fun removeListeners(count: Int) {
52
- // Keep: Required for RN built in Event Emitter Calls.
53
- }
53
+ @ReactMethod
54
+ fun removeListeners(count: Int) {
55
+ // Keep: Required for RN built in Event Emitter Calls.
56
+ }
54
57
 
55
- override fun onEvent(eventName: PinwheelEventType, payload: PinwheelEventPayload?) {
56
- if (!hasListeners) return
57
-
58
- val params = WritableNativeMap()
59
- params.putString("name", eventName.toString())
60
- if (payload != null) {
61
- params.putMap("payload", payload.toWritableMap())
62
- }
63
-
64
- context
65
- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
66
- .emit(Companion.PinwheelEventName, params)
67
- }
58
+ override fun onEvent(eventName: PinwheelEventType, payload: PinwheelEventPayload?) {
59
+ if (!hasListeners) return
68
60
 
69
- companion object {
70
- const val NAME = "RTNPinwheelEvents"
71
- const val PinwheelEventName = "PINWHEEL_EVENT"
72
- private var context: ReactApplicationContext? = null
73
- private var hasListeners = false;
61
+ val params = WritableNativeMap()
62
+ params.putString("name", eventName.toString())
63
+ if (payload != null) {
64
+ params.putMap("payload", payload.toWritableMap())
74
65
  }
66
+
67
+ context
68
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
69
+ .emit(Companion.PinwheelEventName, params)
70
+ }
71
+
72
+ companion object {
73
+ const val NAME = "RTNPinwheelEvents"
74
+ const val PinwheelEventName = "PINWHEEL_EVENT"
75
+ private var context: ReactApplicationContext? = null
76
+ private var hasListeners = false;
77
+ }
75
78
  }
76
79
 
77
80
  fun PinwheelTarget.toWritableMap(): WritableMap {
@@ -109,30 +112,37 @@ fun PinwheelEventPayload.toWritableMap(): WritableMap = when (this) {
109
112
  putString("job", this@toWritableMap.job)
110
113
  putMap("params", this@toWritableMap.params?.toWritableMap())
111
114
  }
115
+
112
116
  is PinwheelError -> Arguments.createMap().apply {
113
117
  putString("type", this@toWritableMap.type)
114
118
  putString("code", this@toWritableMap.code)
115
119
  putString("message", this@toWritableMap.message)
116
120
  putBoolean("pendingRetry", this@toWritableMap.pendingRetry)
117
121
  }
122
+
118
123
  is PinwheelSelectedEmployerPayload -> Arguments.createMap().apply {
119
124
  putString("selectedEmployerId", this@toWritableMap.selectedEmployerId)
120
125
  putString("selectedEmployerName", this@toWritableMap.selectedEmployerName)
121
126
  }
127
+
122
128
  is PinwheelSelectedPlatformPayload -> Arguments.createMap().apply {
123
129
  putString("selectedPlatformId", this@toWritableMap.selectedPlatformId)
124
130
  putString("selectedPlatformName", this@toWritableMap.selectedPlatformName)
125
131
  }
132
+
126
133
  is PinwheelLoginPayload -> Arguments.createMap().apply {
127
134
  putString("accountId", this@toWritableMap.accountId)
128
135
  putString("platformId", this@toWritableMap.platformId)
129
136
  }
137
+
130
138
  is PinwheelLoginAttemptPayload -> Arguments.createMap().apply {
131
139
  putString("platformId", this@toWritableMap.platformId)
132
140
  }
141
+
133
142
  is PinwheelDDFormCreatePayload -> Arguments.createMap().apply {
134
143
  putString("url", this@toWritableMap.url)
135
144
  }
145
+
136
146
  is PinwheelScreenTransitionPayload -> Arguments.createMap().apply {
137
147
  putString("screenName", this@toWritableMap.screenName)
138
148
  putString("selectedEmployerId", this@toWritableMap.selectedEmployerId)
@@ -140,5 +150,33 @@ fun PinwheelEventPayload.toWritableMap(): WritableMap = when (this) {
140
150
  putString("selectedPlatformId", this@toWritableMap.selectedPlatformId)
141
151
  putString("selectedPlatformName", this@toWritableMap.selectedPlatformName)
142
152
  }
153
+
154
+ is PinwheelOtherEventPayload -> Arguments.createMap().apply {
155
+ putString("name", this@toWritableMap.name)
156
+ val payloadArray = Arguments.createArray()
157
+ this@toWritableMap.payload.forEach { item ->
158
+ val map = Arguments.createMap()
159
+ map.putString("key", item.key)
160
+ map.putString("value", item.value)
161
+ map.putString("type", item.type.name)
162
+ payloadArray.pushMap(map)
163
+ }
164
+ putArray("payload", payloadArray)
165
+ }
166
+
167
+ is PinwheelBillSwitchEventPayload -> Arguments.createMap().apply {
168
+ putString("platformId", this@toWritableMap.platformId)
169
+ putString("platformName", this@toWritableMap.platformName)
170
+ putBoolean("isIntegratedSwitch", this@toWritableMap.isIntegratedSwitch)
171
+ putString("frequency", this@toWritableMap.frequency)
172
+ putString("nextPaymentDate", this@toWritableMap.nextPaymentDate)
173
+ putInt("amountCents", this@toWritableMap.amountCents)
174
+ }
175
+
176
+ is PinwheelExternalAccountConnectedPayload -> Arguments.createMap().apply {
177
+ putString("institutionName", this@toWritableMap.institutionName)
178
+ putString("accountName", this@toWritableMap.accountName)
179
+ }
180
+
143
181
  else -> throw IllegalArgumentException("Unsupported PinwheelEventPayload type")
144
182
  }
@@ -74,7 +74,7 @@ using namespace facebook::react;
74
74
  [[PinwheelWrapperVC alloc] initWithToken:self.token
75
75
  delegate:self
76
76
  sdk:@"react native"
77
- version:@"3.5.2"
77
+ version:@"3.5.4"
78
78
  useDarkMode:self.useDarkMode
79
79
  useAppBoundDomains:NO
80
80
  useAppBoundDomainsForNativeLink:NO];
@@ -97,8 +97,6 @@ using namespace facebook::react;
97
97
  if (!self.pinwheelWrapperVC) {
98
98
  [self initPinwheelWrapperVC];
99
99
  }
100
- } else {
101
- [self cleanUpPinwheelWrapperVC];
102
100
  }
103
101
  }
104
102
 
@@ -239,7 +237,7 @@ Class<RCTComponentViewProtocol> RTNPinwheelCls(void) {
239
237
  [[PinwheelWrapperVC alloc] initWithToken:self.token
240
238
  delegate:self
241
239
  sdk:@"react native"
242
- version:@"3.5.2"
240
+ version:@"3.5.4"
243
241
  useDarkMode:self.useDarkMode
244
242
  useAppBoundDomains:NO
245
243
  useAppBoundDomainsForNativeLink:NO];
@@ -262,8 +260,6 @@ Class<RCTComponentViewProtocol> RTNPinwheelCls(void) {
262
260
  if (!self.pinwheelWrapperVC) {
263
261
  [self initPinwheelWrapperVC];
264
262
  }
265
- } else {
266
- [self cleanUpPinwheelWrapperVC];
267
263
  }
268
264
  }
269
265
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinwheel/react-native-pinwheel",
3
- "version": "3.5.2",
3
+ "version": "3.5.4",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -1,80 +1,67 @@
1
1
  import type { AdditionsType, ModificationsType, RemovalsType } from '../utils';
2
- export type PinwheelErrorType =
3
- | 'sandboxError'
4
- | 'clientError'
5
- | 'systemError'
6
- | 'userActionRequired'
7
- | 'platformError'
8
- | 'invalidAccountsConfiguration'
9
- | 'invalidUserInput'
10
- | 'invalidLinkToken'
11
- | 'networkError';
2
+ export type PinwheelErrorType = 'sandboxError' | 'clientError' | 'systemError' | 'userActionRequired' | 'platformError' | 'invalidAccountsConfiguration' | 'invalidUserInput' | 'invalidLinkToken' | 'networkError';
12
3
  export type LinkApiJob = 'login' | 'direct_deposit_switch' | 'card_switch';
13
4
  export type OpenEventPayload = {};
14
5
  export type SelectEmployerEventPayload = {
15
- selectedEmployerId: string;
16
- selectedEmployerName: string;
6
+ selectedEmployerId: string;
7
+ selectedEmployerName: string;
17
8
  };
18
9
  export type SelectPlatformEventPayload = {
19
- selectedPlatformId: string;
20
- selectedPlatformName: string;
10
+ selectedPlatformId: string;
11
+ selectedPlatformName: string;
21
12
  };
22
13
  export type IncorrectPlatformGivenEventPayload = {};
23
14
  export type LoginAttemptEventPayload = {
24
- platformId: string;
15
+ platformId: string;
25
16
  };
26
17
  export type LoginEventPayload = {
27
- accountId: string;
28
- platformId: string;
18
+ accountId: string;
19
+ platformId: string;
29
20
  };
30
21
  export type InputAmountEventPayload = {
31
- value: number;
32
- unit: '$' | '%';
22
+ value: number;
23
+ unit: '$' | '%';
33
24
  };
34
25
  type _PartialSwitch<T> = {
35
- action: 'partial_switch';
36
- allocation: T;
26
+ action: 'partial_switch';
27
+ allocation: T;
37
28
  };
38
29
  type InputAllocationPercentage = _PartialSwitch<{
39
- type: 'percentage';
40
- value: number;
30
+ type: 'percentage';
31
+ value: number;
41
32
  }>;
42
33
  type InputAllocationAmount = _PartialSwitch<{
43
- type: 'amount';
44
- value: number;
34
+ type: 'amount';
35
+ value: number;
45
36
  }>;
46
37
  type InputAllocationRemainder = _PartialSwitch<{
47
- type: 'remainder';
38
+ type: 'remainder';
48
39
  }>;
49
- export type InputAllocationEventPayload =
50
- | {
51
- action: 'full_switch';
52
- }
53
- | InputAllocationRemainder
54
- | InputAllocationAmount
55
- | InputAllocationPercentage;
40
+ export type InputAllocationEventPayload = {
41
+ action: 'full_switch';
42
+ } | InputAllocationRemainder | InputAllocationAmount | InputAllocationPercentage;
56
43
  /**
57
44
  * @deprecated - Use `InputAllocationEventPayload` instead.
58
45
  */
59
46
  export type InputAllocation = InputAllocationEventPayload;
60
47
  export type CardSwitchBeginEventPayload = {};
61
48
  export type DocUploadsBeginEventPayload = {
62
- uploadedDocumentsSubmittedCount?: number;
49
+ uploadedDocumentsSubmittedCount?: number;
63
50
  };
64
51
  export type DocUploadsSubmittedEventPayload = {
65
- uploadedDocumentSubmittedCount: number;
52
+ uploadedDocumentSubmittedCount: number;
66
53
  };
67
54
  export type DdFormBeginEventPayload = {};
68
55
  export type DdFormCreateEventPayload = {
69
- url: string;
56
+ url: string;
70
57
  };
71
58
  export type DdFormDownloadEventPayload = {};
72
59
  export type ScreenTransitionEventPayload = {
73
- screenName: string;
74
- selectedEmployerId?: string;
75
- selectedEmployerName?: string;
76
- selectedPlatformId?: string;
77
- selectedPlatformName?: string;
60
+ screenName: string;
61
+ selectedEmployerId?: string;
62
+ selectedEmployerName?: string;
63
+ selectedPlatformId?: string;
64
+ selectedPlatformName?: string;
78
65
  };
79
66
  /**
80
67
  * @deprecated - Use `ScreenTransitionEventPayload` instead.
@@ -82,80 +69,74 @@ export type ScreenTransitionEventPayload = {
82
69
  export type ScreenTransition = ScreenTransitionEventPayload;
83
70
  export type ExitEventPayload = Record<string, never>;
84
71
  export type SuccessEventPayload = {
85
- accountId: string;
86
- platformId: string;
87
- job: LinkApiJob;
88
- params?: {
89
- amount?: {
90
- value: number;
91
- unit: '%' | '$';
72
+ accountId: string;
73
+ platformId: string;
74
+ job: LinkApiJob;
75
+ params?: {
76
+ amount?: {
77
+ value: number;
78
+ unit: '%' | '$';
79
+ };
92
80
  };
93
- };
94
81
  };
95
82
  export type ErrorEventPayload = {
96
- type: PinwheelErrorType;
97
- code: string;
98
- message: string;
99
- pendingRetry: boolean;
83
+ type: PinwheelErrorType;
84
+ code: string;
85
+ message: string;
86
+ pendingRetry: boolean;
100
87
  };
101
88
  export type OtherEventPayload = {
102
- name: string;
103
- payload: {
104
- key: string;
105
- value: string;
106
- type: 'string' | 'boolean' | 'number';
107
- }[];
89
+ name: string;
90
+ payload: {
91
+ key: string;
92
+ value: string;
93
+ type: 'string' | 'boolean' | 'number';
94
+ }[];
108
95
  };
109
96
  export type BillSwitchPayload = {
110
- platformId: string;
111
- platformName: string;
112
- isGuidedSwitch: boolean;
113
- frequency: string;
114
- nextPaymentDate: string;
115
- amountCents: number;
97
+ platformId: string;
98
+ platformName: string;
99
+ isGuidedSwitch: boolean;
100
+ isIntegratedSwitch: boolean;
101
+ frequency: string;
102
+ nextPaymentDate: string;
103
+ amountCents: number;
116
104
  };
117
105
  export type ExternalAccountConnectedPayload = {
118
- institutionName: string;
119
- accountName: string;
106
+ institutionName: string;
107
+ accountName: string;
120
108
  };
121
109
  /**
122
110
  * @deprecated - Use `ErrorEventPayload` instead.
123
111
  */
124
112
  export type PinwheelError = ErrorEventPayload;
125
113
  type EventPayloadAdditions = {
126
- open: OpenEventPayload;
127
- select_employer: SelectEmployerEventPayload;
128
- select_platform: SelectPlatformEventPayload;
129
- incorrect_platform_given: IncorrectPlatformGivenEventPayload;
130
- login_attempt: LoginAttemptEventPayload;
131
- login: LoginEventPayload;
132
- input_amount: InputAmountEventPayload;
133
- input_allocation: InputAllocationEventPayload;
134
- card_switch_begin: CardSwitchBeginEventPayload;
135
- doc_uploads_begin: DocUploadsBeginEventPayload;
136
- doc_uploads_submitted: DocUploadsSubmittedEventPayload;
137
- dd_form_begin: DdFormBeginEventPayload;
138
- dd_form_create: DdFormCreateEventPayload;
139
- dd_form_download: DdFormDownloadEventPayload;
140
- screen_transition: ScreenTransitionEventPayload;
141
- exit: ErrorEventPayload | ExitEventPayload;
142
- other_event: OtherEventPayload;
143
- success: SuccessEventPayload;
144
- error: ErrorEventPayload;
145
- bill_switch_success: BillSwitchPayload;
146
- bill_removed: BillSwitchPayload;
147
- external_account_connected: ExternalAccountConnectedPayload;
148
- merchant_login_success: LoginEventPayload;
114
+ open: OpenEventPayload;
115
+ select_employer: SelectEmployerEventPayload;
116
+ select_platform: SelectPlatformEventPayload;
117
+ incorrect_platform_given: IncorrectPlatformGivenEventPayload;
118
+ login_attempt: LoginAttemptEventPayload;
119
+ login: LoginEventPayload;
120
+ input_amount: InputAmountEventPayload;
121
+ input_allocation: InputAllocationEventPayload;
122
+ card_switch_begin: CardSwitchBeginEventPayload;
123
+ doc_uploads_begin: DocUploadsBeginEventPayload;
124
+ doc_uploads_submitted: DocUploadsSubmittedEventPayload;
125
+ dd_form_begin: DdFormBeginEventPayload;
126
+ dd_form_create: DdFormCreateEventPayload;
127
+ dd_form_download: DdFormDownloadEventPayload;
128
+ screen_transition: ScreenTransitionEventPayload;
129
+ exit: ErrorEventPayload | ExitEventPayload;
130
+ other_event: OtherEventPayload;
131
+ success: SuccessEventPayload;
132
+ error: ErrorEventPayload;
133
+ bill_switch_success: BillSwitchPayload;
134
+ bill_removed: BillSwitchPayload;
135
+ external_account_connected: ExternalAccountConnectedPayload;
136
+ merchant_login_success: LoginEventPayload;
149
137
  };
150
138
  type EventPayloadModifications = {};
151
139
  type EventPayloadRemovals = [];
152
- export type EventPayloadMap = Omit<
153
- AdditionsType<EventPayloadAdditions> &
154
- ModificationsType<EventPayloadModifications>,
155
- keyof RemovalsType<EventPayloadRemovals>
156
- >;
157
- export type EventHandler = <T extends keyof EventPayloadMap>(
158
- eventName: T,
159
- payload: EventPayloadMap[T]
160
- ) => void;
140
+ export type EventPayloadMap = Omit<AdditionsType<EventPayloadAdditions> & ModificationsType<EventPayloadModifications>, keyof RemovalsType<EventPayloadRemovals>>;
141
+ export type EventHandler = <T extends keyof EventPayloadMap>(eventName: T, payload: EventPayloadMap[T]) => void;
161
142
  export {};
@@ -126,7 +126,8 @@ export type OtherEventPayload = {
126
126
  export type BillSwitchPayload = {
127
127
  platformId: string;
128
128
  platformName: string;
129
- isGuidedSwitch: boolean;
129
+ isGuidedSwitch: boolean; // deprecated: will be removed in future version
130
+ isIntegratedSwitch: boolean;
130
131
  frequency: string;
131
132
  nextPaymentDate: string;
132
133
  amountCents: number;