-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: support both snake_case and camelCase versions of impression data #227
Changes from 8 commits
6d5fb9e
b586071
ddc0ab6
e9dbca5
584b21c
cac078e
0218705
14741d9
c9568bc
7b58eb5
14dd119
07b6c4f
ce70ac4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,8 @@ | |
* value: string | ||
* } | ||
* }, | ||
* impression_data: bool | ||
* impression_data?: bool, | ||
* impressionData?: bool | ||
* } $response | ||
*/ | ||
public function __construct(array $response) | ||
|
@@ -37,12 +38,15 @@ | |
// tries to new this up manually and isn't interesting to tests | ||
|
||
// @codeCoverageIgnoreStart | ||
assert(isset($response['name'], $response['enabled'], $response['variant'], $response['impression_data'])); | ||
assert( | ||
isset($response['name'], $response['enabled'], $response['variant']) | ||
&& (isset($response['impressionData']) || isset($response['impression_data'])) | ||
); | ||
// @codeCoverageIgnoreEnd | ||
|
||
$this->name = $response['name']; | ||
$this->enabled = $response['enabled']; | ||
$this->impressionData = $response['impression_data']; | ||
$this->impressionData = $response['impressionData'] ?? $response['impression_data']; | ||
Check failure on line 49 in src/DTO/DefaultProxyFeature.php GitHub Actions / Static analysis (8.3)
|
||
|
||
$payload = null; | ||
|
||
|
@@ -88,6 +92,7 @@ | |
'enabled' => $this->enabled, | ||
'variant' => $this->variant, | ||
'impression_data' => $this->impressionData, | ||
'impressionData' => $this->impressionData, // maybe we don't need this | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm unsure what are we using this serialization for... maybe caching? |
||
]; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,16 +153,17 @@ | |
* value: string | ||
* } | ||
* }, | ||
* impression_data: bool | ||
* impression_data?: bool, | ||
* impressionData?: bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One will be set, the other won't, we don't know which one because it depends on the version of the backend |
||
* }|null | ||
*/ | ||
private function validateResponse(array $response): ?array | ||
{ | ||
if (!isset($response['name'], $response['enabled'], $response['variant'], $response['impression_data'])) { | ||
if (!isset($response['name'], $response['enabled'], $response['variant']) && !(isset($response['impressionData']) || isset($response['impression_data']))) { | ||
return null; | ||
} | ||
|
||
if (!is_string($response['name']) || !is_bool($response['enabled']) || !is_bool($response['impression_data']) || !is_array($response['variant'])) { | ||
if (!is_string($response['name']) || !is_bool($response['enabled']) || !is_bool($response['impressionData']) || !is_array($response['variant'])) { | ||
gastonfournier marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return null; | ||
} | ||
|
||
|
@@ -174,6 +175,6 @@ | |
return null; | ||
} | ||
|
||
return $response; | ||
Check failure on line 178 in src/Repository/DefaultUnleashProxyRepository.php GitHub Actions / Static analysis (8.3)
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One will be set, the other won't, we don't know which one because it depends on the version of the backend