/**
  * @param OpenpayException $exception
  * @param array $data
  * @return OpenpayException
  */
 public function populate(OpenpayException $exception, array $data)
 {
     $exception->setCategory(isset($data['category']) ? $data['category'] : null);
     $exception->setDescription(isset($data['description']) ? $data['description'] : null);
     $exception->setErrorCode(isset($data['error_code']) ? $data['error_code'] : null);
     $exception->setFraudRules(isset($data['fraud_rules']) ? $data['fraud_rules'] : null);
     $exception->setHttpCode(isset($data['http_code']) ? $data['http_code'] : null);
     $exception->setRequestId(isset($data['request_id']) ? $data['request_id'] : null);
     return $exception;
 }
 /**
  * @param int $senderId
  * @param array $parameters
  * @return \Openpay\Client\Type\OpenpayTransactionType
  * @throws OpenpayException
  */
 public function transfer($senderId, $parameters)
 {
     $violations = $this->transferValidator->validate($senderId, $parameters);
     if ($violations->count() > 0) {
         $openpayException = new OpenpayException($violations->__toString(), self::BAD_REQUEST_STATUS_CODE);
         $openpayException->setErrorCode(self::OPENPAY_BAD_REQUEST_CODE);
         $openpayException->setDescription($violations->__toString());
         throw $openpayException;
     }
     $relativeUrl = $this->merchantId . '/' . self::CUSTOMERS_ENDPOINT . '/' . $senderId . '/' . self::TRANSFERS_ENDPOINT;
     $options = $this->options;
     $options['json'] = $parameters;
     $response = $this->callOpenpayClient($relativeUrl, $options, self::POST_METHOD);
     $transaction = $this->transactionMapper->create($response);
     return $transaction;
 }