| @@ 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->deserializer->deserialize($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->deserializer->deserialize($response, UpdateCredentialResponse::class); |
|
| 194 | } |
|
| 195 | ||
| 196 | /** |
|
| 197 | * Remove a set of SMTP credentials from the specified domain. |
|
| @@ 59-73 (lines=15) @@ | ||
| 56 | * |
|
| 57 | * @return CreateResponse |
|
| 58 | */ |
|
| 59 | public function create($domain, $id, $url) |
|
| 60 | { |
|
| 61 | Assert::notEmpty($domain); |
|
| 62 | Assert::notEmpty($id); |
|
| 63 | Assert::notEmpty($url); |
|
| 64 | ||
| 65 | $params = [ |
|
| 66 | 'id' => $id, |
|
| 67 | 'url' => $url, |
|
| 68 | ]; |
|
| 69 | ||
| 70 | $response = $this->httpPost(sprintf('/v3/domains/%s/webhooks', $domain), $params); |
|
| 71 | ||
| 72 | return $this->deserializer->deserialize($response, CreateResponse::class); |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * @param string $domain |
|