getCustomerOrNew('123e4567-e89b-12d3-a456-426614174000'); echo $customer->firstname; $customer->firstname = 'new firstname'; try { if ($customer->save()) { echo 'Customer was updated'; } } catch (ApiErrorException $e) { if ($e->getApiError()->equals(ApiError::modelNotFound())) { echo 'This customer does not exists in crm therefore we cannot update it'; echo $e->getMessage(); } if ($e->getApiError()->equals(ApiError::validationFailed())) { echo 'Some of the provided fields were not ok'; echo $e->getMessage(); } } $customer = new Customer(); $customer->firstname = 'toto'; $customer->lastname = 'delarogerie'; $customer->email = 'toto.delarogerie@gmail.com'; $customer->password = 'Complic4tEd!P4assW0rd'; $customer->birth_date = '1992-03-08'; $customer->phone = '0673891160'; $customer->address = 'rue des totos'; $customer->city = 'Toto ville'; $customer->postcode = '72160'; $customer->country = Country::france(); try { if ($customer->save()) { echo 'Customer is saved in crm'; } else { echo 'Customer was not saved in crm'; } } catch (ApiErrorException $e) { echo 'Something went wrong'; echo $e->getMessage(); // phpcs:ignore Squiz.PHP.DiscouragedFunctions.Found print_r($e->getApiError()); }