Skip to content

Commit

Permalink
Added method to return all message ids after a BatchMessage operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Swientek committed Oct 12, 2013
1 parent 7323f28 commit 5d7daee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Mailgun/Messages/BatchMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,15 @@ public function sendMessage($message = array(), $files = array()){
$this->counters['recipients']['bcc'] = 0;
unset($this->message["to"]);
array_push($this->messageIds, $response->http_response_body->id);
return $this->messageIds;
}
}

public function finalize(){
return $this->sendMessage();
}

public function getMessageIds(){
return $this->messageIds;
}
}
?>
10 changes: 10 additions & 0 deletions tests/Mailgun/Tests/Messages/BatchMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ public function testDefaultIDInVariables() {
$propertyValue = $property->getValue($message);
$this->assertEquals(1, $propertyValue['test-user@samples.mailgun.org']['id']);
}
public function testgetMessageIds() {
$message = $this->client->BatchMessage($this->sampleDomain);
$message->addToRecipient("test-user@samples.mailgun.org", array("first" => "Test", "last" => "User"));
$message->setFromAddress("samples@mailgun.org", array("first" => "Test", "last" => "User"));
$message->setSubject("This is the subject of the message!");
$message->setTextBody("This is the text body of the message!");
$message->finalize();

$this->assertEquals(array("1234"), $message->getMessageIds());
}
}
?>

Expand Down

0 comments on commit 5d7daee

Please sign in to comment.