@@ 83-101 (lines=19) @@ | ||
80 | * |
|
81 | * @return CreateResponse|array|ResponseInterface |
|
82 | */ |
|
83 | public function create($domain, $smtpPass, $spamAction, $wildcard) |
|
84 | { |
|
85 | Assert::stringNotEmpty($domain); |
|
86 | Assert::stringNotEmpty($smtpPass); |
|
87 | // TODO(sean.johnson): Extended spam filter input validation. |
|
88 | Assert::stringNotEmpty($spamAction); |
|
89 | Assert::boolean($wildcard); |
|
90 | ||
91 | $params = [ |
|
92 | 'name' => $domain, |
|
93 | 'smtp_password' => $smtpPass, |
|
94 | 'spam_action' => $spamAction, |
|
95 | 'wildcard' => $wildcard, |
|
96 | ]; |
|
97 | ||
98 | $response = $this->httpPost('/v3/domains', $params); |
|
99 | ||
100 | return $this->safeDeserialize($response, CreateResponse::class); |
|
101 | } |
|
102 | ||
103 | /** |
|
104 | * Removes a domain from the account. |
|
@@ 129-143 (lines=15) @@ | ||
126 | * |
|
127 | * @return CredentialResponse |
|
128 | */ |
|
129 | public function credentials($domain, $limit = 100, $skip = 0) |
|
130 | { |
|
131 | Assert::stringNotEmpty($domain); |
|
132 | Assert::integer($limit); |
|
133 | Assert::integer($skip); |
|
134 | ||
135 | $params = [ |
|
136 | 'limit' => $limit, |
|
137 | 'skip' => $skip, |
|
138 | ]; |
|
139 | ||
140 | $response = $this->httpGet(sprintf('/v3/domains/%s/credentials', $domain), $params); |
|
141 | ||
142 | return $this->safeDeserialize($response, CredentialResponse::class); |
|
143 | } |
|
144 | ||
145 | /** |
|
146 | * Create a new SMTP credential pair for the specified domain. |
|
@@ 154-169 (lines=16) @@ | ||
151 | * |
|
152 | * @return CreateCredentialResponse|array|ResponseInterface |
|
153 | */ |
|
154 | public function createCredential($domain, $login, $password) |
|
155 | { |
|
156 | Assert::stringNotEmpty($domain); |
|
157 | Assert::stringNotEmpty($login); |
|
158 | Assert::stringNotEmpty($password); |
|
159 | Assert::lengthBetween($password, 5, 32, 'SMTP password must be between 5 and 32 characters.'); |
|
160 | ||
161 | $params = [ |
|
162 | 'login' => $login, |
|
163 | 'password' => $password, |
|
164 | ]; |
|
165 | ||
166 | $response = $this->httpPost(sprintf('/v3/domains/%s/credentials', $domain), $params); |
|
167 | ||
168 | return $this->safeDeserialize($response, CreateCredentialResponse::class); |
|
169 | } |
|
170 | ||
171 | /** |
|
172 | * Update a set of SMTP credentials for the specified domain. |
|
@@ 180-194 (lines=15) @@ | ||
177 | * |
|
178 | * @return UpdateCredentialResponse|array|ResponseInterface |
|
179 | */ |
|
180 | public function updateCredential($domain, $login, $pass) |
|
181 | { |
|
182 | Assert::stringNotEmpty($domain); |
|
183 | Assert::stringNotEmpty($login); |
|
184 | Assert::stringNotEmpty($pass); |
|
185 | Assert::lengthBetween($pass, 5, 32, 'SMTP password must be between 5 and 32 characters.'); |
|
186 | ||
187 | $params = [ |
|
188 | 'password' => $pass, |
|
189 | ]; |
|
190 | ||
191 | $response = $this->httpPut(sprintf('/v3/domains/%s/credentials/%s', $domain, $login), $params); |
|
192 | ||
193 | return $this->safeDeserialize($response, UpdateCredentialResponse::class); |
|
194 | } |
|
195 | ||
196 | /** |
|
197 | * Remove a set of SMTP credentials from the specified domain. |
@@ 35-50 (lines=16) @@ | ||
32 | * |
|
33 | * @return IndexResponse |
|
34 | */ |
|
35 | public function index($limit = 100, $skip = 0) |
|
36 | { |
|
37 | Assert::integer($limit); |
|
38 | Assert::integer($skip); |
|
39 | Assert::greaterThan($limit, 0); |
|
40 | Assert::greaterThanEq($skip, 0); |
|
41 | ||
42 | $params = [ |
|
43 | 'limit' => $limit, |
|
44 | 'skip' => $skip, |
|
45 | ]; |
|
46 | ||
47 | $response = $this->httpGet('/v3/routes', $params); |
|
48 | ||
49 | return $this->safeDeserialize($response, IndexResponse::class); |
|
50 | } |
|
51 | ||
52 | /** |
|
53 | * Returns a single Route object based on its ID. |
|
@@ 78-95 (lines=18) @@ | ||
75 | * |
|
76 | * @return CreateResponse |
|
77 | */ |
|
78 | public function create($expression, array $actions, $description, $priority = 0) |
|
79 | { |
|
80 | Assert::string($expression); |
|
81 | Assert::isArray($actions); |
|
82 | Assert::string($description); |
|
83 | Assert::integer($priority); |
|
84 | ||
85 | $params = [ |
|
86 | 'priority' => $priority, |
|
87 | 'expression' => $expression, |
|
88 | 'action' => $actions, |
|
89 | 'description' => $description, |
|
90 | ]; |
|
91 | ||
92 | $response = $this->httpPost('/v3/routes', $params); |
|
93 | ||
94 | return $this->safeDeserialize($response, CreateResponse::class); |
|
95 | } |
|
96 | ||
97 | /** |
|
98 | * Updates a given Route by ID. All parameters are optional. |