From 02f94ad5ce5d09e7c8fc7a673181b9db9b3ac165 Mon Sep 17 00:00:00 2001 From: INDRASEN Date: Mon, 24 Mar 2025 17:16:54 +0530 Subject: [PATCH 1/4] Release Version 11.7.0 --- CHANGELOG.md | 32 ++++++++ LICENSE | 2 +- README.md | 78 ++++++++++++------ composer.json | 2 +- .../Advanced/WebHookAPI.php | 80 +++++++++++++------ src/LoginRadiusSDK/Utility/Functions.php | 2 +- 6 files changed, 145 insertions(+), 51 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 876b572..eb8c485 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,37 @@ > **LoginRadius PHP SDK Change Log** provides information regarding what has changed, more specifically what changes, improvements and bug fix has been made to the SDK. For more details please refer to the [LoginRadius API Documention](https://www.loginradius.com/docs/api/v2/deployment/sdk-libraries/php-library/) +# Version 11.7.0 + +**Release Date:** March 24, 2025 + +## Enhancements + +We've introduced a brand-new set of Webhook APIs, designed with enhanced functionality and flexibility. These new APIs support advanced features including: + +- Custom header configuration +- Query parameter support +- Webhook authentication methods (Bearer Token and Basic Auth) +- Support for a custom `Name` parameter to label each webhook subscription + +As part of this upgrade, the legacy Webhook APIs have been deprecated in favor of the new, more robust versions. + +## Newly Added APIs + +- `getWebhookSubscriptionDetail` – Retrieve detailed information about a specific webhook subscription +- `createWebhookSubscription` – Create a new webhook subscription with advanced configuration options +- `deleteWebhookSubscription` – Remove an existing webhook subscription +- `updateWebhookSubscription` – Modify an existing webhook subscription +- `listAllWebhooks` – Retrieve a list of all configured webhook subscriptions +- `getWebhookEvents` – Fetch available webhook events supported by the system + +## Deprecated APIs + +The following legacy APIs have been deprecated: + +- `webHookUnsubscribe` +- `webhookTest` +- `webHookSubscribe` +- `getWebHookSubscribedURLs` # Version 11.6.0 diff --git a/LICENSE b/LICENSE index c3ac770..23a023a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2022 LoginRadius Inc. +Copyright (c) 2025 LoginRadius Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index a94d0af..8ebe7e5 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ curl -sS https://getcomposer.org/installer | php Next, run the Composer command to install the latest stable version of library: ``` -composer require loginradius/php-sdk:11.6.0 +composer require loginradius/php-sdk:11.7.0 ``` Include the following files in your Project Directory @@ -3904,10 +3904,16 @@ $result = $nativeSocialAPI->getAccessTokenByGoogleAuthCode($google_authcode,$soc ### WebHook API List of APIs in this Section:
-[POST : Webhook Subscribe](#WebHookSubscribe-post-)
-[GET : Webhook Subscribed URLs](#GetWebHookSubscribedURLs-get-)
-[GET : Webhook Test](#WebhookTest-get-)
-[DELETE : WebHook Unsubscribe](#WebHookUnsubscribe-delete-)
+ +### WebHook API + +List of APIs in this Section:
+[PUT : Update Webhook Subscription](#UpdateWebhookSubscription-put-)
+[POST : Create Webhook Subscription](#CreateWebhookSubscription-post-)
+[GET : Get Webhook Subscription Detail](#GetWebhookSubscriptionDetail-get-)
+[GET : List All Webhooks](#ListAllWebhooks-get-)
+[GET : Get Webhook Events](#GetWebhookEvents-get-)
+[DELETE : Delete Webhook Subscription](#DeleteWebhookSubscription-delete-)
If you have not already initialized the WebHook object do so now ```php @@ -3915,60 +3921,84 @@ $webHookAPI = new WebHookAPI(); ``` -
Webhook Subscribe (POST)
+
Update Webhook Subscription (PUT)
+ +This API is used to update a webhook subscription + [More Info](https://www.loginradius.com/docs/api/v2/integrations/webhooks/webhook-update) + + ```php + +$hookId = "hookId"; //Required + $payload = '{ }'; //Required + +$result = $webHookAPI->updateWebhookSubscription($hookId,$payload); + ``` + + +
Create Webhook Subscription (POST)
-API can be used to configure a WebHook on your LoginRadius site. Webhooks also work on subscribe and notification model, subscribe your hook and get a notification. Equivalent to RESThook but these provide security on basis of signature and RESThook work on unique URL. Following are the events that are allowed by LoginRadius to trigger a WebHook service call. +This API is used to create a new webhook subscription on your LoginRadius site. [More Info](https://www.loginradius.com/docs/api/v2/integrations/webhooks/webhook-subscribe) ```php $payload = '{ "event" : "", +"name" : "", "targetUrl" : "" }'; //Required -$result = $webHookAPI->webHookSubscribe($payload); +$result = $webHookAPI->createWebhookSubscription($payload); ``` -
Webhook Subscribed URLs (GET)
+
Get Webhook Subscription Detail (GET)
-This API is used to fatch all the subscribed URLs, for particular event +This API is used to get details of a webhook subscription by Id [More Info](https://www.loginradius.com/docs/api/v2/integrations/webhooks/webhook-subscribed-urls) ```php -$event = "event"; //Required +$hookId = "hookId"; //Required -$result = $webHookAPI->getWebHookSubscribedURLs($event); +$result = $webHookAPI->getWebhookSubscriptionDetail($hookId); ``` -
Webhook Test (GET)
+
List All Webhooks (GET)
-API can be used to test a subscribed WebHook. - [More Info](https://www.loginradius.com/docs/api/v2/integrations/webhooks/webhook-test) +This API is used to get the list of all the webhooks + [More Info](https://www.loginradius.com/docs/api/v2/integrations/webhooks/webhook-list) ```php -$result = $webHookAPI->webhookTest(); +$result = $webHookAPI->listAllWebhooks(); ``` -
WebHook Unsubscribe (DELETE)
+
Get Webhook Events (GET)
-API can be used to unsubscribe a WebHook configured on your LoginRadius site. - [More Info](https://www.loginradius.com/docs/api/v2/integrations/webhooks/webhook-unsubscribe) +This API is used to retrieve all the webhook events. + [More Info](https://www.loginradius.com/docs/api/v2/integrations/webhooks/webhook-events) ```php - $payload = '{ -"event" : "", -"targetUrl" : "" -}'; //Required -$result = $webHookAPI->webHookUnsubscribe($payload); +$result = $webHookAPI->getWebhookEvents(); + ``` + + +
Delete Webhook Subscription (DELETE)
+ +This API is used to delete webhook subscription + [More Info](https://www.loginradius.com/docs/api/v2/integrations/webhooks/webhook-unsubscribe) + + ```php + +$hookId = "hookId"; //Required + +$result = $webHookAPI->deleteWebhookSubscription($hookId); ``` diff --git a/composer.json b/composer.json index b6b9544..c18b0d1 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "loginradius/php-sdk", - "description": "LoginRadius PHP SDK v11.6.0", + "description": "LoginRadius PHP SDK v11.7.0", "keywords": ["loginradius", "phpsdk"], "type": "library", "license": "MIT", diff --git a/src/LoginRadiusSDK/CustomerRegistration/Advanced/WebHookAPI.php b/src/LoginRadiusSDK/CustomerRegistration/Advanced/WebHookAPI.php index 24734d3..ef1a4f2 100644 --- a/src/LoginRadiusSDK/CustomerRegistration/Advanced/WebHookAPI.php +++ b/src/LoginRadiusSDK/CustomerRegistration/Advanced/WebHookAPI.php @@ -23,37 +23,33 @@ public function __construct($options = []) /** - * This API is used to fatch all the subscribed URLs, for particular event - * @param event Allowed events: Login, Register, UpdateProfile, ResetPassword, ChangePassword, emailVerification, AddEmail, RemoveEmail, BlockAccount, DeleteAccount, SetUsername, AssignRoles, UnassignRoles, SetPassword, LinkAccount, UnlinkAccount, UpdatePhoneId, VerifyPhoneNumber, CreateCustomObject, UpdateCustomobject, DeleteCustomObject - * @return Response Containing List of Webhhook Data + * This API is used to get details of a webhook subscription by Id + * @param hookId Unique ID of the webhook + * @return Response containing Definition for Complete WebHook data * 40.1 */ - public function getWebHookSubscribedURLs($event) + public function getWebhookSubscriptionDetail($hookId) { - $resourcePath = "/api/v2/webhook"; + $resourcePath = "/v2/manage/webhooks/$hookId"; $queryParam = []; $queryParam['apikey'] = Functions::getApiKey(); $queryParam['apisecret'] = Functions::getApiSecret(); - if ($event === '' || ctype_space($event)) { - throw new LoginRadiusException(Functions::paramValidationMsg('event')); - } - $queryParam['event'] = $event; return Functions::_apiClientHandler('GET', $resourcePath, $queryParam); } /** - * API can be used to configure a WebHook on your LoginRadius site. Webhooks also work on subscribe and notification model, subscribe your hook and get a notification. Equivalent to RESThook but these provide security on basis of signature and RESThook work on unique URL. Following are the events that are allowed by LoginRadius to trigger a WebHook service call. + * This API is used to create a new webhook subscription on your LoginRadius site. * @param webHookSubscribeModel Model Class containing Definition of payload for Webhook Subscribe API - * @return Response containing Definition of Complete Validation data + * @return Response containing Definition for Complete WebHook data * 40.2 */ - public function webHookSubscribe($webHookSubscribeModel) + public function createWebhookSubscription($webHookSubscribeModel) { - $resourcePath = "/api/v2/webhook"; + $resourcePath = "/v2/manage/webhooks"; $queryParam = []; $queryParam['apikey'] = Functions::getApiKey(); $queryParam['apisecret'] = Functions::getApiSecret(); @@ -63,36 +59,72 @@ public function webHookSubscribe($webHookSubscribeModel) /** - * API can be used to test a subscribed WebHook. - * @return Response containing Definition of Complete Validation data + * This API is used to delete webhook subscription + * @param hookId Unique ID of the webhook + * @return Response containing Definition of Delete Request * 40.3 */ - public function webhookTest() + public function deleteWebhookSubscription($hookId) { - $resourcePath = "/api/v2/webhook/test"; + $resourcePath = "/v2/manage/webhooks/$hookId"; $queryParam = []; $queryParam['apikey'] = Functions::getApiKey(); $queryParam['apisecret'] = Functions::getApiSecret(); - return Functions::_apiClientHandler('GET', $resourcePath, $queryParam); + return Functions::_apiClientHandler('DELETE', $resourcePath, $queryParam); } /** - * API can be used to unsubscribe a WebHook configured on your LoginRadius site. - * @param webHookSubscribeModel Model Class containing Definition of payload for Webhook Subscribe API - * @return Response containing Definition of Delete Request + * This API is used to update a webhook subscription + * @param hookId Unique ID of the webhook + * @param webHookSubscriptionUpdateModel Model Class containing Definition for WebHookSubscriptionUpdateModel Property + * @return Response containing Definition for Complete WebHook data * 40.4 */ - public function webHookUnsubscribe($webHookSubscribeModel) + public function updateWebhookSubscription($hookId, $webHookSubscriptionUpdateModel) + { + $resourcePath = "/v2/manage/webhooks/$hookId"; + $queryParam = []; + $queryParam['apikey'] = Functions::getApiKey(); + $queryParam['apisecret'] = Functions::getApiSecret(); + return Functions::_apiClientHandler('PUT', $resourcePath, $queryParam, $webHookSubscriptionUpdateModel); + } + + + + /** + * This API is used to get the list of all the webhooks + * @return Response Containing List of Webhhook Data + * 40.5 + */ + + public function listAllWebhooks() { - $resourcePath = "/api/v2/webhook"; + $resourcePath = "/v2/manage/webhooks"; $queryParam = []; $queryParam['apikey'] = Functions::getApiKey(); $queryParam['apisecret'] = Functions::getApiSecret(); - return Functions::_apiClientHandler('DELETE', $resourcePath, $queryParam, $webHookSubscribeModel); + return Functions::_apiClientHandler('GET', $resourcePath, $queryParam); + } + + + + /** + * This API is used to retrieve all the webhook events. + * @return Model Class containing Definition for WebHookEventModel Property + * 40.6 + */ + + public function getWebhookEvents() + { + $resourcePath = "/v2/manage/webhooks/events"; + $queryParam = []; + $queryParam['apikey'] = Functions::getApiKey(); + $queryParam['apisecret'] = Functions::getApiSecret(); + return Functions::_apiClientHandler('GET', $resourcePath, $queryParam); } } \ No newline at end of file diff --git a/src/LoginRadiusSDK/Utility/Functions.php b/src/LoginRadiusSDK/Utility/Functions.php index ea1ab0e..1fc910c 100644 --- a/src/LoginRadiusSDK/Utility/Functions.php +++ b/src/LoginRadiusSDK/Utility/Functions.php @@ -22,7 +22,7 @@ class Functions { - const VERSION = '11.6.0'; + const VERSION = '11.7.0'; private static $_apikey; private static $_apisecret; From 38fabfa0fc503d5ed8565cc7afc3b428f25c2abf Mon Sep 17 00:00:00 2001 From: INDRASEN Date: Mon, 24 Mar 2025 17:40:10 +0530 Subject: [PATCH 2/4] Update README.md --- README.md | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8ebe7e5..427ac74 100644 --- a/README.md +++ b/README.md @@ -3929,7 +3929,21 @@ This API is used to update a webhook subscription ```php $hookId = "hookId"; //Required - $payload = '{ }'; //Required + $payload = '{ + "Headers": { + "x-test-header": "qa" + }, + "QueryParams": { + "apikey": "859faf40a7c54c209360b45376bf529f" + }, + "Authentication": { + "AuthType": "Basic", + "BasicAuth": { + "Username": "lrqaadmin", + "Password": "ZBz6JcnZadxc2gB7sf5vby87zBIu6q" + } + } +}'; //Required $result = $webHookAPI->updateWebhookSubscription($hookId,$payload); ``` @@ -3943,9 +3957,23 @@ This API is used to create a new webhook subscription on your LoginRadius site. ```php $payload = '{ -"event" : "", -"name" : "", -"targetUrl" : "" + "event" : "", + "name" : "", + "targetUrl" : "", + , + "Headers": { + "Custom-Header": "headerValue" + }, + "QueryParams": { + "apikey": "yourApiKey" + }, + "Authentication": { + "AuthType": "Basic", + "BasicAuth": { + "Username": "yourUsername", + "Password": "yourPassword" + } + } }'; //Required $result = $webHookAPI->createWebhookSubscription($payload); From e3645efa76b1a9f269e920097d17cbb76e8d441c Mon Sep 17 00:00:00 2001 From: INDRASEN Date: Mon, 24 Mar 2025 17:41:17 +0530 Subject: [PATCH 3/4] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 427ac74..93bcfb1 100644 --- a/README.md +++ b/README.md @@ -3960,7 +3960,6 @@ This API is used to create a new webhook subscription on your LoginRadius site. "event" : "", "name" : "", "targetUrl" : "", - , "Headers": { "Custom-Header": "headerValue" }, From c8ef81d1bbf038e613b23a47b03d459a3e6e86de Mon Sep 17 00:00:00 2001 From: INDRASEN Date: Mon, 24 Mar 2025 17:49:52 +0530 Subject: [PATCH 4/4] Update README.md --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 93bcfb1..5257c8d 100644 --- a/README.md +++ b/README.md @@ -3924,7 +3924,7 @@ $webHookAPI = new WebHookAPI();
Update Webhook Subscription (PUT)
This API is used to update a webhook subscription - [More Info](https://www.loginradius.com/docs/api/v2/integrations/webhooks/webhook-update) + [More Info](https://www.loginradius.com/docs/api/v2/integrations/webhooks/update-webhook-subscription/) ```php @@ -3952,7 +3952,7 @@ $result = $webHookAPI->updateWebhookSubscription($hookId,$payload);
Create Webhook Subscription (POST)
This API is used to create a new webhook subscription on your LoginRadius site. - [More Info](https://www.loginradius.com/docs/api/v2/integrations/webhooks/webhook-subscribe) + [More Info](https://www.loginradius.com/docs/api/v2/integrations/webhooks/create-webhook-subscription/) ```php @@ -3982,7 +3982,7 @@ $result = $webHookAPI->createWebhookSubscription($payload);
Get Webhook Subscription Detail (GET)
This API is used to get details of a webhook subscription by Id - [More Info](https://www.loginradius.com/docs/api/v2/integrations/webhooks/webhook-subscribed-urls) + [More Info](https://www.loginradius.com/docs/api/v2/integrations/webhooks/get-webhook-subscription-details/) ```php @@ -3995,7 +3995,7 @@ $result = $webHookAPI->getWebhookSubscriptionDetail($hookId);
List All Webhooks (GET)
This API is used to get the list of all the webhooks - [More Info](https://www.loginradius.com/docs/api/v2/integrations/webhooks/webhook-list) + [More Info](https://www.loginradius.com/docs/api/v2/integrations/webhooks/list-all-webhooks/) ```php @@ -4007,7 +4007,7 @@ $result = $webHookAPI->listAllWebhooks();
Get Webhook Events (GET)
This API is used to retrieve all the webhook events. - [More Info](https://www.loginradius.com/docs/api/v2/integrations/webhooks/webhook-events) + [More Info](https://www.loginradius.com/docs/api/v2/integrations/webhooks/get-webhook-events/) ```php @@ -4019,7 +4019,7 @@ $result = $webHookAPI->getWebhookEvents();
Delete Webhook Subscription (DELETE)
This API is used to delete webhook subscription - [More Info](https://www.loginradius.com/docs/api/v2/integrations/webhooks/webhook-unsubscribe) + [More Info](https://www.loginradius.com/docs/api/v2/integrations/webhooks/delete-webhook-subscription/) ```php