Skip to content

Commit

Permalink
Merge pull request #143 from CurrencyCloud/sdkphp-105
Browse files Browse the repository at this point in the history
Adds api_trading, online_trading and phone_trading parameters to Acco…
  • Loading branch information
jonathancouchman authored May 4, 2022
2 parents b78a42b + e6c82cb commit 2b39d26
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 9 deletions.
16 changes: 14 additions & 2 deletions src/EntryPoint/AccountsEntryPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,21 @@ public function convertAccountToRequest(Account $account, $convertForSearch = fa
return $common;
}
$isTermsAndConditionsAccepted = $account->isTermsAndConditionsAccepted();
$isApiTrading = $account->isApiTrading();
$isOnlineTrading = $account->isOnlineTrading();
$isPhoneTrading = $account->isPhoneTrading();
return $common + [
'spread_table' => $account->getSpreadTable(),
'identification_type' => $account->getIdentificationType(),
'identification_value' => $account->getIdentificationValue(),
'terms_and_conditions_accepted' => (null === $isTermsAndConditionsAccepted) ? null :
($isTermsAndConditionsAccepted ? 'true' : 'false')
($isTermsAndConditionsAccepted ? 'true' : 'false'),
'api_trading' => (null === $isApiTrading) ? null :
($isApiTrading ? 'true' : 'false'),
'online_trading' => (null === $isOnlineTrading) ? null :
($isOnlineTrading ? 'true' : 'false'),
'phone_trading' => (null === $isPhoneTrading) ? null :
($isPhoneTrading ? 'true' : 'false')
];
}

Expand Down Expand Up @@ -146,7 +155,10 @@ public function createAccountFromResponse(stdClass $response)
->setIdentificationType($response->identification_type)
->setIdentificationValue($response->identification_value)
->setShortReference($response->short_reference)
->setTermsAndConditionsAccepted($response->terms_and_conditions_accepted);
->setTermsAndConditionsAccepted($response->terms_and_conditions_accepted)
->setApiTrading($response->api_trading)
->setOnlineTrading($response->online_trading)
->setPhoneTrading($response->phone_trading);

$this->setIdProperty($account, $response->id);
return $account;
Expand Down
70 changes: 70 additions & 0 deletions src/Model/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ class Account implements EntityInterface
* @var bool
*/
private $termsAndConditionsAccepted;
/**
* @var bool
*/
private $apiTrading;
/**
* @var bool
*/
private $onlineTrading;
/**
* @var bool
*/
private $phoneTrading;


/**
* @param string $accountName
Expand Down Expand Up @@ -423,5 +436,62 @@ public function setTermsAndConditionsAccepted($termsAndConditionsAccepted)
return $this;
}

/**
* @return bool
*/
public function isApiTRading()
{
return $this->apiTrading;
}

/**
* @param bool $apiTrading
*
* @return $this
*/
public function setApiTrading($apiTrading)
{
$this->apiTrading = (null === $apiTrading) ? null : (bool)$apiTrading;
return $this;
}

/**
* @return bool
*/
public function isOnlineTRading()
{
return $this->onlineTrading;
}

/**
* @param bool $apiTrading
*
* @return $onlineTrading
*/
public function setOnlineTrading($onlineTrading)
{
$this->onlineTrading = (null === $onlineTrading) ? null : (bool)$onlineTrading;
return $this;
}

/**
* @return bool
*/
public function isPhoneTrading()
{
return $this->phoneTrading;
}

/**
* @param bool $phoneTrading
*
* @return $this
*/
public function setPhoneTrading($phoneTrading)
{
$this->phoneTrading = (null === $phoneTrading) ? null : (bool)$phoneTrading;
return $this;
}


}
33 changes: 27 additions & 6 deletions tests/EntryPoint/AccountsEntryPointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ class AccountsEntryPointTest extends BaseCurrencyCloudTestCase
'identification_type' => 'green_card',
'identification_value' => '123',
'short_reference' => '110104-00004',
'terms_and_conditions_accepted' => null
'terms_and_conditions_accepted' => null,
'api_trading' => 'true',
'online_trading' => 'true',
'phone_trading' => 'true'
];

