Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Use restCall object for functions that makes requests #841

Merged
merged 2 commits into from
May 11, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions lib/PayPal/Api/FuturePayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FuturePayment extends Payment
* @param string|null $clientMetadataId
* @return $this
*/
public function create($apiContext = null, $clientMetadataId = null)
public function create($apiContext = null, $clientMetadataId = null, $call = null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please name this $restCall too, just for consistency.

{
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
Expand All @@ -32,7 +32,7 @@ public function create($apiContext = null, $clientMetadataId = null)
);
}
$payLoad = $this->toJSON();
$call = new PayPalRestCall($apiContext);
$call = $call ? $call : new PayPalRestCall($apiContext);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, if we could just replace this with executeCall itself. Maybe we can do that as a separate PR.

$json = $call->execute(
array('PayPal\Handler\RestHandler'),
"/v1/payments/payment",
Expand Down
6 changes: 4 additions & 2 deletions lib/PayPal/Api/OpenIdTokeninfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,10 @@ public static function createFromAuthorizationCode($params, $clientId = null, $c
* (optional) grant_type is the Token grant type. Defaults to refresh_token
* (optional) scope is an array that either the same or a subset of the scope passed to the authorization request
* @param APIContext $apiContext Optional API Context
* @param PayPalRestCall $restCall
* @return OpenIdTokeninfo
*/
public function createFromRefreshToken($params, $apiContext = null)
public function createFromRefreshToken($params, $apiContext = null, $restCall = null)
{
static $allowedParams = array('grant_type' => 1, 'refresh_token' => 1, 'scope' => 1);
$apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential);
Expand All @@ -244,7 +245,8 @@ public function createFromRefreshToken($params, $apiContext = null)
'Content-Type' => 'application/x-www-form-urlencoded',
'Authorization' => 'Basic ' . base64_encode($clientId . ":" . $clientSecret)
),
$apiContext
$apiContext,
$restCall
);

$this->fromJson($json);
Expand Down
6 changes: 4 additions & 2 deletions lib/PayPal/Api/OpenIdUserinfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,9 +505,10 @@ public function getPayerId()
* @param array $params (allowed values are access_token)
* access_token - access token from the createFromAuthorizationCode / createFromRefreshToken calls
* @param ApiContext $apiContext Optional API Context
* @param PayPalRestCall $restCall
* @return OpenIdUserinfo
*/
public static function getUserinfo($params, $apiContext = null)
public static function getUserinfo($params, $apiContext = null, $restCall = null)
{
static $allowedParams = array('schema' => 1);

Expand All @@ -527,7 +528,8 @@ public static function getUserinfo($params, $apiContext = null)
'Authorization' => "Bearer " . $params['access_token'],
'Content-Type' => 'x-www-form-urlencoded'
),
$apiContext
$apiContext,
$restCall
);

$ret = new OpenIdUserinfo();
Expand Down