pipedrive / client-php Goto Github PK
View Code? Open in Web Editor NEWPipedrive API client for PHP
License: MIT License
Pipedrive API client for PHP
License: MIT License
401 request is received.
Test issue to check if appropriate slack channel is notified
Hi guys,
Any plans to implement methods for Leads management via API?
Thanks,
Ros
Hello!
I am trying to connect my project to PipeDrive and decided to use this php client, but I have some issues.
"getDetailsOfADeal" doesn't return custom fields, direct API call response has them in "data", but when I use this client, $response ->data contains only default set of fields.
Checked all the documentation I could, but still cannot find the answer, is there any way to get deal custom field value via this client?
Array to string conversion {"exception":"[object] (ErrorException(code: 0): Array to string conversion at .../vendor/apimatic/jsonmapper/src/JsonMapper.php:204)
To replicate call;
->getProductFields()->getAllProductFields();
$client->getPersons()->updateAPerson([
'id' => 123,
'name' => 'John Doe',
]);
results in
Warning: array_values() expects parameter 1 to be array, null given
Exception trace:
at vendor/pipedrive/pipedrive/src/Controllers/PersonsController.php:445
(or line 446 for phone)
coming from this code:
$_parameters = array (
'name' => $this->val($options, 'name'),
'owner_id' => $this->val($options, 'ownerId'),
'org_id' => $this->val($options, 'orgId'),
'email' => array_values($this->val($options, 'email')),
'phone' => array_values($this->val($options, 'phone')),
'visible_to' => APIHelper::prepareFormFields($this->val($options, 'visibleTo'))
);
array_values()
is called with null if no email or phone is provided (which are optional)
Hey guys,
Starting on Monday 11 April, I have been getting a bunch of Error: OAuth 2 provider says client authentication failed.
errors.
Looking deeper, I can see that the $client->auth()->refreshToken();
isn't actually updating the refresh token.
Has anyone else run into this issue? Any idea how to fix?
Thanks!
If you want to Update a DEAL, instead of sending personId, stageId, userId you have to send person_id, stage_id, user_id
More information in official documentation:
https://developers.pipedrive.com/docs/api/v1/Deals#updateDeal
current version missing 'lead_id' => $this->val($options, 'leadId')
$_parameters = array (
'subject' => $this->val($options, 'subject'),
'type' => $this->val($options, 'type'),
'done' => APIHelper::prepareFormFields($this->val($options, 'done')),
'due_date' => DateTimeHelper::toSimpleDate($this->val($options, 'dueDate')),
'due_time' => $this->val($options, 'dueTime'),
'duration' => $this->val($options, 'duration'),
'user_id' => $this->val($options, 'userId'),
'deal_id' => $this->val($options, 'dealId'),
'person_id' => $this->val($options, 'personId'),
'participants' => $this->val($options, 'participants'),
'org_id' => $this->val($options, 'orgId'),
'note' => $this->val($options, 'note'),
'busy_flag' => $this->val($options, 'busyFlag')
);
i expected same with API documentation on pipedrive addActivity documentation
$_parameters = array (
'subject' => $this->val($options, 'subject'),
'type' => $this->val($options, 'type'),
'done' => APIHelper::prepareFormFields($this->val($options, 'done')),
'due_date' => DateTimeHelper::toSimpleDate($this->val($options, 'dueDate')),
'due_time' => $this->val($options, 'dueTime'),
'duration' => $this->val($options, 'duration'),
'user_id' => $this->val($options, 'userId'),
'deal_id' => $this->val($options, 'dealId'),
'lead_id'. => $this->val($options, 'leadId'), // ====> ADD LEAD ID HERE
'person_id' => $this->val($options, 'personId'),
'participants' => $this->val($options, 'participants'),
'org_id' => $this->val($options, 'orgId'),
'note' => $this->val($options, 'note'),
'busy_flag' => $this->val($options, 'busyFlag')
);
Hi,
I am just trying to update a person. It is working, except the custom fields of a person. Those are not handled by the PersonController. This seem to be a great bug in the code. When I add the following lines in the method PersonController::updateAPerson
in line 455 it seems to work:
foreach ($options as $key => $value) {
if (!in_array($key, ['id', 'name', 'owner_id', 'org_id', 'email', 'phone', 'visible_to'])) {
$_parameters[$key] = $value;
}
}
This is clearly a bug in this lib for me and makes the whole lib pointless/useless.
Specifying here and in other places return void response from the API call
produces IDE warnings.
Please replace void
with actual returned type or just with mixed
.
only this fields will be changed:
$_parameters = array (
'name' => $this->val($options, 'name'),
'owner_id' => $this->val($options, 'ownerId'),
'org_id' => $this->val($options, 'orgId'),
'email' => array_values($this->val($options, 'email')),
'phone' => array_values($this->val($options, 'phone')),
'visible_to' => APIHelper::prepareFormFields($this->val($options, 'visibleTo'))
);
ActivitiesController.php
addAnActivity():
$_parameters = array (
'subject' => $this->val($options, 'subject'),
'type' => $this->val($options, 'type'),
'done' => APIHelper::prepareFormFields($this->val($options, 'done')),
'due_date' => DateTimeHelper::toSimpleDate($this->val($options, 'dueDate')),
'due_time' => $this->val($options, 'dueTime'),
'duration' => $this->val($options, 'duration'),
'user_id' => $this->val($options, 'userId'),
'deal_id' => $this->val($options, 'dealId'),
'person_id' => $this->val($options, 'personId'),
'participants' => $this->val($options, 'participants'),
'org_id' => $this->val($options, 'orgId'),
'note' => $this->val($options, 'note')
);
busy_flag parameter is missing - it's in documentation: https://developers.pipedrive.com/docs/api/v1/Activities#addActivity
Fatal error: Uncaught InvalidArgumentException: Invalid value for enum '\Pipedrive\Model\FieldTypeAsString', must be one of: 'address', 'date', 'daterange', 'double', 'enum', 'monetary', 'org', 'people', 'phone', 'set', 'text', 'time', 'timerange', 'user', 'varchar', 'varchar_auto', 'visible_to' in /vendor/pipedrive/pipedrive/lib/ObjectSerializer.php:375
Retrieving indivudual fields via OrganizationFieldsApi->getOrganizationField($id) works fine
Hi
I'm trying to add a document to pipdrive but I have the following error: operation aborted by callback and i don't undestrand the error
My code
$pipeDrive = $this->client;
$files = $pipDrive->getFiles();
$collect['file'] = $pathfile ; // public/uploads/filename.pdf =>
$collect['personalId'] = 1;
$files->addFile($collect);
Thank's for help
In function docs there is: @param object $body (optional) TODO: type description here
but there should be array
.
Some controller functions use CamelCaseHelper::keysToCamelCase() on the function return value, and some don't. For example, in DealsController.php getDetailsOfADeal()
ends like this:
return $mapper->mapClass($response->body, 'Pipedrive\\Models\\GetDeal');
but, in OrganizationsController.php, listDealsAssociatedWithAnOrganization()
ends like this:
return CamelCaseHelper::keysToCamelCase($response->body);
This can play havoc in some situations.
This library looks out of date as it's using deprecated search functions like findPersonsByName
. Will it be updated with the ItemSearch
controller or should we move too interacting with the API directly?
Hi! It seams src/Models/MailThread.php
does not hold additionalData
even API endpoint returns it. As a result pagination feature is missing from the endpoint when using the client.
See an example of existed pagination: https://github.com/pipedrive/client-php/blob/master/src/Models/GetDeals.php#L69
I'm using the following code from the example. I'm running PHP 7.4.3 and get this error "Uncaught Error: Call to undefined method Pipedrive\Configuration::setApiKey()"
$ssdpath = get_stylesheet_directory();
use Pipedrive\Configuration;
require_once($ssdpath . '/vendor/autoload.php');
// Create a Configuration object and set the API key as an array
// Configure API key authorization: api_key
$config = (new Pipedrive\Configuration())->setApiKey('api_token', 'YOUR_API_KEY');
$apiInstance = new Pipedrive\Api\ActivitiesApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
try {
$result = $apiInstance->getActivities();
echo '<pre>';
print_r($result);
echo '</pre>';
} catch (Exception $e) {
echo 'Exception when calling ActivitiesApi->getActivities: ', $e->getMessage(), PHP_EOL;
}
If I use just this code, i do not get any error:
$ssdpath = get_stylesheet_directory();
use Pipedrive\Configuration;
require_once($ssdpath . '/vendor/autoload.php');
// Create a Configuration object and set the API key as an array
$config = new \Pipedrive\Configuration();
So it seems like for whatever reason the setApiKey method is not available?
I have tried uninstalling pipedrive with composer and then reinstalling, and get the same result.
If it's of any consequence, I am using composer via SSH on a wpengine server. Thanks
Exception:
production.ERROR: Incorrect format. {"userId":1,"email":"[email protected]","exception":"[object] (Exception(code: 0): Incorrect format. at /vendor/pipedrive/pipedrive/src/Utils/DateTimeHelper.php:73)
[stacktrace]
#0 [internal function]: Pipedrive\Utils\DateTimeHelper::fromSimpleDate('2020-03-30T13:3...')
#1 /vendor/apimatic/jsonmapper/src/JsonMapper.php(183): call_user_func('\\Pipedrive\\Util...', '2020-03-30T13:3...')
#2 /vendor/apimatic/jsonmapper/src/JsonMapper.php(523): apimatic\jsonmapper\JsonMapper->map(Object(stdClass), Object(Pipedrive\Models\Data29))
#3 /vendor/apimatic/jsonmapper/src/JsonMapper.php(247): apimatic\jsonmapper\JsonMapper->mapArray(Array, Array, '\\Pipedrive\\Mode...')
#4 /vendor/apimatic/jsonmapper/src/JsonMapper.php(319): apimatic\jsonmapper\JsonMapper->map(Object(stdClass), Object(Pipedrive\Models\WebhooksResponse))
#5 /vendor/pipedrive/pipedrive/src/Controllers/WebhooksController.php(97): apimatic\jsonmapper\JsonMapper->mapClass(Object(stdClass), 'Pipedrive\\Model...')
#6 /pipedriveplugin/Controllers/PluginController.php(45): Pipedrive\Controllers\WebhooksController->getAllWebhooks()
I think at /pipedrive/pipedrive/src/Models/Data29.php need to change:
$json['last_delivery_time'] = isset($this->lastDeliveryTime) ? DateTimeHelper::toSimpleDate($this->lastDeliveryTime) : null;
to
$json['last_delivery_time'] = isset($this->lastDeliveryTime) ? DateTimeHelper::toRfc3339DateTime($this->lastDeliveryTime) : null;
and
/**
* The last delivery time of the Webhook
* @maps last_delivery_time
* @factory \Pipedrive\Utils\DateTimeHelper::fromSimpleDate
* @var \DateTime|null $lastDeliveryTime public property
*/
public $lastDeliveryTime;
to
/**
* The last delivery time of the Webhook
* @maps last_delivery_time
* @factory \Pipedrive\Utils\DateTimeHelper::fromRfc3339DateTime
* @var \DateTime|null $lastDeliveryTime public property
*/
public $lastDeliveryTime;
Unnecessary use json mapper. It fails.
$mapper->mapClass($response->body, 'Pipedrive\\Models\\GetAllProductFieldsResponse')
Use this:
CamelCaseHelper::keysToCamelCase($response->body);
Hi guys,
Just wanted to know if the Call Logs endpoint is somewhere in the documentation or has it been missed?
https://developers.pipedrive.com/docs/api/v1/CallLogs
Hopefully this can be added soon.
/**
* Returns data about all person fields
*
* @return void response from the API call
* @throws APIException Thrown if API call fails
*/
public function getAllPersonFields()
{
//check or get oauth token
OAuthManager::getInstance()->checkAuthorization();
//prepare query string for API call
$_queryBuilder = '/personFields';
//validate and preprocess url
$_queryUrl = APIHelper::cleanUrl(Configuration::getBaseUri() . $_queryBuilder);
So, there is no way to add any query params and this only return first 100 results.
Stack trace:
PHP Fatal error: Uncaught InvalidArgumentException: Invalid value for enum '\Pipedrive\Model\FieldTypeAsString', must be one of: 'address', 'date', 'daterange', 'double', 'enum', 'monetary', 'org', '
people', 'phone', 'set', 'text', 'time', 'timerange', 'user', 'varchar', 'varchar_auto', 'visible_to' in ...\vendor\pipedrive\pipedrive\lib\ObjectSerializer.php:375
Stack trace:
#0 ...\vendor\pipedrive\pipedrive\lib\ObjectSerializer.php(400): Pipedrive\ObjectSerializer::deserialize('int', '\\Pipedrive\\Mode...', NULL)
#1 ...\vendor\pipedrive\pipedrive\lib\ObjectSerializer.php(287): Pipedrive\ObjectSerializer::deserialize(Object(stdClass), '\\Pipedrive\\Mode...', NULL)
#2 ...\vendor\pipedrive\pipedrive\lib\ObjectSerializer.php(400): Pipedrive\ObjectSerializer::deserialize(Array, '\\Pipedrive\\Mode...', NULL)
#3 ...\vendor\pipedrive\pipedrive\lib\Api\DealFieldsApi.php(1373): Pipedrive\ObjectSerializer::deserialize(Object(stdClass), '\\Pipedrive\\Mode...', Array)
#4 ...\vendor\pipedrive\pipedrive\lib\Api\DealFieldsApi.php(1314): Pipedrive\Api\DealFieldsApi->getDealFieldsWithHttpInfo(0, NULL)
Error:
array_values() expects parameter 1 to be array, null given
Method: Update A person
Input:
[
'id' => Int,
'custon_field_key' => Int
]
Using this package with PHP8.1 thows a lot of deprecation notices:
PHP Deprecated: Return type of Pipedrive\Models\PostNote::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/vendor/pipedrive/pipedrive/src/Models/PostNote.php on line 46
PHP Deprecated: Return type of Pipedrive\Models\BaseNote::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/vendor/pipedrive/pipedrive/src/Models/BaseNote.php on line 195
PHP Deprecated: Return type of Pipedrive\Models\Person::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/vendor/pipedrive/pipedrive/src/Models/Person.php on line 38
PHP Deprecated: Return type of Pipedrive\Models\NoteCreatorUser::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/vendor/pipedrive/pipedrive/src/Models/NoteCreatorUser.php on line 64
I have faced an issue that I get 401 response when sending PipelinesController::getOnePipeline
request with only pipeline ID as options. Then APIHelper::appendUrlWithQueryParameters
just adds a question mark to the query which screws up the things.
https://github.com/pipedrive/client-php/blob/master/docs/Api/DealsApi.md#adddeal
Note that you can supply additional custom fields ...
but there is no way to do it, isn't it?
I try run a example: updateTheProductAttachedToADeal
`
$id = 27;
$collect['id'] = $id;
$productAttachmentId = 27;
$collect['productAttachmentId'] = $productAttachmentId;
$productId = 2;
$collect['productId'] = $productId;
$itemPrice = 27.9633801840075;
$collect['itemPrice'] = $itemPrice;
$quantity = 27;
$collect['quantity'] = $quantity;
$discountPercentage = 27.9633801840075;
$collect['discountPercentage'] = $discountPercentage;
$duration = 27.9633801840075;
$collect['duration'] = $duration;
$productVariationId = 27;
$collect['productVariationId'] = $productVariationId;
$comments = 'comments';
$collect['comments'] = $comments;
$enabledFlag = int::ENUM_0;
$collect['enabledFlag'] = $enabledFlag;
$result = $deals->updateTheProductAttachedToADeal($collect);
`
Response
`
+body: {#1694
+"success": false
+"error": "body/product_id must be integer, body/item_price must be number, body/quantity must be number, body/discount_percentage must be number, body/product_variation_id must be integer, body/product_variation_id must be null, body/product_variation_id must match a schema in anyOf, body/duration must be number
`
Сustom fields are not returned when I use the getDeals()/getDeal()/getPersons()/getPerson() methods.
During debugging, I see custom fields in the response, but after deserialization, they don't get into the object.
In version 4, the fields are present.
Sometimes Pipedrive Api returns an empty body causing CamelCaseHelper
to fail because response is not iterable.
Sadly, we do not know how to reproduce this at the moment.
/var/www/vendor/pipedrive/pipedrive/src/Utils/CamelCaseHelper.php:27 Invalid argument supplied for foreach()
/var/www/vendor/pipedrive/pipedrive/src/Utils/CamelCaseHelper.php in _exception_handler() at line 27
/var/www/vendor/pipedrive/pipedrive/src/Controllers/PersonsController.php in Pipedrive\Utils\CamelCaseHelper::keysToCamelCase() at line 233
/var/www/application/logic/pipedrive.php in Pipedrive\Controllers\PersonsController->searchPersons() at line 433
Currently all the method of all controllers have the return type hinting set to void
.
This is wrong, as the real return type is \Pipedrive\Utils\JsonSerializer
.
Using void
breaks autocompletion in PHPStorm and breaks static code analyses.
EXPECTED BEHAVIOR
Return type hintings in Docblock comments should be \Pipedrive\Utils\JsonSerializer
.
Example
/**
* Returns all organizations
*
* @param array $options Array with all options for search
* @param integer $options['userId'] (optional) If supplied, only organizations owned by the given user will be
* returned.
* @param integer $options['filterId'] (optional) ID of the filter to use
* @param string $options['firstChar'] (optional) If supplied, only organizations whose name starts with the
* specified letter will be returned (case insensitive).
* @param integer $options['start'] (optional) Pagination start
* @param integer $options['limit'] (optional) Items shown per page
* @param string $options['sort'] (optional) Field names and sorting mode separated by a comma (field_name_1
* ASC, field_name_2 DESC). Only first-level field keys are supported (no
* nested keys).
- * @return void response from the API call
+ * @return \Pipedrive\Utils\JsonSerializer response from the API call
* @throws APIException Thrown if API call fails
*/
public function getAllOrganizations(
i use this "composer require pipedrive/pipedrive"
command and my Configuration.php loading incompletely
for example i didnt acces setApiKey() function.
Am I making a mistake while uploading?
(my Configuration.php row count 78 But there needs to be more rows)
Hey guys,
Please help me!
I give this error:
Unirest\Response {#1172 +code: 403 +raw_body: "{"success":false,"error":"Scope and URL mismatch","errorCode":403}" +body: {#1181 +"success": false +"error": "Scope and URL mismatch" +"errorCode": 403 } +headers: array:21 [ 0 => "HTTP/1.1 403 Forbidden" "Date" => "Thu, 02 Jul 2020 18:00:31 GMT" "Content-Type" => "application/json" "Transfer-Encoding" => "chunked" "Connection" => "keep-alive" "Set-Cookie" => "__cfduid=d76208080a8f8cda75657cdf957e5528c1593712830; expires=Sat, 01-Aug-20 18:00:30 GMT; path=/; domain=.pipedrive.com; HttpOnly; SameSite=Lax" "x-correlation-id" => "4fcd6f7f-3b89-4568-891f-6f45382685fa" "badi" => "Routing: us-east-1=>us-east-1; Version: c2a6; Host: bari;" "Cache-Control" => "no-cache" "Access-Control-Expose-Headers" => "X-RateLimit-Remaining, X-RateLimit-Limit, X-RateLimit-Reset" "pdtrusted-wgw-real-user-ip" => "18.230.84.218" "X-XSS-Protection" => "1; mode=block" "X-Content-Type-Options" => "nosniff" "Strict-Transport-Security" => "max-age=31536000; includeSubDomains" "Content-Encoding" => "gzip" "CF-Cache-Status" => "DYNAMIC" "cf-request-id" => "03b24901c90000d01cda0ac200000001" "Expect-CT" => "max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"" "Server" => "cloudflare" "CF-RAY" => "5aca44494bf9d01c-GRU" "alt-svc" => "h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400" ]}
But in my account, i have permission on Call Logs, when i create new App.
Why this error ?
The method of the authentication is: OAuth
Request:
Method: POST
URL: https://api.pipedrive.com/v1/callLogs/7441/recordings
Parameters: ^ array:11 [
"user_id" => "11419111"
"activity_id" => null
"subject" => "asdfasdfasdfasdfadsf"
"from_phone_number" => null
"to_phone_number" => "41992512151"
"outcome" => "connected"
"start_time" => "2020-07-02 19:33:40"
"end_time" => "2020-07-02 19:33:40"
"deal_id" => null
"person_id" => "9865"
"org_id" => null
]
json mapper in getAllDeals is not returning the custom fields
return CamelCaseHelper::keysToCamelCase($mapper->mapClass($response->body, 'Pipedrive\\Models\\GetDeals'));
Better use this
return CamelCaseHelper::keysToCamelCase($response->body);
A lot of times the return type of API calls are void when they are returning an array of data. Could you please update them to a correct value?
E.g.:
@return void response from the API call
To:
@return mixed response from the API call
Or:
@return array response from the API call
Thanks in advance.
I've just started a project using this library, and in general, it's done a good job, however, it seems a little out of date
https://developers.pipedrive.com/docs/api/v1
Published: 8 April 2020
On 31 March 2021 we will remove the following endpoints:
GET /deals/find
GET /organizations/find
GET /persons/find
GET /products/find
GET /searchResults
GET /searchResults/field
All of these endpoints are in the library, and more importantly perhaps, their replacements are not. Is there a plan to update this to support the new methods?
it is not possible to use "addAnActivity" on "activity" controller. Ther is undefined variable in use "$due_date" on line 229
All jsonSerialize
methods are without a return type, whereas interface signature JsonSerializable::jsonSerialize
has return type mixed
. This throws up warnings continually. One way or the other, they should be consistent with each other.
I get in response
{
"statusCode":415,
"code":"FST_ERR_CTP_INVALID_MEDIA_TYPE",
"error":"Unsupported Media Type",
"message":"Internal Server Error (2bac3f41-d80a-4377-b4f9-e55aecc19ba2)"
}
I don't see any controller related to leads. Could you let me know which is the controller for create/delete leads?
Return value of Pipedrive\Model\LeadResponse::jsonSerialize() must be an instance of Pipedrive\Model\mixed, instance of stdClass returned [/app/vendor/pipedrive/pipedrive/lib/Model/LeadResponse.php:793]
I get this error when trying to add a lead.
Hi everyone,
I'm running pipedrive/pipedrive:5@beta and when using the getDealFields function on DealFieldsApi, it fails with 'Class 'FieldTypeAsString' not found'. My code is added below.
Other endpoints like POST deals is working perfectly.
Who has an idea what goes wrong?
$apiKey = Environment::getEnv('PIPEDRIVE_API_KEY');
$companyDomain = Environment::getEnv('PIPEDRIVE_COMPANY_DOMAIN');
$host = str_replace('{{companyDomain}}', $companyDomain, 'https://{{companyDomain}}.pipedrive.com/v1');
$this->configuration = (new Pipedrive\Configuration())
->setApiKey('api_token', $apiKey)
->setHost($host);
$apiInstance = new Pipedrive\Api\DealFieldsApi(
new GuzzleHttp\Client(),
$this->configuration
);
try {
$result = $apiInstance->getDealFields(0, 10);
print_r($result);
} catch (\Exception $e) {
print_r('Exception when calling DealFieldsApi->getDealFields: ' . $e->getMessage());
}
Hi. I've tried running tests by README but it gives an error about missing api key. I guess it should work out of the box for tests run? 🤔
terminal: php71 vendor/bin/phpunit --verbose
PHPUnit 4.8.36 by Sebastian Bergmann and contributors.
Runtime: PHP 7.1.31 with Xdebug 2.7.2
Configuration: ~/pipedrive/pipedrive/phpunit.xml
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
Time: 354 ms, Memory: 8.00MB
There were 42 errors:
1) Pipedrive\Tests\ActivitiesControllerTest::testTestGetAllActivitiesAssignedToAParticularUser
Exception: Client is not authorized. An OAuth token or an API token is needed to make API calls.
~/pipedrive/pipedrive/src/OAuthManager.php:150
~/pipedrive/pipedrive/src/Controllers/ActivitiesController.php:128
~/pipedrive/pipedrive/tests/Controllers/ActivitiesControllerTest.php:64
2) Pipedrive\Tests\ActivityFieldsControllerTest::testTestGetAllFieldsForAnActivity
Exception: Client is not authorized. An OAuth token or an API token is needed to make API calls.
~/pipedrive/pipedrive/src/OAuthManager.php:150
~/pipedrive/pipedrive/src/Controllers/ActivityFieldsController.php:56
~/pipedrive/pipedrive/tests/Controllers/ActivityFieldsControllerTest.php:53
...
InvalidArgumentException
JsonMapper::map() requires first argument to be an object, array given.
in vendor/apimatic/jsonmapper/src/JsonMapper.php:103
It looks like the getDealsTimeline API response returns an object with the data member as an array for like this:
object(stdClass)#2247 (2) {
["success"]=>
bool(true)
["data"]=>
array(12) {
[0]=>
object(stdClass)#2244 (4) {
["period_start"]=>
string(19) "2021-08-01 00:00:00"
["period_end"]=>
string(19) "2021-08-31 23:59:59"
["deals"]=>
array(9) {
[0]=>
object(stdClass)#2246 (69) {
["id"]=>
int(1193)
["creator_user_id"]=>
int(149104)
["user_id"]=>
...
When jsonmapper tries to map this response in pipedrive/pipedrive/src/Controllers/DealsController.php:459
the data ends up being recognized as an object of type \Pipedrive\Models\Data25
rather than as an array. But in apimapper/jsonmapper/src/JsonMapper.php:103
an InvalidArgumentException is thrown because $json
that is passed in is an array rather than an object.
Ultimately, I think JsonMapper should be calling mapArray
or mapClassArray
around JsonMapper.php:247
but it is instead trying to call map
which only works with an object.
I wish I could have determined the root cause here to provide a merge request to fix this, but the best I could come up with is to skip using JsonMapper and to instead just return the object that comes back from the API. This looks like:
--- vendor/pipedrive/pipedrive/src/Controllers/DealsController.php.old
+++ vendor/pipedrive/pipedrive/src/Controllers/DealsController.php
@@ -454,7 +454,7 @@ class DealsController extends BaseContro
$mapper = $this->getJsonMapper();
- return $mapper->mapClass($response->body, 'Pipedrive\\Models\\GetDealsTimeline');
+ return $response->body;
}
That solution neglects whatever value JsonMapper has.
Thanks for your help troubleshooting and fixing this issue!
Hello,
Just noticed there's no reference to Leads in this client.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.