Exemple #1
0
 /**
  * Edits a location and returns the updated instance.
  *
  * @param Google\MyBusiness\Location $location
  * @param Google\MyBusiness\Account $account = null
  * @param boolean $dryRun = false
  * @return Google\MyBusiness\Location
  */
 public function editLocation(Location $location, Account $account = null, $dryRun = false)
 {
     try {
         self::_validateLocation($location);
     } catch (AccountOwnerNotSetException $e) {
         /* Try to use the account in the arguments, or failing that, the
            cached account. */
         if ($account) {
             self::_validateID($account);
         } else {
             $account = $this->_getCachedAccount();
         }
         $location->setOwnerAccountID($account->getID());
     }
     $locationRest = $location->toREST();
     $requestBody = array('location' => $locationRest, 'languageCode' => $location->getLanguageCode(), 'fieldMask' => implode(',', array_map(function ($key) {
         return 'location.' . $key;
     }, array_keys($locationRest))), 'validateOnly' => $dryRun);
     $request = new APIRequest($location->getName());
     $request->setPayload(json_encode($requestBody));
     $request->setVerb('PATCH');
     $this->_parseCallback = '_parseLocationResponse';
     return $this->_makeRequest($request);
 }