Skip to content

Commit

Permalink
Merge pull request #16 from amirkhiz/phpdocs-completion
Browse files Browse the repository at this point in the history
PHPDocs & Reformation & Refactoring
  • Loading branch information
amirkhiz authored May 20, 2020
2 parents 7b8f916 + 2fec24f commit d586c5d
Show file tree
Hide file tree
Showing 9 changed files with 760 additions and 237 deletions.
116 changes: 38 additions & 78 deletions src/APIs/Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ class Actions
protected $api = 'actions';

/**
* @param array|null $eaqIds Array of Integers
* @param array|null $orderIds Array of Integers
* @param array|null $entityTypeIds Array of Integers
* @param array|null $actionStatus Array of Strings
* @param array|null $actionType Array of Strings
* @param int $noOfRecords
* @param int $pageNo
* @param array $eaqIds Array of Integers
* @param array $orderIds Array of Integers
* @param array $entityTypeIds Array of Integers
* @param array $actionStatus Array of Strings
* @param array $actionType Array of Strings
* @param int $noOfRecords
* @param int $pageNo
*
* @return Exception|array
* @throws Exception
* @link https://manage.logicboxes.com/kb/node/908
*/
public function current(
array $eaqIds = [],
Expand All @@ -39,77 +41,33 @@ public function current(
$noOfRecords = 10,
$pageNo = 1
) {
$dataToSend = $this->formatData(
$eaqIds,
$orderIds,
$entityTypeIds,
$actionStatus,
$actionType,
$noOfRecords,
$pageNo
$dataToSend = $this->fillParameters(
[
'no-of-records' => $noOfRecords,
'page-no' => $pageNo,
'eaq-id' => $eaqIds,
'order-id' => $orderIds,
'entity-type-id' => $entityTypeIds,
'action-status' => $actionStatus,
'action-type' => $actionType,
]
);

return $this->get('search-current', $dataToSend);
}

/**
* @param array $eaqIds
* @param array $orderIds
* @param array $entityTypeIds
* @param array $actionStatus
* @param array $actionType
* @param $noOfRecords
* @param $pageNo
*
* @return array
*/
private function formatData(
array $eaqIds,
array $orderIds,
array $entityTypeIds,
array $actionStatus,
array $actionType,
$noOfRecords,
$pageNo
) {
$dataToSend = [
'no-of-records' => $noOfRecords,
'page-no' => $pageNo,
];

if ( ! empty($eaqIds)) {
$dataToSend['eaq-id'] = $eaqIds;
}

if ( ! empty($orderIds)) {
$dataToSend['order-id'] = $orderIds;
}

if ( ! empty($entityTypeIds)) {
$dataToSend['entity-type-id'] = $entityTypeIds;
}

if ( ! empty($actionStatus)) {
$dataToSend['action-status'] = $actionStatus;
}

if ( ! empty($actionType)) {
$dataToSend['action-type'] = $actionType;
}

return $dataToSend;
}

/**
* @param array|null $eaqIds Array of Integers
* @param array|null $orderIds Array of Integers
* @param array|null $entityTypeIds Array of Integers
* @param array|null $actionStatus Array of Strings
* @param array|null $actionType Array of Strings
* @param int $noOfRecords
* @param int $pageNo
* @param array $eaqIds Array of Integers
* @param array $orderIds Array of Integers
* @param array $entityTypeIds Array of Integers
* @param array $actionStatus Array of Strings
* @param array $actionType Array of Strings
* @param int $noOfRecords
* @param int $pageNo
*
* @return Exception|array
* @throws Exception
* @link https://manage.logicboxes.com/kb/node/909
*/
public function archived(
array $eaqIds = [],
Expand All @@ -120,14 +78,16 @@ public function archived(
$noOfRecords = 10,
$pageNo = 1
) {
$dataToSend = $this->formatData(
$eaqIds,
$orderIds,
$entityTypeIds,
$actionStatus,
$actionType,
$noOfRecords,
$pageNo
$dataToSend = $this->fillParameters(
[
'no-of-records' => $noOfRecords,
'page-no' => $pageNo,
'eaq-id' => $eaqIds,
'order-id' => $orderIds,
'entity-type-id' => $entityTypeIds,
'action-status' => $actionStatus,
'action-type' => $actionType,
]
);

return $this->get('search-archived', $dataToSend);
Expand Down
92 changes: 32 additions & 60 deletions src/APIs/Billing.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace habil\ResellerClub\APIs;

use Exception;
use habil\ResellerClub\Helper;
use SimpleXMLElement;

/**
* Class Billing
Expand All @@ -24,14 +24,19 @@ class Billing
*
* @param int $customerId
*
* @return array
* @return array|Exception
* @throws Exception
* @link https://manage.logicboxes.com/kb/node/868
*/
public function customerTransactions($customerId)
{
return $this->get('customer-transactions', ['customer-id' => $customerId]);
return $this->get(
'customer-transactions',
['customer-id' => $customerId]
);
}

/**
/**
* @param int $records
* @param int $page
* @param array $customerId
Expand All @@ -47,7 +52,9 @@ public function customerTransactions($customerId)
* @param string $transactionDateEnd
* @param string $orderBy
*
* @return array
* @return array|Exception
* @throws Exception
* @link https://manage.logicboxes.com/kb/node/964
*/
public function search(
$records = 10,
Expand All @@ -65,60 +72,25 @@ public function search(
$transactionDateEnd = '',
$orderBy = ''
) {
$data = [
'no-of-records' => $records,
'page-no' => $page,
];

if ( ! empty($customerId)) {
$data['customer-id'] = $customerId;
}

if ( ! empty($username)) {
$data['username'] = $username;
}

if ( ! empty($transactionType)) {
$data['transaction-type'] = $transactionType;
}

if ( ! empty($transactionKey)) {
$data['transaction-key'] = $transactionKey;
}

if ( ! empty($transactionId)) {
$data['transaction-id'] = $transactionId;
}

if ( ! empty($transactionDescription)) {
$data['transaction-description'] = $transactionDescription;
}

if ( ! empty($balanceType)) {
$data['balance-type'] = $balanceType;
}

if ( ! empty($amtRangeStart)) {
$data['amt-range-start'] = $amtRangeStart;
}

if ( ! empty($amtRangeEnd)) {
$data['amt-range-end'] = $amtRangeEnd;
}

if ( ! empty($transactionDateStart)) {
$data['transaction-date-start'] = $transactionDateStart;
}

if ( ! empty($transactionDateEnd)) {
$data['transaction-date-end'] = $transactionDateEnd;
}

if ( ! empty($orderBy)) {
$data['order-by'] = $orderBy;
}

return $this->get('search', $data,'customer-transactions/');
$data = $this->fillParameters(
[
'no-of-records' => $records,
'page-no' => $page,
'customer-id' => $customerId,
'username' => $username,
'transaction-type' => $transactionType,
'transaction-key' => $transactionKey,
'transaction-id' => $transactionId,
'transaction-description' => $transactionDescription,
'balance-type' => $balanceType,
'amt-range-start' => $amtRangeStart,
'amt-range-end' => $amtRangeEnd,
'transaction-date-start' => $transactionDateStart,
'transaction-date-end' => $transactionDateEnd,
'order-by' => $orderBy,
]
);

return $this->get('search', $data, 'customer-transactions/');
}

}
Loading

0 comments on commit d586c5d

Please sign in to comment.