File size: 1,660 Bytes
4327358
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { ApiProperty } from '@nestjs/swagger';
import { BooleanString } from '@waha/nestjs/validation/BooleanString';
import { PaginationParams } from '@waha/structures/pagination.dto';
import { ChatIdProperty } from '@waha/structures/properties.dto';
import { Transform } from 'class-transformer';
import { IsBoolean, IsEnum, IsOptional, IsString } from 'class-validator';

import { SessionBaseRequest, SessionQuery } from './base.dto';

/**
 * Queries
 */

export class ContactQuery extends SessionQuery {
  @ChatIdProperty()
  @IsString()
  contactId: string;
}

export class ContactProfilePictureQuery extends ContactQuery {
  @Transform(BooleanString)
  @IsBoolean()
  @IsOptional()
  @ApiProperty({
    example: false,
    required: false,
    description:
      'Refresh the picture from the server (24h cache by default). Do not refresh if not needed, you can get rate limit error',
  })
  refresh?: boolean = false;
}

enum ContactSortField {
  ID = 'id',
  NAME = 'name',
}

export class ContactsPaginationParams extends PaginationParams {
  @ApiProperty({
    description: 'Sort by field',
    enum: ContactSortField,
  })
  @IsOptional()
  @IsEnum(ContactSortField)
  sortBy?: string;
}

/**
 * Requests
 */

export class ContactRequest extends SessionBaseRequest {
  @ChatIdProperty()
  @IsString()
  contactId: string;
}

export class ContactUpdateBody {
  @ApiProperty({
    description: 'Contact First Name',
    example: 'John',
    required: true,
  })
  @IsString()
  firstName: string = 'John';

  @ApiProperty({
    description: 'Contact Last Name',
    example: 'Doe',
    required: true,
  })
  @IsString()
  lastName: string = 'Doe';
}