/** * Get a delivery label for a parcel and a recipient * * @param array $parcel * @param array $recipient * @param array $sender * @param boolean $validate * * @throws InvalidRequestException * @throws FailedRequestException * @throws \SoapFault * * @return ReturnLetter */ public function getLabel(array $parcel, array $recipient, array $sender = array(), $validate = true) { $request = $this->buildLetterColissimoRequest($parcel, $recipient, $sender); if ($validate) { $violations = $this->validator->validate($request->getLetter()); if ($violations->count() > 0) { $exception = new InvalidRequestException('The request is not valid, please check the violations list'); $exception->setViolations($violations); throw $exception; } } $response = $this->client->getLetterColissimo($request); if (!$response->isSuccess()) { throw new FailedRequestException($response->getErrorMessage()); } return $response->getReturnLetter(); }