Changeset View
Changeset View
Standalone View
Standalone View
src/future/postmark/PhutilPostmarkFuture.php
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | if (!$this->future) { | ||||
if ($this->accessToken === null) { | if ($this->accessToken === null) { | ||||
throw new PhutilInvalidStateException('setAccessToken'); | throw new PhutilInvalidStateException('setAccessToken'); | ||||
} | } | ||||
if ($this->method === null || $this->parameters === null) { | if ($this->method === null || $this->parameters === null) { | ||||
throw new PhutilInvalidStateException('setMethod'); | throw new PhutilInvalidStateException('setMethod'); | ||||
} | } | ||||
$uri = id(new PhutilURI('https://api.postmarkapp.com/')) | $uri = (new PhutilURI('https://api.postmarkapp.com/')) | ||||
->setPath('/'.$this->method); | ->setPath('/'.$this->method); | ||||
$request_body = phutil_json_encode($this->parameters); | $request_body = phutil_json_encode($this->parameters); | ||||
$future = id(new HTTPSFuture($uri)) | $future = (new HTTPSFuture($uri)) | ||||
->setData($request_body) | ->setData($request_body) | ||||
->setMethod('POST') | ->setMethod('POST') | ||||
->addHeader('X-Postmark-Server-Token', $this->accessToken) | ->addHeader('X-Postmark-Server-Token', $this->accessToken) | ||||
->addHeader('Accept', 'application/json') | ->addHeader('Accept', 'application/json') | ||||
->addHeader('Content-Type', 'application/json'); | ->addHeader('Content-Type', 'application/json'); | ||||
$timeout = $this->getTimeout(); | $timeout = $this->getTimeout(); | ||||
if ($timeout) { | if ($timeout) { | ||||
Show All 37 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0