Skip to content

Commit

Permalink
Merge pull request #125 from fingerprintjs/bugfix/update-event
Browse files Browse the repository at this point in the history
Fix body in `updateEvent` method always being sent as empty json
  • Loading branch information
TheUnderScorer authored Oct 10, 2024
2 parents 839fa93 + acdc56e commit d179072
Show file tree
Hide file tree
Showing 96 changed files with 1,139 additions and 642 deletions.
5 changes: 5 additions & 0 deletions .changeset/nervous-sheep-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"fingerprint-pro-server-api-php-sdk": minor
---

Introduce `toPrettyString` in models that returns json encoded model in a pretty format
5 changes: 5 additions & 0 deletions .changeset/rude-llamas-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"fingerprint-pro-server-api-php-sdk": patch
---

Fix body in `updateEvent` method always being sent as empty json
10 changes: 8 additions & 2 deletions src/Api/FingerprintApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use Fingerprint\ServerAPI\ApiException;
use Fingerprint\ServerAPI\Configuration;
use Fingerprint\ServerAPI\Model\EventUpdateRequest;
use Fingerprint\ServerAPI\Model\ModelInterface;
use Fingerprint\ServerAPI\ObjectSerializer;
use Fingerprint\ServerAPI\SerializationException;
use GuzzleHttp\Client;
Expand Down Expand Up @@ -1052,10 +1053,15 @@ protected function updateEventRequest(EventUpdateRequest $body, string $request_
if (isset($body)) {
$_tempBody = $body;
}

// for model (json/xml)
if (isset($_tempBody)) {
// $_tempBody is the method argument, if present
$httpBody = json_encode($_tempBody);
if ($_tempBody instanceof ModelInterface) {
$httpBody = (string) $_tempBody;
} else {
// $_tempBody is the method argument, if present
$httpBody = json_encode($_tempBody);
}
}

// this endpoint requires API key authentication
Expand Down
19 changes: 12 additions & 7 deletions src/Model/ASN.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,6 @@ public function __construct(?array $data = null)
*/
public function __toString(): string
{
if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}

return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}

Expand Down Expand Up @@ -322,4 +315,16 @@ public function offsetUnset($offset): void
{
unset($this->container[$offset]);
}

/**
* Gets the string presentation of the object in a pretty JSON format.
*
*/
public function toPrettyString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
}
19 changes: 12 additions & 7 deletions src/Model/BotdDetectionResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,6 @@ public function __construct(?array $data = null)
*/
public function __toString(): string
{
if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}

return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}

Expand Down Expand Up @@ -326,4 +319,16 @@ public function offsetUnset($offset): void
{
unset($this->container[$offset]);
}

/**
* Gets the string presentation of the object in a pretty JSON format.
*
*/
public function toPrettyString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
}
19 changes: 12 additions & 7 deletions src/Model/BotdResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,6 @@ public function __construct(?array $data = null)
*/
public function __toString(): string
{
if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}

return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}

Expand Down Expand Up @@ -448,4 +441,16 @@ public function offsetUnset($offset): void
{
unset($this->container[$offset]);
}

/**
* Gets the string presentation of the object in a pretty JSON format.
*
*/
public function toPrettyString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
}
19 changes: 12 additions & 7 deletions src/Model/BrowserDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,6 @@ public function __construct(?array $data = null)
*/
public function __toString(): string
{
if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}

return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}

Expand Down Expand Up @@ -477,4 +470,16 @@ public function offsetUnset($offset): void
{
unset($this->container[$offset]);
}

/**
* Gets the string presentation of the object in a pretty JSON format.
*
*/
public function toPrettyString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
}
19 changes: 12 additions & 7 deletions src/Model/ClonedAppResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,6 @@ public function __construct(?array $data = null)
*/
public function __toString(): string
{
if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}

return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}

Expand Down Expand Up @@ -263,4 +256,16 @@ public function offsetUnset($offset): void
{
unset($this->container[$offset]);
}

/**
* Gets the string presentation of the object in a pretty JSON format.
*
*/
public function toPrettyString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
}
19 changes: 12 additions & 7 deletions src/Model/Common403ErrorResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,6 @@ public function __construct(?array $data = null)
*/
public function __toString(): string
{
if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}

return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}

Expand Down Expand Up @@ -332,4 +325,16 @@ public function offsetUnset($offset): void
{
unset($this->container[$offset]);
}

/**
* Gets the string presentation of the object in a pretty JSON format.
*
*/
public function toPrettyString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
}
19 changes: 12 additions & 7 deletions src/Model/Confidence.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,6 @@ public function __construct(?array $data = null)
*/
public function __toString(): string
{
if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}

return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}

Expand Down Expand Up @@ -291,4 +284,16 @@ public function offsetUnset($offset): void
{
unset($this->container[$offset]);
}

/**
* Gets the string presentation of the object in a pretty JSON format.
*
*/
public function toPrettyString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
}
19 changes: 12 additions & 7 deletions src/Model/DataCenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,6 @@ public function __construct(?array $data = null)
*/
public function __toString(): string
{
if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}

return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}

Expand Down Expand Up @@ -291,4 +284,16 @@ public function offsetUnset($offset): void
{
unset($this->container[$offset]);
}

/**
* Gets the string presentation of the object in a pretty JSON format.
*
*/
public function toPrettyString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
}
19 changes: 12 additions & 7 deletions src/Model/DeprecatedIPLocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,6 @@ public function __construct(?array $data = null)
*/
public function __toString(): string
{
if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}

return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}

Expand Down Expand Up @@ -489,4 +482,16 @@ public function offsetUnset($offset): void
{
unset($this->container[$offset]);
}

/**
* Gets the string presentation of the object in a pretty JSON format.
*
*/
public function toPrettyString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
}
19 changes: 12 additions & 7 deletions src/Model/DeprecatedIPLocationCity.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,6 @@ public function __construct(?array $data = null)
*/
public function __toString(): string
{
if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}

return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}

Expand Down Expand Up @@ -257,4 +250,16 @@ public function offsetUnset($offset): void
{
unset($this->container[$offset]);
}

/**
* Gets the string presentation of the object in a pretty JSON format.
*
*/
public function toPrettyString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
}
19 changes: 12 additions & 7 deletions src/Model/DeveloperToolsResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,6 @@ public function __construct(?array $data = null)
*/
public function __toString(): string
{
if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}

return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}

Expand Down Expand Up @@ -263,4 +256,16 @@ public function offsetUnset($offset): void
{
unset($this->container[$offset]);
}

/**
* Gets the string presentation of the object in a pretty JSON format.
*
*/
public function toPrettyString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
}
Loading

0 comments on commit d179072

Please sign in to comment.