Skip to content

Commit 53495b2

Browse files
committed
add transfer subscription operation
1 parent 2253ba4 commit 53495b2

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

src/core/modelRepo/OperationModelStore.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { SetPropertyOperation } from '../operations/SetPropertyOperation';
1212
import { SetTagOperation } from '../operations/SetTagOperation';
1313
import { TrackSessionEndOperation } from '../operations/TrackSessionEndOperation';
1414
import { TrackSessionStartOperation } from '../operations/TrackSessionStartOperation';
15+
import { TransferSubscriptionOperation } from '../operations/TransferSubscriptionOperation';
1516
import { UpdateSubscriptionOperation } from '../operations/UpdateSubscriptionOperation';
1617
import { ModelStore } from './ModelStore';
1718

@@ -54,6 +55,9 @@ export class OperationModelStore extends ModelStore<Operation> {
5455
case OPERATION_NAME.DELETE_SUBSCRIPTION:
5556
operation = new DeleteSubscriptionOperation();
5657
break;
58+
case OPERATION_NAME.TRANSFER_SUBSCRIPTION:
59+
operation = new TransferSubscriptionOperation();
60+
break;
5761
case OPERATION_NAME.REFRESH_USER:
5862
operation = new RefreshUserOperation();
5963
break;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { OPERATION_NAME } from '../executors/constants';
2+
import { BaseSubscriptionOperation } from './BaseSubscriptionOperation';
3+
import { GroupComparisonType, GroupComparisonValue } from './Operation';
4+
5+
/**
6+
* An Operation to transfer a subscription to a new owner on the OneSignal backend.
7+
*/
8+
export class TransferSubscriptionOperation extends BaseSubscriptionOperation {
9+
constructor(appId?: string, onesignalId?: string, subscriptionId?: string) {
10+
super(OPERATION_NAME.TRANSFER_SUBSCRIPTION, appId, onesignalId);
11+
if (subscriptionId) {
12+
this.subscriptionId = subscriptionId;
13+
}
14+
}
15+
16+
override get groupComparisonType(): GroupComparisonValue {
17+
return GroupComparisonType.NONE;
18+
}
19+
20+
override get modifyComparisonKey(): string {
21+
return `${this.appId}.Subscription.${this.subscriptionId}.Transfer`;
22+
}
23+
}

0 commit comments

Comments
 (0)