Example #1
0
 /**
  * Creates a new domain for the account.
  * See below for spam filtering parameter information.
  * {@link https://documentation.mailgun.com/user_manual.html#um-spam-filter}.
  *
  * @param string $domain     Name of the domain.
  * @param string $smtpPass   Password for SMTP authentication.
  * @param string $spamAction `disable` or `tag` - inbound spam filtering.
  * @param bool   $wildcard   Domain will accept email for subdomains.
  *
  * @return CreateResponse|array|ResponseInterface
  */
 public function create($domain, $smtpPass, $spamAction, $wildcard)
 {
     Assert::stringNotEmpty($domain);
     Assert::stringNotEmpty($smtpPass);
     // TODO(sean.johnson): Extended spam filter input validation.
     Assert::stringNotEmpty($spamAction);
     Assert::boolean($wildcard);
     $params = ['name' => $domain, 'smtp_password' => $smtpPass, 'spam_action' => $spamAction, 'wildcard' => $wildcard];
     $response = $this->httpPost('/v3/domains', $params);
     return $this->safeDeserialize($response, CreateResponse::class);
 }
 /**
  * @param array $data
  *
  * @return self
  */
 public static function create(array $data)
 {
     Assert::keyExists($data, 'message');
     Assert::keyExists($data, 'skip_verification');
     Assert::keyExists($data, 'require_tls');
     $message = $data['message'];
     $noVerify = $data['skip_verification'];
     $requireTLS = $data['require_tls'];
     Assert::nullOrString($message);
     Assert::boolean($noVerify);
     Assert::boolean($requireTLS);
     return new self($message, $noVerify, $requireTLS);
 }