PayPal\Api\CreditCard::update PHP Method

update() public method

Update information in a previously saved card. Only the modified fields need to be passed in the request.
public update ( PatchRequest $patchRequest, ApiContext $apiContext = null, PayPalRestCall $restCall = null ) : CreditCard
$patchRequest PatchRequest
$apiContext PayPal\Rest\ApiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
$restCall PayPal\Transport\PayPalRestCall is the Rest Call Service that is used to make rest calls
return CreditCard
    public function update($patchRequest, $apiContext = null, $restCall = null)
    {
        ArgumentValidator::validate($this->getId(), "Id");
        ArgumentValidator::validate($patchRequest, 'patch');
        $payload = $patchRequest->toJSON();
        $json = self::executeCall("/v1/vault/credit-cards/{$this->getId()}", "PATCH", $payload, null, $apiContext, $restCall);
        $this->fromJson($json);
        return $this;
    }

Usage Example

 /**
  * @dataProvider mockProvider
  * @param CreditCard $obj
  */
 public function testUpdate($obj, $mockApiContext)
 {
     $mockPPRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock();
     $mockPPRestCall->expects($this->any())->method('execute')->will($this->returnValue(self::getJson()));
     $patchRequest = PatchRequestTest::getObject();
     $result = $obj->update($patchRequest, $mockApiContext, $mockPPRestCall);
     $this->assertNotNull($result);
 }