_client_id = $client_id; } /** * Required to be able to send requests through API * * @param $manager Thrive_Dash_Api_CampaignMonitor * * @throws Exception */ public function set_manager( $manager ) { if ( false === $manager instanceof Thrive_Dash_Api_CampaignMonitor ) { throw new Exception( 'Invalid manager', 400 ); } $this->_manager = $manager; } /** * Sends the email through API Manager * * @param $message * * @return true * @throws Exception */ function send( $message ) { /** * merge some defaults data */ $message = array_merge( array( 'ConsentToTrack' => 'Yes', ), $message ); $data = array( 'body' => json_encode( $message ), ); $response = $this->_manager->request( 'transactional/classicEmail/send?clientId=' . $this->_client_id, 'post', $data ); if ( false === is_array( $response ) || false === isset( $response[0]['MessageID'] ) ) { throw new Exception( 'Mail not sent', 400 ); } return true; } }