diff --git a/src/CloudApi/Client.php b/src/CloudApi/Client.php index 29ef5893..ff2fa9f1 100644 --- a/src/CloudApi/Client.php +++ b/src/CloudApi/Client.php @@ -19,6 +19,7 @@ use AcquiaCloudApi\Response\InvitationsResponse; use AcquiaCloudApi\Response\LogstreamResponse; use AcquiaCloudApi\Response\MembersResponse; +use AcquiaCloudApi\Response\NotificationResponse; use AcquiaCloudApi\Response\OperationResponse; use AcquiaCloudApi\Response\OrganizationsResponse; use AcquiaCloudApi\Response\PermissionsResponse; @@ -105,6 +106,22 @@ public function account() return new AccountResponse($this->connector->request('get', '/account', $this->query)); } + /** + * Returns details about your account. + * + * @return NotificationResponse + */ + public function notification($notificationUuid) + { + return new NotificationResponse( + $this->connector->request( + 'get', + "/notifications/${notificationUuid}", + $this->query + ) + ); + } + /** * Shows all applications. * diff --git a/src/CloudApi/ClientInterface.php b/src/CloudApi/ClientInterface.php index df91c6b0..b2a32a2f 100644 --- a/src/CloudApi/ClientInterface.php +++ b/src/CloudApi/ClientInterface.php @@ -18,6 +18,7 @@ use AcquiaCloudApi\Response\InvitationsResponse; use AcquiaCloudApi\Response\LogstreamResponse; use AcquiaCloudApi\Response\MembersResponse; +use AcquiaCloudApi\Response\NotificationResponse; use AcquiaCloudApi\Response\OperationResponse; use AcquiaCloudApi\Response\OrganizationsResponse; use AcquiaCloudApi\Response\PermissionsResponse; @@ -68,6 +69,15 @@ public function account(); */ public function applications(); + + /** + * Returns details about a notification. + * + * @param string $notificationUuid + * @return NotificationResponse + */ + public function notification($notificationUuid); + /** * Shows information about an application. * diff --git a/src/Response/NotificationResponse.php b/src/Response/NotificationResponse.php new file mode 100644 index 00000000..7c6d29f8 --- /dev/null +++ b/src/Response/NotificationResponse.php @@ -0,0 +1,40 @@ +uuid = $notification->uuid; + $this->event = $notification->event; + $this->label = $notification->label; + $this->description = $notification->description; + $this->created_at = $notification->created_at; + $this->completed_at = $notification->completed_at; + $this->status = $notification->status; + $this->progress = $notification->progress; + $this->context = $notification->context; + $this->links = $notification->_links; + } +} diff --git a/tests/Endpoints/NotificationTest.php b/tests/Endpoints/NotificationTest.php new file mode 100644 index 00000000..04e658dc --- /dev/null +++ b/tests/Endpoints/NotificationTest.php @@ -0,0 +1,35 @@ +getPsr7JsonResponseForFixture('Endpoints/getNotification.json'); + $client = $this->getMockClient($response); + + /** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ + $result = $client->notification('f4b37e3c-1g96-4ed4-ad20-3081fe0f9545'); + + $this->assertInstanceOf('\AcquiaCloudApi\Response\NotificationResponse', $result); + + foreach ($this->properties as $property) { + $this->assertObjectHasAttribute($property, $result); + } + } +} diff --git a/tests/Fixtures/Endpoints/getNotification.json b/tests/Fixtures/Endpoints/getNotification.json new file mode 100644 index 00000000..32138a59 --- /dev/null +++ b/tests/Fixtures/Endpoints/getNotification.json @@ -0,0 +1,69 @@ +{ + "uuid": "f4b37e3c-1g96-4ed4-ad20-3081fe0f9545", + "event": "DatabaseBackupCreated", + "label": "Database backup created", + "description": "A \"sample_db\" database backup has been created for \"Dev\".", + "created_at": "2019-09-23T15:59:39+00:00", + "completed_at": "2019-09-23T16:01:16+00:00", + "status": "completed", + "progress": 100, + "context": { + "database": { + "names": [ + "sample_db" + ] + }, + "environment": { + "ids": [ + "5333-3580d1ec-cf2b-1624-5d85-0d11ecd9a69a" + ] + }, + "application": { + "uuids": [ + "3580d1ec-cfgb-1624-5d85-0d28g2d9n69a" + ] + }, + "team": { + "uuids": [ + "3cb395d2-7cba-1fh4-b588-22000b04072f", + "a31ba519-4ec3-47c9-9dd1-b509g3fb618f" + ] + }, + "organization": { + "uuids": [ + "26416235-7cba-11e4-b567-200200b04072f" + ] + }, + "subscription": { + "uuids": [ + "863aa975-b9b9-4c55-9b1f-90e31293ad30" + ] + }, + "author": { + "uuid": "a58b046c-dd0c-102e-8305-1231f10f2cc1", + "actual_uuid": "a58b046c-dd0c-102e-8305-1231f10f2cc1" + }, + "user": { + "uuids": [ + "a58b046c-dd0c-102e-8305-1231f10f2cc1" + ] + } + }, + "_links": { + "self": { + "href": "https:\/\/cloud.acquia.com\/api\/notifications\/f4b37e3c-1g96-4ed4-ad20-3081fe0f9545" + } + }, + "_embedded": { + "author": { + "uuid": "a58b046c-dd0c-102e-8305-1231f10f2cc1", + "first_name": "Jane", + "last_name": "Doe", + "last_login_at": "2019-09-22T12:20:20+00:00", + "created_at": "2017-03-28T13:07:54-0500", + "email": "jane.doe@example.com", + "picture_url": "https:\/\/accounts.acquia.com\/images\/users\/a58b046c-dd0c-102e-8305-1231f10f2cc1\/style\/avatar", + "username": "jane.doe" + } + } +} \ No newline at end of file