Skip to content

Commit

Permalink
add UserInfo Endpoint, count() method to return the count of all records
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Fairchild committed Mar 29, 2018
1 parent 5c31d2b commit f0167f2
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Infusionsoft/Api/Rest/RestModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,15 @@ public function first()

}

public function count()
{
$this->where('limit', 1);

$data = $this->client->restfulRequest('get', $this->getIndexUrl(), $this->where);

return $data['count'];
}

public function all()
{
$data = $this->client->restfulRequest('get', $this->getIndexUrl());
Expand Down
13 changes: 13 additions & 0 deletions src/Infusionsoft/Api/Rest/Traits/CannotList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php namespace Infusionsoft\Api\Rest\Traits;

use Infusionsoft\InfusionsoftException;

trait CannotList {

public function all() {
throw new InfusionsoftException(
__CLASS__.' cannot use '.__FUNCTION__.' function.'
);
}

}
25 changes: 25 additions & 0 deletions src/Infusionsoft/Api/Rest/UserInfoService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php namespace Infusionsoft\Api\Rest;

use Infusionsoft\Api\Rest\Traits\CannotCreate;
use Infusionsoft\Api\Rest\Traits\CannotDelete;
use Infusionsoft\Api\Rest\Traits\CannotFind;
use Infusionsoft\Api\Rest\Traits\CannotList;
use Infusionsoft\Api\Rest\Traits\CannotSave;
use Infusionsoft\Api\Rest\Traits\CannotSync;
use Infusionsoft\Api\Rest\Traits\CannotWhere;

class UserInfoService extends RestModel
{
use CannotList, CannotWhere, CannotSync, CannotSave, CannotFind, CannotDelete, CannotCreate;

public $full_url = 'https://api.infusionsoft.com/crm/rest/v1/oauth/connect/userinfo';

public function get()
{

$data = $this->client->restfulRequest('get', $this->getIndexUrl());

return $data;
}

}
5 changes: 5 additions & 0 deletions src/Infusionsoft/Infusionsoft.php
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,11 @@ public function campaigns()
return $this->getRestApi('CampaignService');
}

public function userinfo()
{
return $this->getRestApi('UserInfoService');
}

/**
* @return \Infusionsoft\Api\Rest\OpportunityService
*/
Expand Down

0 comments on commit f0167f2

Please sign in to comment.