| @@ 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. |
|
| @@ 77-94 (lines=18) @@ | ||
| 74 | * |
|
| 75 | * @return CreateResponse |
|
| 76 | */ |
|
| 77 | public function create($expression, array $actions, $description, $priority = 0) |
|
| 78 | { |
|
| 79 | Assert::string($expression); |
|
| 80 | Assert::isArray($actions); |
|
| 81 | Assert::string($description); |
|
| 82 | Assert::integer($priority); |
|
| 83 | ||
| 84 | $params = [ |
|
| 85 | 'priority' => $priority, |
|
| 86 | 'expression' => $expression, |
|
| 87 | 'action' => $actions, |
|
| 88 | 'description' => $description, |
|
| 89 | ]; |
|
| 90 | ||
| 91 | $response = $this->httpPost('/v3/routes', $params); |
|
| 92 | ||
| 93 | return $this->safeDeserialize($response, CreateResponse::class); |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * Updates a given Route by ID. All parameters are optional. |
|
| @@ 34-49 (lines=16) @@ | ||
| 31 | * |
|
| 32 | * @return IndexResponse |
|
| 33 | */ |
|
| 34 | public function index($limit = 100, $skip = 0) |
|
| 35 | { |
|
| 36 | Assert::integer($limit); |
|
| 37 | Assert::integer($skip); |
|
| 38 | Assert::greaterThan($limit, 0); |
|
| 39 | Assert::greaterThanEq($skip, 0); |
|
| 40 | ||
| 41 | $params = [ |
|
| 42 | 'limit' => $limit, |
|
| 43 | 'skip' => $skip, |
|
| 44 | ]; |
|
| 45 | ||
| 46 | $response = $this->httpGet('/v3/routes', $params); |
|
| 47 | ||
| 48 | return $this->safeDeserialize($response, IndexResponse::class); |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * Returns a single Route object based on its ID. |
|