Skip to content

Commit

Permalink
Merge pull request #218 from Accommodatiehuur/master
Browse files Browse the repository at this point in the history
TransactionTypeApiConnector
  • Loading branch information
rojtjo authored Jan 18, 2023
2 parents 601657b + 4a4ec5e commit cc28417
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
71 changes: 71 additions & 0 deletions src/ApiConnectors/TransactiontypeApiConnector.php
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;
}
}
30 changes: 30 additions & 0 deletions src/TransactionType.php
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;
}
}

0 comments on commit cc28417

Please sign in to comment.