Skip to content

Commit 74690a7

Browse files
authored
Merge pull request #73 from pipedrive/GRAL-3076-get-all-person-fields-with-pagination
GRAL-3076 Added pagination support to getAllPersonFields
2 parents f68f905 + 9911657 commit 74690a7

File tree

5 files changed

+33
-7
lines changed

5 files changed

+33
-7
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4852,16 +4852,25 @@ $personFields->deleteMultiplePersonFieldsInBulk($ids);
48524852
```php
48534853
function getAllPersonFields()
48544854
```
4855+
#### Parameters
4856+
4857+
| Parameter | Tags | Description |
4858+
|-----------|------|-------------|
4859+
| start | ``` Optional ``` ``` DefaultValue ``` | Pagination start |
4860+
| limit | ``` Optional ``` | Items shown per page |
48554861

48564862
#### Example Usage
48574863

48584864
```php
4865+
$start = 0;
4866+
$collect['start'] = $start;
48594867

4860-
$personFields->getAllPersonFields();
4868+
$limit = 69;
4869+
$collect['limit'] = $limit;
48614870

4871+
$personFields->getAllPersonFields($collect);
48624872
```
48634873

4864-
48654874
### <a name="add_a_new_person_field"></a>![Method: ](https://apidocs.io/img/method.png ".PersonFieldsController.addANewPersonField") addANewPersonField
48664875

48674876
> Adds a new person field. For more information on adding a new custom field, see <a href="https://pipedrive.readme.io/docs/adding-a-new-custom-field" target="_blank" rel="noopener noreferrer">this tutorial</a>.

src/Controllers/BaseController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class BaseController
2424
* User-agent to be sent with API calls
2525
* @var string
2626
*/
27-
const USER_AGENT = 'Pipedrive-SDK-PHP-4.0.0';
27+
const USER_AGENT = 'Pipedrive-SDK-PHP-4.0.3';
2828

2929
/**
3030
* HttpCallBack instance associated with this controller

src/Controllers/PersonFieldsController.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,26 @@ public function deleteMultiplePersonFieldsInBulk(
100100
/**
101101
* Returns data about all person fields
102102
*
103+
* @param integer $options['limit'] (optional) For pagination, the limit of entries to be returned
104+
* @param integer $options['start'] (optional) For pagination, the position that represents the first result for the page
103105
* @return \Pipedrive\Utils\JsonSerializer response from the API call
104106
* @throws APIException Thrown if API call fails
105107
*/
106-
public function getAllPersonFields()
107-
{
108+
public function getAllPersonFields(
109+
$options = array()
110+
) {
108111
//check or get oauth token
109112
OAuthManager::getInstance()->checkAuthorization();
110113

111114
//prepare query string for API call
112115
$_queryBuilder = '/personFields';
113116

117+
//process optional query parameters
118+
APIHelper::appendUrlWithQueryParameters($_queryBuilder, array (
119+
'start' => $this->val($options, 'start', 0),
120+
'limit' => $this->val($options, 'limit'),
121+
));
122+
114123
//validate and preprocess url
115124
$_queryUrl = APIHelper::cleanUrl(Configuration::getBaseUri() . $_queryBuilder);
116125

src/Utils/CamelCaseHelper.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ class CamelCaseHelper
66
{
77
public static function keysToCamelCase($input)
88
{
9-
if ($input instanceof \DateTime) {
9+
if (is_null($input)) {
10+
return null;
11+
}
12+
13+
if ($input instanceof \DateTime || is_string($input)) {
1014
return $input;
1115
}
1216

tests/Controllers/PersonFieldsControllerTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,15 @@ protected function setUp()
4646
*/
4747
public function testTestGetAllPersonFields()
4848
{
49+
// Parameters for the API call
50+
$input = array();
51+
$input['start'] = 0;
52+
$input['limit'] = null;
4953

5054
// Set callback and perform API call
5155
self::$controller->setHttpCallBack($this->httpResponse);
5256
try {
53-
self::$controller->getAllPersonFields();
57+
self::$controller->getAllPersonFields($input);
5458
} catch (APIException $e) {
5559
}
5660

0 commit comments

Comments
 (0)