1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

[SM-288] Rename requests and responses to follow naming convention (#3806)

This commit is contained in:
Oscar Hinton
2022-10-18 19:01:42 +02:00
committed by GitHub
parent c2df5c608e
commit cf2d3f5382
375 changed files with 868 additions and 1054 deletions

View File

@@ -0,0 +1,113 @@
import { NotificationType } from "../../enums/notificationType";
import { BaseResponse } from "./base.response";
export class NotificationResponse extends BaseResponse {
contextId: string;
type: NotificationType;
payload: any;
constructor(response: any) {
super(response);
this.contextId = this.getResponseProperty("ContextId");
this.type = this.getResponseProperty("Type");
const payload = this.getResponseProperty("Payload");
switch (this.type) {
case NotificationType.SyncCipherCreate:
case NotificationType.SyncCipherDelete:
case NotificationType.SyncCipherUpdate:
case NotificationType.SyncLoginDelete:
this.payload = new SyncCipherNotification(payload);
break;
case NotificationType.SyncFolderCreate:
case NotificationType.SyncFolderDelete:
case NotificationType.SyncFolderUpdate:
this.payload = new SyncFolderNotification(payload);
break;
case NotificationType.SyncVault:
case NotificationType.SyncCiphers:
case NotificationType.SyncOrgKeys:
case NotificationType.SyncSettings:
case NotificationType.LogOut:
this.payload = new UserNotification(payload);
break;
case NotificationType.SyncSendCreate:
case NotificationType.SyncSendUpdate:
case NotificationType.SyncSendDelete:
this.payload = new SyncSendNotification(payload);
break;
case NotificationType.AuthRequest:
case NotificationType.AuthRequestResponse:
this.payload = new AuthRequestPushNotification(payload);
break;
default:
break;
}
}
}
export class SyncCipherNotification extends BaseResponse {
id: string;
userId: string;
organizationId: string;
collectionIds: string[];
revisionDate: Date;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty("Id");
this.userId = this.getResponseProperty("UserId");
this.organizationId = this.getResponseProperty("OrganizationId");
this.collectionIds = this.getResponseProperty("CollectionIds");
this.revisionDate = new Date(this.getResponseProperty("RevisionDate"));
}
}
export class SyncFolderNotification extends BaseResponse {
id: string;
userId: string;
revisionDate: Date;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty("Id");
this.userId = this.getResponseProperty("UserId");
this.revisionDate = new Date(this.getResponseProperty("RevisionDate"));
}
}
export class UserNotification extends BaseResponse {
userId: string;
date: Date;
constructor(response: any) {
super(response);
this.userId = this.getResponseProperty("UserId");
this.date = new Date(this.getResponseProperty("Date"));
}
}
export class SyncSendNotification extends BaseResponse {
id: string;
userId: string;
revisionDate: Date;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty("Id");
this.userId = this.getResponseProperty("UserId");
this.revisionDate = new Date(this.getResponseProperty("RevisionDate"));
}
}
export class AuthRequestPushNotification extends BaseResponse {
id: string;
userId: string;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty("Id");
this.userId = this.getResponseProperty("UserId");
}
}