You've already forked grav-plugin-listmonk
Initial commit
This commit is contained in:
5
vendor/adnanhussainturki/listmonk-php/test/.credentials.example
vendored
Normal file
5
vendor/adnanhussainturki/listmonk-php/test/.credentials.example
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"serverUrl" : "",
|
||||
"username" : "",
|
||||
"password" : ""
|
||||
}
|
||||
20
vendor/adnanhussainturki/listmonk-php/test/init.php
vendored
Normal file
20
vendor/adnanhussainturki/listmonk-php/test/init.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// Read files from .credentials
|
||||
try {
|
||||
$credentials = json_decode(file_get_contents(__DIR__ . '/.credentials'), true);
|
||||
} catch (\Throwable $th) {
|
||||
echo "Error reading credentials file: " . $th->getMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Create a new ListMonk instance
|
||||
$listMonk = new \AdnanHussainTurki\ListMonk\ListMonk(
|
||||
$credentials['serverUrl'],
|
||||
$credentials['username'],
|
||||
$credentials['password']
|
||||
);
|
||||
|
||||
?>
|
||||
42
vendor/adnanhussainturki/listmonk-php/test/list.test.php
vendored
Normal file
42
vendor/adnanhussainturki/listmonk-php/test/list.test.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
// Get all lists
|
||||
$lists = $listMonk->lists()->getAll();
|
||||
echo "All lists:\n";
|
||||
foreach ($lists as $list) {
|
||||
echo $list->getId() . " - " . $list->getName() . "\n";
|
||||
}
|
||||
|
||||
// Get a list by id
|
||||
$list = $listMonk->lists()->get(3);
|
||||
echo "List with id 3:\n";
|
||||
echo $list->getId() . " - " . $list->getName() . "\n";
|
||||
|
||||
// Create a new list
|
||||
$newList = new \AdnanHussainTurki\ListMonk\Models\MonkList();
|
||||
$newList->setName("Test List");
|
||||
$newList->setType("private");
|
||||
$newList->setOptin("single");
|
||||
$newList->setTags(["test", "list"]);
|
||||
$newListMonk = $listMonk->lists()->create($newList);
|
||||
echo "New list created:\n";
|
||||
echo $newListMonk->getId(). " - " . $newListMonk->getName() . "\n";
|
||||
|
||||
|
||||
// Update the created list
|
||||
$newListMonk->setName("Test List Updated");
|
||||
$newListMonk->setType("public");
|
||||
$newListMonk->setOptin("double");
|
||||
$newListMonk->setTags(["test", "list", "updated"]);
|
||||
$updatedList = $listMonk->lists()->update($newListMonk);
|
||||
echo "Updated list:\n";
|
||||
echo $updatedList->getId(). " - " . $updatedList->getName() . "\n";
|
||||
|
||||
|
||||
// Delete the created list
|
||||
$deletedList = $listMonk->lists()->delete($updatedList->getId());
|
||||
echo "List deleted:\n";
|
||||
echo $deletedList->getId(). " - " . $deletedList->getName() . "\n";
|
||||
|
||||
41
vendor/adnanhussainturki/listmonk-php/test/subscriber.test.php
vendored
Normal file
41
vendor/adnanhussainturki/listmonk-php/test/subscriber.test.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/init.php';
|
||||
|
||||
// Get all subscribers
|
||||
$subscribers = $listMonk->subscribers()->getAll();
|
||||
echo "All subscribers:\n";
|
||||
foreach ($subscribers as $subscriber) {
|
||||
echo $subscriber->getId() . " - " . $subscriber->getName() . "\n";
|
||||
}
|
||||
|
||||
// Get a subscriber by id
|
||||
$subscriber = $listMonk->subscribers()->get(5);
|
||||
echo "Subscriber with id 1:\n";
|
||||
echo $subscriber->getId() . " - " . $subscriber->getName() . "\n";
|
||||
|
||||
// Create a new subscriber
|
||||
$newSubscriber = new \AdnanHussainTurki\ListMonk\Models\MonkSubscriber();
|
||||
$newSubscriber->setName("Test Subscriber");
|
||||
$newSubscriber->setEmail(random_int(23, 1000). "@gmail.com");
|
||||
$newSubscriber->setStatus("enabled");
|
||||
$newSubscriber->setLists([1, 2]);
|
||||
|
||||
$newSubscriberMonk = $listMonk->subscribers()->create($newSubscriber);
|
||||
echo "New subscriber created:\n";
|
||||
echo $newSubscriberMonk->getId(). " - " . $newSubscriberMonk->getName() . "\n";
|
||||
|
||||
// Update the created subscriber
|
||||
$newSubscriberMonk->setName("Test Subscriber Updated");
|
||||
$newSubscriberMonk->setEmail(random_int(23, 1000). "@email.com");
|
||||
$newSubscriberMonk->setStatus("disabled");
|
||||
$newSubscriberMonk->setLists([1, 2, 3]);
|
||||
$updatedSubscriber = $listMonk->subscribers()->update($newSubscriberMonk);
|
||||
echo "Updated subscriber:\n";
|
||||
echo $updatedSubscriber->getId(). " - " . $updatedSubscriber->getName() . "\n";
|
||||
|
||||
// Delete the created subscriber
|
||||
$deletedSubscriber = $listMonk->subscribers()->delete($updatedSubscriber->getId());
|
||||
echo "Subscriber deleted:\n";
|
||||
echo $deletedSubscriber->getId(). " - " . $deletedSubscriber->getName() . "\n";
|
||||
|
||||
Reference in New Issue
Block a user