It seems the problem is in a way how does getAllDeals() method transforms the API response. If I change the highlighted line to
return CamelCaseHelper::keysToCamelCase($response->body);
(borrowed that from getAllOrganizations()) I’m getting unfiltered response…
However, very strange to have such inconsistencies in similar controllers
I’m running into the same issue with DealsController::getDealsTimeline where $mapper->map removes custom fields. The proposed solution from petar above would work great for getDealsTimeline and other endpoints.
For now, I’ve had to write my own Guzzle HTTP requests to return the raw response. If you could fix this in the PHP package, it would be ver helpful!
unbelieveble, but this problem with PHP client is not solved after 3 years and many new versions of PHP client
But the difference with the actual client version is that I cannot borrow the solution from OrganizationsApi::getOrganization because it’s messed up there as well.
Please, give us the way to get values of deal custom fields using PHP client!
Still the same problem with PHP client…
This problem is not only relevant with deals but also with other models such as organizations.
We can’t get custom field values or can’t update custom field values on existing models.
Not sure if this will be ever fixed so I wrote a quick patch that allows me to get the custom field values from organizations and update them. Not the best solution but it works for my use case.
.../pipedrive/lib/Model/OrganizationItem.php | 10 ++++++++++
.../pipedrive/lib/Model/UpdateOrganization.php | 16 ++++++++++++++++
.../pipedrive/pipedrive/lib/ObjectSerializer.php | 14 ++++++++++++++
3 files changed, 40 insertions(+)
diff --git a/lib/Model/OrganizationItem.php b/lib/Model/OrganizationItem.php
index a48c3c1e7..9c574d7b6 100644
--- a/lib/Model/OrganizationItem.php
+++ b/lib/Model/OrganizationItem.php
@@ -48,6 +48,8 @@ class OrganizationItem implements ModelInterface, ArrayAccess, JsonSerializable
{
public const DISCRIMINATOR = null;
+ protected array $leftOvers = [];
+
/**
* The original name of the model.
*
@@ -487,6 +489,14 @@ public function __construct(array $data = null)
$this->container['next_activity'] = $data['next_activity'] ?? null;
}
+ public function setLeftOvers(array $leftOvers): void {
+ $this->leftOvers = $leftOvers;
+ }
+
+ public function getLeftOvers(): array {
+ return $this->leftOvers;
+ }
+
/**
* Show all the invalid properties with reasons.
*
diff --git a/lib/Model/UpdateOrganization.php b/lib/Model/UpdateOrganization.php
index 5be5d090e..5fd8af150 100644
--- a/lib/Model/UpdateOrganization.php
+++ b/lib/Model/UpdateOrganization.php
@@ -48,6 +48,8 @@ class UpdateOrganization implements ModelInterface, ArrayAccess, JsonSerializabl
{
public const DISCRIMINATOR = null;
+ protected array $custom = [];
+
/**
* The original name of the model.
*
@@ -242,6 +244,20 @@ public function valid(): bool
return count($this->listInvalidProperties()) === 0;
}
+ public function setCustom(array $custom): self
+ {
+ $this->custom = $custom;
+
+ return $this;
+ }
+
+ public function appendCustom(array $values): array {
+ foreach ($this->custom as $key => $value) {
+ $values[$key] = $value;
+ }
+
+ return $values;
+ }
/**
* Gets name
diff --git a/lib/ObjectSerializer.php b/lib/ObjectSerializer.php
index 05a11d9d2..b32f1a007 100644
--- a/lib/ObjectSerializer.php
+++ b/lib/ObjectSerializer.php
@@ -110,6 +110,11 @@ public static function sanitizeForSerialization($data, $type = null, string $for
}
}
}
+
+ if (method_exists($data, 'appendCustom')) {
+ $values = $data->appendCustom($values);
+ }
+
return (object)$values;
} else {
return (string)$data;
@@ -388,9 +393,13 @@ public static function deserialize($data, string $class, array $httpHeaders = nu
/** @var ModelInterface $instance */
$instance = new $class();
+ $leftovers = (array) $data;
+
foreach ($instance::openAPITypes() as $property => $type) {
$propertySetter = $instance::setters()[$property];
+ unset($leftovers[$property]);
+
if (!isset($propertySetter) || !isset($data->{$instance::attributeMap()[$property]})) {
continue;
}
@@ -400,6 +409,11 @@ public static function deserialize($data, string $class, array $httpHeaders = nu
$instance->$propertySetter(self::deserialize($propertyValue, $type, null));
}
}
+
+ if (method_exists($instance, 'setLeftOvers')) {
+ $instance->setLeftOvers($leftovers);
+ }
+
return $instance;
}
}
--
2.34.1