type = $type; $this->status = $status; $this->data = $data; $this->etag = $etag; $this->retry_after = $retry_after; $this->message = $message; $this->error_code = $error_code; $this->error_reason = $error_reason; } /** * The same result, marked with the state id of the connection whose key was sent. * * @param string $state_id State id. */ public function for_state( string $state_id ): self { $copy = clone $this; $copy->state_id = $state_id; return $copy; } /** * For a keyed call, the state id of the connection whose key was sent, else null. */ public function state_id(): ?string { return $this->state_id; } /** * Result type. */ public function type(): string { return $this->type; } /** * Whether the result has the given type. * * @param string $type One of the type constants. */ public function is( string $type ): bool { return $type === $this->type; } /** * HTTP status code, or 0 when no response arrived. */ public function status(): int { return $this->status; } /** * Decoded JSON body on success, else null. * * @return mixed */ public function data() { return $this->data; } /** * ETag from the response, if any. */ public function etag(): ?string { return $this->etag; } /** * Seconds to wait before retrying, for a rate-limited result. */ public function retry_after(): int { return $this->retry_after; } /** * Diagnostic message. Never contains a key. */ public function message(): string { return $this->message; } /** * The API's error code on an error response (for example `plan_upgrade_required`), or ''. */ public function error_code(): string { return $this->error_code; } /** * The API's reason for refusing a request (for example `mismatch`), or ''. */ public function error_reason(): string { return $this->error_reason; } }