Falcon_Handler_Postmark::send_single PHP Метод

send_single() защищенный Метод

protected send_single ( $data )
    protected function send_single($data)
    {
        $headers = array('Accept' => 'application/json', 'Content-Type' => 'application/json', 'X-Postmark-Server-Token' => $this->api_key);
        $response = wp_remote_post('http://api.postmarkapp.com/email', array('headers' => $headers, 'body' => json_encode($data)));
        $code = wp_remote_retrieve_response_code($response);
        switch ($code) {
            case 200:
                break;
            case 401:
                throw new Exception(__('Invalid API key', 'falcon'), 401);
            case 422:
                throw new Exception(sprintf(__('Error with sent body: %s', 'falcon'), wp_remote_retrieve_body($response)), 422);
            case 500:
                throw new Exception(__('Postmark server error', 'falcon'), 500);
            default:
                throw new Exception(__('Unknown error', 'falcon'), $code);
        }
        $data = json_decode(wp_remote_retrieve_body($response));
        if (empty($data)) {
            throw new Exception(__('Invalid response from Postmark', 'falcon'));
        }
        return $data->MessageID;
    }