public function testSendTest() { $response = self::$client->post('/'); $testSend = TestSend::create($response->json()); $this->assertInstanceOf('Ctct\\Components\\EmailMarketing\\TestSend', $testSend); $this->assertEquals("HTML", $testSend->format); $this->assertEquals("oh hai there", $testSend->personal_message); $this->assertEquals("*****@*****.**", $testSend->email_addresses[0]); }
/** * Send a test send of a campaign * @param string $accessToken - Constant Contact OAuth2 access token * @param int $campaignId - Id of campaign to send test of * @param TestSend $testSend - Test send details * @return TestSend * @throws CtctException */ public function sendTest($accessToken, $campaignId, TestSend $testSend) { $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_test_sends'), $campaignId); $request = parent::createBaseRequest($accessToken, 'POST', $baseUrl); $stream = Stream::factory(json_encode($testSend)); $request->setBody($stream); try { $response = parent::getClient()->send($request); } catch (ClientException $e) { throw parent::convertException($e); } return TestSend::create($response->json()); }
/** * Send a test send of a campaign * @param string $accessToken - Constant Contact OAuth2 access token * @param int $campaignId - Id of campaign to send test of * @param TestSend $test_send - Test send details * @return TestSend */ public function sendTest($accessToken, $campaignId, TestSend $test_send) { $baseUrl = Config::get('endpoints.base_url') . sprintf(Config::get('endpoints.campaign_test_sends'), $campaignId); $url = $this->buildUrl($baseUrl); $response = parent::getRestClient()->post($url, parent::getHeaders($accessToken), $test_send->toJson()); return TestSend::create(json_decode($response->body, true)); }