Skip to content

Commit

Permalink
update some tests with the new method names, although restapi_test sh…
Browse files Browse the repository at this point in the history
…ould be retired
  • Loading branch information
michield committed Nov 19, 2015
1 parent 3621bfa commit ff4e03a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 37 deletions.
39 changes: 15 additions & 24 deletions plugins/restapi_test/main.php
Expand Up @@ -289,50 +289,50 @@

?>

<h2>Step <?php echo $step++; ?> - Create a message</h2>
<h2>Step <?php echo $step++; ?> - Create a campaign</h2>
<?php

$result = $api->messageAdd('Test API from plugin', $admin_address, $admin_address, 'TEST API', 'TEST API', $template_id, date('Y-m-d H:i:s'));
$result = $api->campaignAdd('Test API from plugin', $admin_address, $admin_address, 'TEST API', 'TEST API', $template_id, date('Y-m-d H:i:s'));
if ($result->status != 'success') {
echo $result->data->message;

return;
}
$message_id = $result->data->id;
echo 'Message created (ID='.$message_id.').';
echo 'campaign created (ID='.$message_id.').';

?>

<h2>Step <?php echo $step++; ?> - Update message</h2>
<h2>Step <?php echo $step++; ?> - Update campaign</h2>
<?php

$result = $api->messageUpdate($message_id, 'Test API from plugin updated '.date('Y-m-d H:i:s'), $admin_address, $admin_address, 'TEST API', 'TEST API', $template_id, date('Y-m-d H:i:s'), 'submitted', $subscriber_id);
if ($result->status != 'success') {
echo $result->data->message;
//$result = $api->campaignUpdate($message_id, 'Test API from plugin updated '.date('Y-m-d H:i:s'), $admin_address, $admin_address, 'TEST API', 'TEST API', $template_id, date('Y-m-d H:i:s'), 'submitted', $subscriber_id);
//if ($result->status != 'success') {
//echo $result->data->message;

return;
}
echo 'Message updated and submitted (ID='.$result->data->id.').';
//return;
//}
//echo 'Campaign updated and submitted (ID='.$result->data->id.').';

?>

<h2>Step <?php echo $step++; ?> - Messages count</h2>
<h2>Step <?php echo $step++; ?> - Campaigns count</h2>
<?php

$result = $api->messagesGet();
$result = $api->campaignsGet();
if ($result->status != 'success') {
echo $result->data->message;

return;
}
echo 'Messages in phpList: '.count($result->data).'.';
echo 'Campaigns in phpList: '.count($result->data).'.';

?>

<h2>Step <?php echo $step++; ?> - Assign message to list</h2>
<h2>Step <?php echo $step++; ?> - Assign campaign to list</h2>
<?php

$result = $api->listMessageAdd($list_id, $message_id);
$result = $api->listCampaignAdd($list_id, $message_id);
if ($result->status != 'success') {
echo $result->data->message;

Expand All @@ -341,15 +341,6 @@
echo 'Message assigned to the created list.';
?>

<h2>Step <?php echo $step++; ?> - Process Queue</h2>
<?php

$result = $api->processQueue($login, $password, true);

sleep(5);

?>

<h2>Step <?php echo $step++; ?> - Unassign subscriber from list</h2>
<?php

Expand Down
26 changes: 13 additions & 13 deletions plugins/restapi_test/phplist_restapi_helper.php
Expand Up @@ -195,16 +195,16 @@ public function listSubscriberDelete($list_id, $subscriber_id)
return $result;
}

public function listMessageAdd($list_id, $message_id)
public function listCampaignAdd($list_id, $message_id)
{

//Post Data
$post_params = array(
'list_id' => $list_id,
'message_id' => $message_id,
'campaign_id' => $message_id,
);

$result = $this->callAPI('listMessageAdd', $post_params);
$result = $this->callAPI('listCampaignAdd', $post_params);

return $result;
}
Expand All @@ -215,10 +215,10 @@ public function listMessageDelete($list_id, $message_id)
//Post Data
$post_params = array(
'list_id' => $list_id,
'message_id' => $message_id,
'campaign_id' => $message_id,
);

$result = $this->callAPI('listMessageDelete', $post_params);
$result = $this->callAPI('listCampaignDelete', $post_params);

return $result;
}
Expand Down Expand Up @@ -403,32 +403,32 @@ public function templateDelete($id)
* Messages
************************************************************/

public function messageGet($id)
public function campaignGet($id)
{

//Post Data
$post_params = array(
'id' => $id,
);

$result = $this->callAPI('messageGet', $post_params);
$result = $this->callAPI('campaignGet', $post_params);

return $result;
}

public function messagesGet()
public function campaignsGet()
{

//Post Data
$post_params = array(
);

$result = $this->callAPI('messagesGet', $post_params);
$result = $this->callAPI('campaignsGet', $post_params);

return $result;
}

public function messageAdd($subject, $fromfield, $replyto, $message, $textmessage, $template, $embargo, $status = 'draft', $owner = 0, $sendformat = 'HTML', $footer = '', $rsstemplate = '')
public function campaignAdd($subject, $fromfield, $replyto, $message, $textmessage, $template, $embargo, $status = 'draft', $owner = 0, $sendformat = 'HTML', $footer = '', $rsstemplate = '')
{

//Post Data
Expand All @@ -447,12 +447,12 @@ public function messageAdd($subject, $fromfield, $replyto, $message, $textmessag
'owner' => $owner,
);

$result = $this->callAPI('messageAdd', $post_params);
$result = $this->callAPI('campaignAdd', $post_params);

return $result;
}

public function messageUpdate($id, $subject, $fromfield, $replyto, $message, $textmessage, $template, $embargo, $status = 'draft', $owner = 0, $sendformat = 'HTML', $footer = '', $rsstemplate = '')
public function campaignUpdate($id, $subject, $fromfield, $replyto, $message, $textmessage, $template, $embargo, $status = 'draft', $owner = 0, $sendformat = 'HTML', $footer = '', $rsstemplate = '')
{

//Post Data
Expand All @@ -472,7 +472,7 @@ public function messageUpdate($id, $subject, $fromfield, $replyto, $message, $te
'owner' => $owner,
);

$result = $this->callAPI('messageUpdate', $post_params);
$result = $this->callAPI('campaignUpdate', $post_params);

return $result;
}
Expand Down

0 comments on commit ff4e03a

Please sign in to comment.