protected $in = [
Expand All @@ -48,7 +51,10 @@ class AccountsEntryPointTest extends BaseCurrencyCloudTestCase
'identification_type' => null,
'identification_value' => null,
'on_behalf_of' => null,
'terms_and_conditions_accepted' => null
'terms_and_conditions_accepted' => null,
'api_trading' => null,
'online_trading' => null,
'phone_trading' => null
];

/**
Expand Down Expand Up @@ -92,7 +98,10 @@ public function allFieldsCanBeSet()
'identification_type' => 'L',
'identification_value' => 'M',
'on_behalf_of' => null,
'terms_and_conditions_accepted' => 'false'
'terms_and_conditions_accepted' => 'false',
'api_trading' => 'true',
'online_trading' => 'true',
'phone_trading' => 'false'
];

$entryPoint = new AccountsEntryPoint(
Expand All @@ -119,7 +128,10 @@ public function allFieldsCanBeSet()
->setIdentificationType('L')
->setIdentificationValue('M')
->setShortReference('N')
->setTermsAndConditionsAccepted(false);
->setTermsAndConditionsAccepted(false)
->setApiTrading(true)
->setOnlineTrading(true)
->setPhoneTrading(false);

$account = $entryPoint->create($account);

Expand Down Expand Up @@ -168,6 +180,9 @@ public function accountsCanBeFound()
unset($in['identification_value']);
unset($in['on_behalf_of']);
unset($in['terms_and_conditions_accepted']);
unset($in['api_trading']);
unset($in['online_trading']);
unset($in['phone_trading']);
$entryPoint = new AccountsEntryPoint(
new SimpleEntityManager(), $this->getMockedClient(
json_decode(
Expand Down Expand Up @@ -374,7 +389,10 @@ private function testTermsAndConditionsAccepted($isTermsAndConditionsAccepted) {
'identification_value' => 'M',
'on_behalf_of' => null,
'terms_and_conditions_accepted' => (null === $isTermsAndConditionsAccepted) ? null :
($isTermsAndConditionsAccepted ? 'true' : 'false')
($isTermsAndConditionsAccepted ? 'true' : 'false'),
'api_trading' => 'true',
'online_trading' => 'true',
'phone_trading' => 'true'
];

$entryPoint = new AccountsEntryPoint(
Expand All @@ -401,7 +419,10 @@ private function testTermsAndConditionsAccepted($isTermsAndConditionsAccepted) {
->setIdentificationType('L')
->setIdentificationValue('M')
->setShortReference('N')
->setTermsAndConditionsAccepted($isTermsAndConditionsAccepted);
->setTermsAndConditionsAccepted($isTermsAndConditionsAccepted)
->setApiTrading(true)
->setOnlineTrading(true)
->setPhoneTrading(true);

$account = $entryPoint->create($account);

Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/Actions/can_current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
Content-Type: application/json
Content-Length: '459'
X-Request-Id: '2773776363343519430'
body: '{"id":"8ec3a69b-02d1-4f09-9a6b-6bd54a61b3a8","account_name":"Currency Cloud","brand":"currencycloud","your_reference":null,"status":"enabled","street":null,"city":null,"state_or_province":null,"country":null,"postal_code":null,"spread_table":"fxcg_rfx_default","legal_entity_type":null,"created_at":"2015-04-24T15:57:55+00:00","updated_at":"2015-04-24T15:57:55+00:00","identification_type":null,"identification_value":null,"short_reference":"150424-00002","terms_and_conditions_accepted":null}'
body: '{"id":"8ec3a69b-02d1-4f09-9a6b-6bd54a61b3a8","account_name":"Currency Cloud","brand":"currencycloud","your_reference":null,"status":"enabled","street":null,"city":null,"state_or_province":null,"country":null,"postal_code":null,"spread_table":"fxcg_rfx_default","legal_entity_type":null,"created_at":"2015-04-24T15:57:55+00:00","updated_at":"2015-04-24T15:57:55+00:00","identification_type":null,"identification_value":null,"short_reference":"150424-00002","terms_and_conditions_accepted":null,"api_trading": true,"online_trading": true,"phone_trading": true}'

0 comments on commit 2b39d26

Please sign in to comment.