Skip to content

Commit

Permalink
Merged with V4 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Rrathinasabapath committed Oct 22, 2020
2 parents dbd9a27 + ab887b4 commit ab5e27f
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 36 deletions.
Empty file added hasPreviousPage
Empty file.
48 changes: 37 additions & 11 deletions src/Hyperwallet/Hyperwallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,17 @@ class Hyperwallet {
* @param string|null $programToken The program token that is used for some API calls
* @param string $server The API server to connect to
* @param string $encryptionData Encryption data to initialize ApiClient with encryption enabled
* @param array $clientOptions Guzzle Client Options
*
* @throws HyperwalletArgumentException
*/
public function __construct($username, $password, $programToken = null, $server = 'https://api.sandbox.hyperwallet.com', $encryptionData = array()) {
public function __construct($username, $password, $programToken = null, $server = 'https://api.sandbox.hyperwallet.com', $encryptionData = array(), $clientOptions = array()) {
if (empty($username) || empty($password)) {
throw new HyperwalletArgumentException('You need to specify your API username and password!');
}

$this->programToken = $programToken;
$this->client = new ApiClient($username, $password, $server, array(), $encryptionData);
$this->client = new ApiClient($username, $password, $server, $clientOptions, $encryptionData);
}

//--------------------------------------
Expand Down Expand Up @@ -1501,9 +1502,11 @@ public function listBalancesForUser($userToken, $options = array()) {
}

$body = $this->client->doGet('/rest/v4/users/{user-token}/balances', array('user-token' => $userToken), $options);
return new ListResponse($body, function ($entry) {
$listResponse = new ListResponse($body, function ($entry) {
return new Balance($entry);
});
call_user_func(array($listResponse, 'unsetLinksAttribute'));
return $listResponse;
}

/**
Expand All @@ -1528,9 +1531,11 @@ public function listBalancesForPrepaidCard($userToken, $prepaidCardToken, $optio
'user-token' => $userToken,
'prepaid-card-token' => $prepaidCardToken
), $options);
return new ListResponse($body, function ($entry) {
$listResponse = new ListResponse($body, function ($entry) {
return new Balance($entry);
});
call_user_func(array($listResponse, 'unsetLinksAttribute'));
return $listResponse;
}

/**
Expand All @@ -1555,9 +1560,11 @@ public function listBalancesForAccount($programToken, $accountToken, $options =
'program-token' => $programToken,
'account-token' => $accountToken
), $options);
return new ListResponse($body, function ($entry) {
$listResponse = new ListResponse($body, function ($entry) {
return new Balance($entry);
});
call_user_func(array($listResponse, 'unsetLinksAttribute'));
return $listResponse;
}

//--------------------------------------
Expand Down Expand Up @@ -1996,7 +2003,7 @@ public function updateVerificationStatus($userToken, $verificationStatus){
throw new HyperwalletArgumentException('verificationStatus is required!');
}
$user = new User(array('verificationStatus'=> $verificationStatus));
$responseUser = $this->client->doPut('/rest/v3/users/{user-token}', array('user-token' => $userToken), $user, array());
$responseUser = $this->client->doPut('/rest/v4/users/{user-token}', array('user-token' => $userToken), $user, array());
return new User($responseUser);
}

Expand All @@ -2016,7 +2023,7 @@ public function createUserStatusTransition($userToken, UserStatusTransition $tra
if (empty($transition->getTransition())) {
throw new HyperwalletArgumentException('userStatusTransition is required!');
}
$body = $this->client->doPost('/rest/v3/users/{user-token}/status-transitions', array(
$body = $this->client->doPost('/rest/v4/users/{user-token}/status-transitions', array(
'user-token' => $userToken), $transition, array());
return new UserStatusTransition($body);
}
Expand Down Expand Up @@ -2346,10 +2353,6 @@ public function uploadDocumentsForBusinessStakeholder($userToken, $businessToken
return new BusinessStakeholder($body);
}

//--------------------------------------
// Business Stakeholders
//--------------------------------------

/**
* Create a Business Stakeholder
*
Expand All @@ -2371,6 +2374,7 @@ public function createBusinessStakeholder($userToken,$businessStakeholder) {
*
* @param Business Stakeholder $BusinessStakeholder The Business Stakeholder
* @return BusinessStakeholder
*
* @throws HyperwalletArgumentException
* @throws HyperwalletApiException
Expand All @@ -2394,6 +2398,7 @@ public function updateBusinessStakeholder($userToken, $businessToken, $businessS
*
* @throws HyperwalletApiException
*/

public function listBusinessStakeholders($userToken , $options) {
if (empty($userToken)) {
throw new HyperwalletArgumentException('userToken is required!');
Expand All @@ -2411,4 +2416,25 @@ public function listBusinessStakeholders($userToken , $options) {
return new BusinessStakeholder($entry);
});
}

/**
* List all Transfer Methods
*
* @param string $userToken The user token
* @param array $options The query parameters
* @return ListResponse of HyperwalletTransferMethod
*/

public function listTransferMethods($userToken, $options = array()) {
if (empty($userToken)) {
throw new HyperwalletArgumentException('userToken is required!');
}

$body = $this->client->doGet('/rest/v4/users/{user-token}/transfer-methods', array(
'user-token' => $userToken
), $options);
return new ListResponse($body, function ($entry) {
return new TransferMethod($entry);
});
}
}
12 changes: 12 additions & 0 deletions src/Hyperwallet/Response/ListResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,16 @@ public function offsetSet($offset, $value) {
public function offsetUnset($offset) {
unset($this->data[$offset]);
}

/**
* @external
*
* The links to unset.
* @method unsetLinksAttribute()
* @return void
* @description unsetting links attribute.
*/
public function unsetLinksAttribute(){
unset($this->links);
}
}

0 comments on commit ab5e27f

Please sign in to comment.