Skip to content

Commit

Permalink
De-duplicating User controller
Browse files Browse the repository at this point in the history
  • Loading branch information
paypay-ayas committed Sep 15, 2020
1 parent 86c3429 commit 4ad73dd
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/Controllers/User.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

namespace PayPay\OpenPaymentAPI\Controller;

use PayPay\OpenPaymentAPI\Client;
Expand Down Expand Up @@ -110,14 +109,7 @@ public function getUserAuthorizationStatus($userAuthorizationId)
if ($mid) {
$options["HEADERS"]['X-ASSUME-MERCHANT'] = $mid;
}
$response = $this->main()->http()->get(
$url,
[
'headers' => $options["HEADERS"],
'query' => ['userAuthorizationId' => $userAuthorizationId]
]
);
return json_decode($response->getBody(), true);
return $this->doAuthCall($url,$options,$userAuthorizationId);
}

/**
Expand All @@ -138,6 +130,17 @@ public function getMaskedUserProfile($userAuthorizationId)
if ($mid) {
$options["HEADERS"]['X-ASSUME-MERCHANT'] = $mid;
}
return $this->doAuthCall($url,$options,$userAuthorizationId);
}
/**
* Generic HTTP call function
*
* @param string $url
* @param array $options
* @param string $userAuthorizationId
* @return array
*/
private function doAuthCall($url,$options,$userAuthorizationId){
$response = $this->main()->http()->get(
$url,
[
Expand Down

0 comments on commit 4ad73dd

Please sign in to comment.