From dbb00e534e6a6bdb4a982ae4d3d4df3ead2ca89d Mon Sep 17 00:00:00 2001 From: Jim Seconde Date: Wed, 20 Nov 2024 11:26:27 +0000 Subject: [PATCH] added method to delete member in conversations client --- src/Conversation/Client.php | 7 ++++++ test/Conversation/ClientTest.php | 23 +++++++++++++++++++ .../Fixtures/Responses/delete-member.json | 0 3 files changed, 30 insertions(+) create mode 100644 test/Conversation/Fixtures/Responses/delete-member.json diff --git a/src/Conversation/Client.php b/src/Conversation/Client.php index f7bac303..1d9e53ca 100644 --- a/src/Conversation/Client.php +++ b/src/Conversation/Client.php @@ -152,6 +152,13 @@ public function updateMember(UpdateMemberRequest $updateMemberRequest): Member return $member; } + public function deleteMember(string $memberId, string $conversationId): bool + { + $this->getApiResource()->delete($conversationId . '/members/' . $memberId); + + return true; + } + public function createEvent(EventRequest $event): Event { $response = $this->getAPIResource()->create($event->toArray(), '/' . $event->getConversationId() . '/events'); diff --git a/test/Conversation/ClientTest.php b/test/Conversation/ClientTest.php index efba9c78..9ec5f559 100644 --- a/test/Conversation/ClientTest.php +++ b/test/Conversation/ClientTest.php @@ -809,6 +809,29 @@ public function testWillUpdateMemberInConversation(): void $this->assertInstanceOf(Member::class, $response); } + public function testWillDeleteMemberInConversation(): void + { + $this->vonageClient->send(Argument::that(function (Request $request) use (&$requestIndex) { + $this->assertEquals('DELETE', $request->getMethod()); + + $uri = $request->getUri(); + $uriString = $uri->__toString(); + + $this->assertEquals( + 'https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/members/' . + 'MEM-63f61863-4a51-4f6b-86e1-46edebio0391', + $uriString + ); + + return true; + }))->willReturn($this->getResponse('delete-member', 204)); + + $this->conversationsClient->deleteMember( + 'MEM-63f61863-4a51-4f6b-86e1-46edebio0391', + 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a' + ); + } + public function testWillCreateEvent(): void { $messageText = new EventRequest( diff --git a/test/Conversation/Fixtures/Responses/delete-member.json b/test/Conversation/Fixtures/Responses/delete-member.json new file mode 100644 index 00000000..e69de29b