/**
  * @param Opportunity $opportunity
  *
  * @return Opportunity
  * @throws InvalidParamException
  */
 public function updateOpportunity(Opportunity $opportunity)
 {
     if ($opportunity->getId() == null) {
         throw new InvalidParamException('When updating a opportunity you must provide the opportunity ID');
     }
     $id = $opportunity->getId();
     $opportunity->setId(null);
     $opportunity = json_encode($opportunity);
     $apiRequest = $this->prepareRequest('update-opportunity', $opportunity, ['id' => $id]);
     $response = $this->triggerPut($apiRequest);
     return new Opportunity($response->getData());
 }
 /**
  * @param Opportunity $opportunity
  * @return Opportunity|string
  * @throws InvalidParamException
  * @throws ResourceNotFoundException
  */
 public function updateOpportunity(Opportunity $opportunity)
 {
     // check if opportunity has id
     if ($opportunity->getId() == null) {
         throw new InvalidParamException('When updating a opportunity you must provide the opportunity ID');
     }
     // remove id from opportunity since it won't be part of the patch data
     $id = $opportunity->getId();
     $opportunity->setId(null);
     $opportunity = json_encode($opportunity);
     $apiRequest = $this->prepareRequest('update-opportunity', $opportunity, ['id' => $id]);
     $response = $this->triggerPut($apiRequest);
     // return Opportunity object if successful
     if ($response->getReturnCode() == 200 && $response->getData() !== null) {
         $opportunity = new Opportunity($response->getData());
     } else {
         throw new ResourceNotFoundException();
     }
     return $opportunity;
 }