@pinwheel/react-native-pinwheel 3.7.1 → 4.0.0

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.
@@ -19,5 +19,5 @@ Pod::Spec.new do |s|
19
19
 
20
20
  install_modules_dependencies(s)
21
21
 
22
- s.dependency 'PinwheelSDK', '3.5.0'
22
+ s.dependency 'PinwheelSDK', '4.0.0'
23
23
  end
@@ -32,7 +32,7 @@ repositories {
32
32
  google()
33
33
  }
34
34
 
35
- def PW_ANDROID_SDK_VERSION = '3.6.0'
35
+ def PW_ANDROID_SDK_VERSION = '4.0.0'
36
36
 
37
37
  dependencies {
38
38
  def pwVersion = rootProject.hasProperty('pwVersion') ? rootProject.pwVersion : PW_ANDROID_SDK_VERSION
@@ -97,7 +97,7 @@ class Pinwheel : FrameLayout {
97
97
  val pinwheelFragment = PinwheelFragment.newInstanceWithAdvancedOptions(
98
98
  it,
99
99
  "react native",
100
- "3.7.1",
100
+ "4.0.0",
101
101
  getReactNativeVersion(),
102
102
  this.handleInsets,
103
103
  this.useDarkMode,
@@ -14,7 +14,11 @@ 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.PinwheelBillEventPayload
17
18
  import com.underdog_tech.pinwheel_android.model.PinwheelBillSwitchEventPayload
19
+ import com.underdog_tech.pinwheel_android.model.PinwheelBillSwitchPlatformsAddedEventPayload
20
+ import com.underdog_tech.pinwheel_android.model.PinwheelCalendarSyncEventPayload
21
+ import com.underdog_tech.pinwheel_android.model.PinwheelUserActivatedEventPayload
18
22
  import com.underdog_tech.pinwheel_android.model.PinwheelParams
19
23
  import com.underdog_tech.pinwheel_android.model.PinwheelResult
20
24
  import com.underdog_tech.pinwheel_android.model.PinwheelError
@@ -171,6 +175,34 @@ fun PinwheelEventPayload.toWritableMap(): WritableMap = when (this) {
171
175
  putString("frequency", this@toWritableMap.frequency)
172
176
  putString("nextPaymentDate", this@toWritableMap.nextPaymentDate)
173
177
  putInt("amountCents", this@toWritableMap.amountCents)
178
+ this@toWritableMap.accountId?.let { putString("accountId", it) }
179
+ }
180
+
181
+ is PinwheelBillEventPayload -> Arguments.createMap().apply {
182
+ putString("platformId", this@toWritableMap.platformId)
183
+ putString("platformName", this@toWritableMap.platformName)
184
+ putString("frequency", this@toWritableMap.frequency)
185
+ putString("nextPaymentDate", this@toWritableMap.nextPaymentDate)
186
+ putInt("amountCents", this@toWritableMap.amountCents)
187
+ }
188
+
189
+ is PinwheelBillSwitchPlatformsAddedEventPayload -> Arguments.createMap().apply {
190
+ val platformsArray = Arguments.createArray()
191
+ this@toWritableMap.platforms.forEach { platform ->
192
+ val map = Arguments.createMap()
193
+ map.putString("id", platform.id)
194
+ map.putString("name", platform.name)
195
+ platformsArray.pushMap(map)
196
+ }
197
+ putArray("platforms", platformsArray)
198
+ }
199
+
200
+ is PinwheelCalendarSyncEventPayload -> Arguments.createMap().apply {
201
+ putString("calendarType", this@toWritableMap.calendarType.name.lowercase())
202
+ }
203
+
204
+ is PinwheelUserActivatedEventPayload -> Arguments.createMap().apply {
205
+ putString("solutionName", this@toWritableMap.solutionName)
174
206
  }
175
207
 
176
208
  is PinwheelExternalAccountConnectedPayload -> Arguments.createMap().apply {
@@ -75,7 +75,7 @@ using namespace facebook::react;
75
75
  [[PWPinwheelWrapperVC alloc] initWithToken:self.token
76
76
  delegate:self
77
77
  sdk:@"react native"
78
- version:@"3.7.1"
78
+ version:@"4.0.0"
79
79
  useSecureOrigin:self.useSecureOrigin
80
80
  useDarkMode:self.useDarkMode
81
81
  useAppBoundDomains:NO
@@ -244,7 +244,7 @@ Class<RCTComponentViewProtocol> RTNPinwheelCls(void) {
244
244
  [[PWPinwheelWrapperVC alloc] initWithToken:self.token
245
245
  delegate:self
246
246
  sdk:@"react native"
247
- version:@"3.7.1"
247
+ version:@"4.0.0"
248
248
  useSecureOrigin:self.useSecureOrigin
249
249
  useDarkMode:self.useDarkMode
250
250
  useAppBoundDomains:NO
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinwheel/react-native-pinwheel",
3
- "version": "3.7.1",
3
+ "version": "4.0.0",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -22,6 +22,7 @@
22
22
  ],
23
23
  "scripts": {
24
24
  "build": "tsc",
25
+ "test:types": "tsc -p type-tests/tsconfig.json",
25
26
  "dev": "./scripts/dev_expo.sh",
26
27
  "dev:bare": "./scripts/dev_bare.sh"
27
28
  },
@@ -1,4 +1,4 @@
1
- import type { LoginEventPayload, SuccessEventPayload, EventHandler, ErrorEventPayload, LoginAttemptEventPayload } from './registry/v3';
1
+ import type { LoginEventPayload, SuccessEventPayload, EventHandler, ErrorEventPayload, LoginAttemptEventPayload } from './registry/v4';
2
2
  export type LinkOptions = {
3
3
  linkToken: string;
4
4
  useSecureOrigin?: boolean;
@@ -4,7 +4,7 @@ import type {
4
4
  EventHandler,
5
5
  ErrorEventPayload,
6
6
  LoginAttemptEventPayload,
7
- } from './registry/v3';
7
+ } from './registry/v4';
8
8
 
9
9
  export type LinkOptions = {
10
10
  linkToken: string;
@@ -0,0 +1,47 @@
1
+ import type { AdditionsType, ModificationsType, RemovalsType } from '../utils';
2
+ import type { BillSwitchPayload, EventPayloadMap as EventPayloadMapV3 } from './v3';
3
+ export * from './v3';
4
+ export type BillSwitchEventPayload = BillSwitchPayload & {
5
+ accountId?: string;
6
+ };
7
+ export type BillEventPayload = {
8
+ platformId: string;
9
+ platformName: string;
10
+ frequency: string;
11
+ nextPaymentDate: string;
12
+ amountCents: number;
13
+ };
14
+ export type BillSwitchPlatform = {
15
+ id: string;
16
+ name: string;
17
+ };
18
+ export type BillSwitchPlatformsPayload = {
19
+ platforms: BillSwitchPlatform[];
20
+ };
21
+ export type CalendarSyncEventPayload = {
22
+ calendarType: 'google' | 'outlook';
23
+ };
24
+ export type CustomerTermsAcceptedEventPayload = Record<string, never>;
25
+ export type UserActivatedEventPayload = {
26
+ solutionName: string;
27
+ };
28
+ type EventPayloadAdditions = {
29
+ bill_switch_failure: BillSwitchEventPayload;
30
+ bill_added: BillEventPayload;
31
+ bill_edited: BillEventPayload;
32
+ bill_marked_inactive: BillEventPayload;
33
+ bill_switch_platforms_added: BillSwitchPlatformsPayload;
34
+ bill_switch_platforms_removed: BillSwitchPlatformsPayload;
35
+ bill_cancel_success: BillSwitchEventPayload;
36
+ bill_cancel_failure: BillSwitchEventPayload;
37
+ calendar_sync: CalendarSyncEventPayload;
38
+ customer_terms_accepted: CustomerTermsAcceptedEventPayload;
39
+ user_activated: UserActivatedEventPayload;
40
+ };
41
+ type EventPayloadModifications = {
42
+ bill_removed: BillEventPayload;
43
+ bill_switch_success: BillSwitchEventPayload;
44
+ };
45
+ type EventPayloadRemovals = [];
46
+ export type EventPayloadMap = Omit<EventPayloadMapV3 & AdditionsType<EventPayloadAdditions> & ModificationsType<EventPayloadModifications>, keyof RemovalsType<EventPayloadRemovals>>;
47
+ export type EventHandler = <T extends keyof EventPayloadMap>(eventName: T, payload: EventPayloadMap[T]) => void;
@@ -0,0 +1,76 @@
1
+ /* eslint-disable camelcase */
2
+ /* eslint-disable @typescript-eslint/ban-types */
3
+ import type { AdditionsType, ModificationsType, RemovalsType } from '../utils'
4
+ import type {
5
+ BillSwitchPayload,
6
+ EventPayloadMap as EventPayloadMapV3,
7
+ } from './v3'
8
+
9
+ /*
10
+ * Export all the types from V4 and we override whatever changes
11
+ */
12
+ export * from './v3'
13
+
14
+ export type BillSwitchEventPayload = BillSwitchPayload & {
15
+ accountId?: string
16
+ }
17
+
18
+ export type BillEventPayload = {
19
+ platformId: string
20
+ platformName: string
21
+ frequency: string
22
+ nextPaymentDate: string
23
+ amountCents: number
24
+ }
25
+
26
+ export type BillSwitchPlatform = {
27
+ id: string
28
+ name: string
29
+ }
30
+
31
+ export type BillSwitchPlatformsPayload = {
32
+ platforms: BillSwitchPlatform[]
33
+ }
34
+
35
+ export type CalendarSyncEventPayload = {
36
+ calendarType: 'google' | 'outlook'
37
+ }
38
+
39
+ export type CustomerTermsAcceptedEventPayload = Record<string, never>
40
+
41
+ export type UserActivatedEventPayload = {
42
+ solutionName: string
43
+ }
44
+
45
+ type EventPayloadAdditions = {
46
+ bill_switch_failure: BillSwitchEventPayload
47
+ bill_added: BillEventPayload
48
+ bill_edited: BillEventPayload
49
+ bill_marked_inactive: BillEventPayload
50
+ bill_switch_platforms_added: BillSwitchPlatformsPayload
51
+ bill_switch_platforms_removed: BillSwitchPlatformsPayload
52
+ bill_cancel_success: BillSwitchEventPayload
53
+ bill_cancel_failure: BillSwitchEventPayload
54
+ calendar_sync: CalendarSyncEventPayload
55
+ customer_terms_accepted: CustomerTermsAcceptedEventPayload
56
+ user_activated: UserActivatedEventPayload
57
+ }
58
+
59
+ type EventPayloadModifications = {
60
+ bill_removed: BillEventPayload
61
+ bill_switch_success: BillSwitchEventPayload
62
+ }
63
+
64
+ type EventPayloadRemovals = []
65
+
66
+ export type EventPayloadMap = Omit<
67
+ EventPayloadMapV3 &
68
+ AdditionsType<EventPayloadAdditions> &
69
+ ModificationsType<EventPayloadModifications>,
70
+ keyof RemovalsType<EventPayloadRemovals>
71
+ >
72
+
73
+ export type EventHandler = <T extends keyof EventPayloadMap>(
74
+ eventName: T,
75
+ payload: EventPayloadMap[T]
76
+ ) => void