File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -643,6 +643,29 @@ public function resendInvitation($invitationId)
643643 return Resource \Invitation::constructFromResponse ($ response );
644644 }
645645
646+ /**
647+ * Accept an Invitation
648+ *
649+ * @param string $invitationId ID of the Invitation
650+ * @return Resource\Invitation
651+ *
652+ * @throws Exception\WorkOSException
653+ */
654+ public function acceptInvitation ($ invitationId )
655+ {
656+ $ path = "user_management/invitations/ {$ invitationId }/accept " ;
657+
658+ $ response = Client::request (
659+ Client::METHOD_POST ,
660+ $ path ,
661+ null ,
662+ null ,
663+ true
664+ );
665+
666+ return Resource \Invitation::constructFromResponse ($ response );
667+ }
668+
646669 /**
647670 * Generates an OAuth 2.0 authorization URL used to initiate the SSO flow with WorkOS.
648671 *
Original file line number Diff line number Diff line change @@ -1678,6 +1678,50 @@ public function testResendInvitationAccepted()
16781678 $ this ->userManagement ->resendInvitation ($ invitationId );
16791679 }
16801680
1681+ public function testAcceptInvitation ()
1682+ {
1683+ $ invitationId = "invitation_01E4ZCR3C56J083X43JQXF3JK5 " ;
1684+ $ path = "user_management/invitations/ {$ invitationId }/accept " ;
1685+
1686+ $ result = $ this ->invitationResponseFixture ();
1687+
1688+ $ this ->mockRequest (
1689+ Client::METHOD_POST ,
1690+ $ path ,
1691+ null ,
1692+ null ,
1693+ true ,
1694+ $ result
1695+ );
1696+
1697+ $ response = $ this ->userManagement ->acceptInvitation ($ invitationId );
1698+
1699+ $ expected = $ this ->invitationFixture ();
1700+
1701+ $ this ->assertSame ($ response ->toArray (), $ expected );
1702+ }
1703+
1704+ public function testAcceptInvitation404 ()
1705+ {
1706+ $ invitationId = "invitation_01E4ZCR3C56J083X43JQXF3JK5 " ;
1707+ $ path = "user_management/invitations/ {$ invitationId }/accept " ;
1708+
1709+ $ this ->expectException (Exception \NotFoundException::class);
1710+
1711+ $ this ->mockRequest (
1712+ Client::METHOD_POST ,
1713+ $ path ,
1714+ null ,
1715+ null ,
1716+ true ,
1717+ null ,
1718+ null ,
1719+ 404
1720+ );
1721+
1722+ $ this ->userManagement ->acceptInvitation ($ invitationId );
1723+ }
1724+
16811725 public function testGetJwksUrl ()
16821726 {
16831727 $ clientId = "12345 " ;
You can’t perform that action at this time.
0 commit comments