mirror of
https://github.com/bitwarden/cli
synced 2025-12-16 16:23:30 +00:00
Simplify send templates (#237)
* Simplify Send templates * Fix internal template reference * No trailing whitespace
This commit is contained in:
@@ -36,6 +36,8 @@ import { Response } from 'jslib/cli/models/response';
|
|||||||
import { MessageResponse } from 'jslib/cli/models/response/messageResponse';
|
import { MessageResponse } from 'jslib/cli/models/response/messageResponse';
|
||||||
import { StringResponse } from 'jslib/cli/models/response/stringResponse';
|
import { StringResponse } from 'jslib/cli/models/response/stringResponse';
|
||||||
|
|
||||||
|
import { SendType } from 'jslib/enums/sendType';
|
||||||
|
|
||||||
import { CipherResponse } from '../models/response/cipherResponse';
|
import { CipherResponse } from '../models/response/cipherResponse';
|
||||||
import { CollectionResponse } from '../models/response/collectionResponse';
|
import { CollectionResponse } from '../models/response/collectionResponse';
|
||||||
import { FolderResponse } from '../models/response/folderResponse';
|
import { FolderResponse } from '../models/response/folderResponse';
|
||||||
@@ -430,14 +432,11 @@ export class GetCommand extends DownloadCommand {
|
|||||||
case 'org-collection':
|
case 'org-collection':
|
||||||
template = OrganizationCollectionRequest.template();
|
template = OrganizationCollectionRequest.template();
|
||||||
break;
|
break;
|
||||||
case 'send':
|
|
||||||
template = SendResponse.template();
|
|
||||||
break;
|
|
||||||
case 'send.text':
|
case 'send.text':
|
||||||
template = SendTextResponse.template();
|
template = SendResponse.template(SendType.Text);
|
||||||
break;
|
break;
|
||||||
case 'send.file':
|
case 'send.file':
|
||||||
template = SendFileResponse.template();
|
template = SendResponse.template(SendType.File);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return Response.badRequest('Unknown template object.');
|
return Response.badRequest('Unknown template object.');
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ const dateProperties: string[] = [Utils.nameOf<SendResponse>('deletionDate'), Ut
|
|||||||
|
|
||||||
export class SendResponse implements BaseResponse {
|
export class SendResponse implements BaseResponse {
|
||||||
|
|
||||||
static template(deleteInDays = 7): SendResponse {
|
static template(sendType?: SendType, deleteInDays = 7): SendResponse {
|
||||||
const req = new SendResponse();
|
const req = new SendResponse();
|
||||||
req.name = 'Send name';
|
req.name = 'Send name';
|
||||||
req.notes = 'Some notes about this send.';
|
req.notes = 'Some notes about this send.';
|
||||||
req.type = SendType.Text;
|
req.type = SendType.Text;
|
||||||
req.text = null;
|
req.text = sendType === SendType.Text ? SendTextResponse.template() : null;
|
||||||
req.file = null;
|
req.file = sendType === SendType.File ? SendFileResponse.template() : null;
|
||||||
req.maxAccessCount = null;
|
req.maxAccessCount = null;
|
||||||
req.deletionDate = this.getStandardDeletionDate(deleteInDays);
|
req.deletionDate = this.getStandardDeletionDate(deleteInDays);
|
||||||
req.expirationDate = null;
|
req.expirationDate = null;
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ export class SendProgram extends Program {
|
|||||||
sendText = SendTextResponse.template(data, options.hidden);
|
sendText = SendTextResponse.template(data, options.hidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
const template = Utils.assign(SendResponse.template(options.deleteInDays), {
|
const template = Utils.assign(SendResponse.template(null, options.deleteInDays), {
|
||||||
name: options.name ?? name,
|
name: options.name ?? name,
|
||||||
notes: options.notes,
|
notes: options.notes,
|
||||||
file: sendFile,
|
file: sendFile,
|
||||||
|
|||||||
Reference in New Issue
Block a user