Skip to content

Object of class stdClass could not be converted to int #246

@Nightcro

Description

@Nightcro

Sometimes we get an error from php when it tries to deserialize the answer from the getDeals function

The first time we have to send a request to push something to pipedrive it fails with the error provided below on the getDeals function.
The second time it works perfectly with same data. We do not understand what is wrong with it.

public function getLatestDeal(int $organizationId = null, int $personId = null): ?DealItem
    {
        if (is_null($this->configV2)) {
            return null;
        }

        $instance = new DealsApiV2(config: $this->configV2);

        try {
            $deals = $instance->getDeals(person_id: $personId, org_id: $organizationId, sort_direction: "desc", limit: 1);
            if (!is_null($deals) && !is_null($deals->getData()) && count($deals->getData())) {
                return $deals->getData()[0];
            }
        } catch (APIExceptionV2|GuzzleException $e) {
            Log::error("Could not get deals for user {$this->user}! Error: {$e->getMessage()}");
        }

        return null;
    }

The organizationId or personId are provided by searching first through pipedrive with some filters. If it does not exist it will create those and return the respective ids. Sometimes it just searches for them but it does not create and the ids are null. So in either case if we provide the id or give null, we still get the same error, but on the second try it works perfectly.

We are using the latest version of the sdk 13.2.2 with php 8.2.3

ErrorException Object
(
[message:protected] => Object of class stdClass could not be converted to int
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => /var/www/html/vendor/pipedrive/pipedrive/lib/versions/v2/ObjectSerializer.php
[line:protected] => 368
[trace:Exception:private] => Array
(
[0] => Array
(
[file] => /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php
[line] => 255
[function] => handleError
[class] => Illuminate\Foundation\Bootstrap\HandleExceptions
[type] => ->
)
[1] => Array
(
[function] => Illuminate\Foundation\Bootstrap{closure}
[class] => Illuminate\Foundation\Bootstrap\HandleExceptions
[type] => ->
)
[2] => Array
(
[file] => /var/www/html/vendor/pipedrive/pipedrive/lib/versions/v2/ObjectSerializer.php
[line] => 368
[function] => settype
)
[3] => Array
(
[file] => /var/www/html/vendor/pipedrive/pipedrive/lib/versions/v2/ObjectSerializer.php
[line] => 400
[function] => deserialize
[class] => Pipedrive\versions\v2\ObjectSerializer
[type] => ::
)
[4] => Array
(
[file] => /var/www/html/vendor/pipedrive/pipedrive/lib/versions/v2/ObjectSerializer.php
[line] => 287
[function] => deserialize
[class] => Pipedrive\versions\v2\ObjectSerializer
[type] => ::
)
[5] => Array
(
[file] => /var/www/html/vendor/pipedrive/pipedrive/lib/versions/v2/ObjectSerializer.php
[line] => 400
[function] => deserialize
[class] => Pipedrive\versions\v2\ObjectSerializer
[type] => ::
)
[6] => Array
(
[file] => /var/www/html/vendor/pipedrive/pipedrive/lib/versions/v2/Api/DealsApi.php
[line] => 5362
[function] => deserialize
[class] => Pipedrive\versions\v2\ObjectSerializer
[type] => ::
)
[7] => Array
(
[file] => /var/www/html/vendor/pipedrive/pipedrive/lib/versions/v2/Api/DealsApi.php
[line] => 5289
[function] => getDealsWithHttpInfo
[class] => Pipedrive\versions\v2\Api\DealsApi
[type] => ->
)
[8] => Array
(
[file] => /var/www/html/app/Integrations/Pipedrive/Api.php
[line] => 268
[function] => getDeals
[class] => Pipedrive\versions\v2\Api\DealsApi
[type] => ->
)
[9] => Array
(
[file] => /var/www/html/app/Integrations/Pipedrive/PipedriveServiceProvider.php
[line] => 682
[function] => getLatestDeal
[class] => App\Integrations\Pipedrive\Api
[type] => ->
)
[10] => Array
(
[file] => /var/www/html/app/Integrations/Pipedrive/PipedriveServiceProvider.php
[line] => 440
[function] => getCreateDeal
[class] => App\Integrations\Pipedrive\PipedriveServiceProvider
[type] => ->
)
[11] => Array
(
[file] => /var/www/html/app/Integrations/Pipedrive/PipedriveServiceProvider.php
[line] => 413
[function] => sendPipedriveMessage
[class] => App\Integrations\Pipedrive\PipedriveServiceProvider
[type] => ->
)
[12] => Array
(
[file] => /var/www/html/app/Integrations/Pipedrive/PipedriveServiceProvider.php
[line] => 362
[function] => sendPipedrive
[class] => App\Integrations\Pipedrive\PipedriveServiceProvider
[type] => ->
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions