requestBuilder = $requestBuilder ?: new RequestBuilder(); $this->hydrator = $hydrator ?: new ModelHydrator(); $this->httpClient = $configurator->createConfiguredClient(); $this->apiKey = $configurator->getApiKey(); $this->responseHistory = $configurator->getResponseHistory(); } public static function create(string $apiKey, string $endpoint = 'https://api.mailgun.net'): self { $httpClientConfigurator = (new HttpClientConfigurator()) ->setApiKey($apiKey) ->setEndpoint($endpoint); return new self($httpClientConfigurator); } public function getLastResponse(): ?ResponseInterface { return $this->responseHistory->getLastResponse(); } public function attachment(): Api\Attachment { return new Api\Attachment($this->httpClient, $this->requestBuilder, $this->hydrator); } public function domains(): Api\Domain { return new Api\Domain($this->httpClient, $this->requestBuilder, $this->hydrator); } public function emailValidation(): Api\EmailValidation { return new Api\EmailValidation($this->httpClient, $this->requestBuilder, $this->hydrator); } public function events(): Api\Event { return new Api\Event($this->httpClient, $this->requestBuilder, $this->hydrator); } public function ips(): Api\Ip { return new Api\Ip($this->httpClient, $this->requestBuilder, $this->hydrator); } public function mailingList(): Api\MailingList { return new Api\MailingList($this->httpClient, $this->requestBuilder, $this->hydrator); } public function messages(): Api\Message { return new Api\Message($this->httpClient, $this->requestBuilder, $this->hydrator); } public function routes(): Api\Route { return new Api\Route($this->httpClient, $this->requestBuilder, $this->hydrator); } public function suppressions(): Api\Suppression { return new Api\Suppression($this->httpClient, $this->requestBuilder, $this->hydrator); } public function stats(): Api\Stats { return new Api\Stats($this->httpClient, $this->requestBuilder, $this->hydrator); } public function tags(): Api\Tag { return new Api\Tag($this->httpClient, $this->requestBuilder, $this->hydrator); } public function webhooks(): Api\Webhook { return new Api\Webhook($this->httpClient, $this->requestBuilder, $this->hydrator, $this->apiKey); } }