PayPal\Api\Invoice::update PHP Method

update() public method

Fully updates an invoice by passing the invoice ID to the request URI. In addition, pass a complete invoice object in the request JSON. Partial updates are not supported.
public update ( ApiContext $apiContext = null, PayPalRestCall $restCall = null ) : Invoice
$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 Invoice
    public function update($apiContext = null, $restCall = null)
    {
        ArgumentValidator::validate($this->getId(), "Id");
        $payLoad = $this->toJSON();
        $json = self::executeCall("/v1/invoicing/invoices/{$this->getId()}", "PUT", $payLoad, null, $apiContext, $restCall);
        $this->fromJson($json);
        return $this;
    }

Usage Example

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