Skip to content

Commit

Permalink
Merge pull request #44 from owenvoke/feature/notifications
Browse files Browse the repository at this point in the history
feat: add support for Notifications
  • Loading branch information
freekmurze committed Sep 25, 2023
2 parents a9ef66e + e166b23 commit 62f48ca
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Actions/ManagesNotifications.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace OhDear\PhpSdk\Actions;

use OhDear\PhpSdk\Resources\NotificationDestination;

trait ManagesNotifications
{
/** @return array<int, NotificationDestination> */
public function teamNotificationDestinations(): array
{
return $this->transformCollection(
$this->get('team-notification-destinations')['data'],
NotificationDestination::class
);
}

/** @return array<int, NotificationDestination> */
public function siteNotificationDestinations(int $siteId): array
{
return $this->transformCollection(
$this->get("sites/{$siteId}/notification-destinations")['data'],
NotificationDestination::class
);
}
}
2 changes: 2 additions & 0 deletions src/OhDear.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use OhDear\PhpSdk\Actions\ManagesLighthouseReports;
use OhDear\PhpSdk\Actions\ManagesMaintenancePeriods;
use OhDear\PhpSdk\Actions\ManagesMixedContent;
use OhDear\PhpSdk\Actions\ManagesNotifications;
use OhDear\PhpSdk\Actions\ManagesPerformance;
use OhDear\PhpSdk\Actions\ManagesSites;
use OhDear\PhpSdk\Actions\ManagesStatusPages;
Expand All @@ -36,6 +37,7 @@ class OhDear
use ManagesLighthouseReports;
use ManagesMaintenancePeriods;
use ManagesMixedContent;
use ManagesNotifications;
use ManagesPerformance;
use ManagesSites;
use ManagesStatusPages;
Expand Down
18 changes: 18 additions & 0 deletions src/Resources/NotificationDestination.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace OhDear\PhpSdk\Resources;

class NotificationDestination extends ApiResource
{
public int $id;

public ?int $teamId = null;

public string $channel;

/** @var array<string, mixed> */
public array $destination;

/** @var array<int, string> */
public array $notificationTypes;
}

0 comments on commit 62f48ca

Please sign in to comment.