-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #218 from Accommodatiehuur/master
TransactionTypeApiConnector
- Loading branch information
Showing
2 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
namespace PhpTwinfield\ApiConnectors; | ||
|
||
use PhpTwinfield\Services\FinderService; | ||
use PhpTwinfield\TransactionType; | ||
use PhpTwinfield\User; | ||
|
||
class TransactiontypeApiConnector extends BaseApiConnector | ||
{ | ||
const ACCESS_RULES_DISABLED = 0; | ||
const ACCESS_RULES_ENABLED = 1; | ||
|
||
const MUTUAL_OFFICES_DISABLED = 0; | ||
const MUTUAL_OFFICES_ENABLED = 1; | ||
|
||
/** | ||
* List all users. | ||
* | ||
* @param string|null $officeCode The office code, if only users from one office should be listed | ||
* @param integer|null $accessRules One of the self::ACCESS_RULES_* constants. | ||
* @param integer|null $mutualOffices One of the self::MUTUAL_OFFICES_* constants. | ||
* @param string $pattern The search pattern. May contain wildcards * and ? | ||
* @param int $field The search field determines which field or fields will be searched. The | ||
* available fields depends on the finder type. Passing a value outside the | ||
* specified values will cause an error. | ||
* @param int $firstRow First row to return, useful for paging | ||
* @param int $maxRows Maximum number of rows to return, useful for paging | ||
* @param array $options The Finder options. Passing an unsupported name or value causes an error. It's | ||
* possible to add multiple options. An option name may be used once, specifying | ||
* an option multiple times will cause an error. | ||
* | ||
* @return TransactionType[] | ||
*/ | ||
public function listAll( | ||
$officeCode = null, | ||
$accessRules = null, | ||
$mutualOffices = null, | ||
$pattern = '*', | ||
$field = 0, | ||
$firstRow = 1, | ||
$maxRows = 100, | ||
$options = array() | ||
): array { | ||
if (!is_null($officeCode)) { | ||
$options['office'] = $officeCode; | ||
} | ||
if (!is_null($accessRules)) { | ||
$options['accessRules'] = $accessRules; | ||
} | ||
if (!is_null($mutualOffices)) { | ||
$options['mutualOffices'] = $mutualOffices; | ||
} | ||
|
||
$response = $this->getFinderService()->searchFinder(FinderService::TYPE_TRANSACTION_TYPES, $pattern, $field, $firstRow, $maxRows, $options); | ||
|
||
if ($response->data->TotalRows == 0) { | ||
return []; | ||
} | ||
|
||
$transactionTypes = []; | ||
foreach ($response->data->Items->ArrayOfString as $transactionTypeArray) { | ||
$transactionType = new TransactionType(); | ||
$transactionType->setCode($transactionTypeArray->string[0]); | ||
$transactionType->setName($transactionTypeArray->string[1]); | ||
$transactionTypes[] = $transactionType; | ||
} | ||
|
||
return $transactionTypes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace PhpTwinfield; | ||
|
||
class TransactionType | ||
{ | ||
private $code; | ||
|
||
private $name; | ||
|
||
public function getCode(): string | ||
{ | ||
return $this->code; | ||
} | ||
|
||
public function setCode(string $code): void | ||
{ | ||
$this->code = $code; | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function setName(string $name): void | ||
{ | ||
$this->name = $name; | ||
} | ||
} |