-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPIResponseOfContact.php
More file actions
137 lines (117 loc) · 3.26 KB
/
APIResponseOfContact.php
File metadata and controls
137 lines (117 loc) · 3.26 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
declare(strict_types=1);
namespace SentDm\Contacts;
use SentDm\Core\Attributes\Optional;
use SentDm\Core\Concerns\SdkModel;
use SentDm\Core\Contracts\BaseModel;
use SentDm\Webhooks\APIMeta;
use SentDm\Webhooks\ErrorDetail;
/**
* Standard API response envelope for all v3 endpoints.
*
* @phpstan-import-type ContactResponseShape from \SentDm\Contacts\ContactResponse
* @phpstan-import-type ErrorDetailShape from \SentDm\Webhooks\ErrorDetail
* @phpstan-import-type APIMetaShape from \SentDm\Webhooks\APIMeta
*
* @phpstan-type APIResponseOfContactShape = array{
* data?: null|ContactResponse|ContactResponseShape,
* error?: null|ErrorDetail|ErrorDetailShape,
* meta?: null|APIMeta|APIMetaShape,
* success?: bool|null,
* }
*/
final class APIResponseOfContact implements BaseModel
{
/** @use SdkModel<APIResponseOfContactShape> */
use SdkModel;
/**
* Contact response for v3 API
* Uses snake_case for JSON property names.
*/
#[Optional(nullable: true)]
public ?ContactResponse $data;
/**
* Error information.
*/
#[Optional(nullable: true)]
public ?ErrorDetail $error;
/**
* Request and response metadata.
*/
#[Optional]
public ?APIMeta $meta;
/**
* Indicates whether the request was successful.
*/
#[Optional]
public ?bool $success;
public function __construct()
{
$this->initialize();
}
/**
* Construct an instance from the required parameters.
*
* You must use named parameters to construct any parameters with a default value.
*
* @param ContactResponse|ContactResponseShape|null $data
* @param ErrorDetail|ErrorDetailShape|null $error
* @param APIMeta|APIMetaShape|null $meta
*/
public static function with(
ContactResponse|array|null $data = null,
ErrorDetail|array|null $error = null,
APIMeta|array|null $meta = null,
?bool $success = null,
): self {
$self = new self;
null !== $data && $self['data'] = $data;
null !== $error && $self['error'] = $error;
null !== $meta && $self['meta'] = $meta;
null !== $success && $self['success'] = $success;
return $self;
}
/**
* Contact response for v3 API
* Uses snake_case for JSON property names.
*
* @param ContactResponse|ContactResponseShape|null $data
*/
public function withData(ContactResponse|array|null $data): self
{
$self = clone $this;
$self['data'] = $data;
return $self;
}
/**
* Error information.
*
* @param ErrorDetail|ErrorDetailShape|null $error
*/
public function withError(ErrorDetail|array|null $error): self
{
$self = clone $this;
$self['error'] = $error;
return $self;
}
/**
* Request and response metadata.
*
* @param APIMeta|APIMetaShape $meta
*/
public function withMeta(APIMeta|array $meta): self
{
$self = clone $this;
$self['meta'] = $meta;
return $self;
}
/**
* Indicates whether the request was successful.
*/
public function withSuccess(bool $success): self
{
$self = clone $this;
$self['success'] = $success;
return $self;
}
}