Skip to content

Commit

Permalink
feat(webhooks): webhook support, update getSettingsFile API
Browse files Browse the repository at this point in the history
  • Loading branch information
softvar committed Jan 12, 2021
1 parent 122e995 commit 215f65b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.10.0] - 2020-01-13

### Added
- Webhooks support. Updated `getSettingsFile` API to fetch latest settings-file when webhook is triggered.

## [1.8.0] - 2020-05-30
### Changed
- Refactor entire SDK - into modular and reusable components
Expand Down
4 changes: 4 additions & 0 deletions src/Constants/Urls.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class Urls
* query string to fetch settings
*/
const SETTINGS_URL = self::BASE_URL . 'settings';
/**
* query string to fetch settings once webhook is triggered
*/
const WEBHOOK_SETTINGS_URL = self::BASE_URL . 'pull';
/**
* query string to track goal
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/ImpressionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ImpressionBuilder
/**
* sdk version for api hit
*/
const SDK_VERSION = '1.8.0';
const SDK_VERSION = '1.10.0';
/**
* sdk langauge for api hit
*/
Expand Down
13 changes: 11 additions & 2 deletions src/VWO.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,25 @@ function __construct($config)
/**
* @param $accountId
* @param $sdkKey
* @param $isTriggeredByWebhook
* @return bool|mixed
*/
public static function getSettingsFile($accountId, $sdkKey)
public static function getSettingsFile($accountId, $sdkKey, $isTriggeredByWebhook = false)
{
self::$apiName = 'getSettingsFile';
LoggerService::setApiName(self::$apiName);
try {
$parameters = ImpressionBuilder::getSettingsFileQueryParams($accountId, $sdkKey);
$eventDispatcher = new EventDispatcher(false);
$response = $eventDispatcher->send(UrlConstants::SETTINGS_URL, $parameters);

$url = '';
if ($isTriggeredByWebhook) {
$url = UrlConstants::WEBHOOK_SETTINGS_URL;
} else {
$url = UrlConstants::SETTINGS_URL;
}

$response = $eventDispatcher->send($url, $parameters);

return $response;
} catch (Exception $e) {
Expand Down

0 comments on commit 215f65b

Please sign in to comment.