Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions cleverpush-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,33 @@ public static function send_notification($title, $body, $url, $options = array()
return CleverPush_Api::request('/notification/send', $params);
}

public static function delete_notification($notification_id)
{
$channel_id = get_option('cleverpush_channel_id');
$api_key_private = get_option('cleverpush_apikey_private');

if (empty($channel_id) || empty($notification_id) || empty($api_key_private)) {
return false;
}

$response = wp_remote_request(
CLEVERPUSH_API_ENDPOINT . '/channel/' . rawurlencode($channel_id) . '/notification/' . rawurlencode($notification_id),
array(
'method' => 'DELETE',
'timeout' => 20, // phpcs:ignore
'headers' => array(
'authorization' => $api_key_private
)
)
);

if (is_wp_error($response)) {
return false;
}

return wp_remote_retrieve_response_code($response) >= 200 && wp_remote_retrieve_response_code($response) < 300;
}

public static function update_channel($channel_id, $params = array())
{
if (empty($channel_id)) {
Expand Down
Loading
Loading