Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TransactionTypeApiConnector #218

Merged
merged 7 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}