function __construct($data)
 {
     if (!in_array(@$data['transaction_type'], self::$allowedTypes)) {
         throw Errors\ValidationError::create('transaction_type', 'value invalid: "' . @$data['transaction_type'] . '"');
     }
     Helper::assign($this, $data);
     if (isset($this->transaction_id)) {
         $this->transaction_id = Helper::appendRandomId($this->transaction_id);
     }
 }
 /**
  * $data hash of format:
  * {
  *		type: "WpfPayment",
  *		amount: 1000,
  *		currency: "USD",
  *		...
  *	}
  *
  * @param array $data
  */
 function __construct($data)
 {
     if (!in_array(@$data['type'], self::$allowedTypes)) {
         throw Errors\ValidationError::create('type', 'must be one of "' . join(self::$allowedTypes, '", "') . '" but is: "' . @$data['type'] . '"');
     }
     Helper::assign($this, $data);
     if (isset($this->transaction_id)) {
         $this->transaction_id = Helper::appendRandomId($this->transaction_id);
     }
 }
 function testValidateThrows()
 {
     $this->expectException(Errors\ValidationError::create('unique_id', 'must be 32 character hex string: 345'));
     $c = new SimplePaymentReturningRequest('cancel', '345');
     $c->validate();
 }
 function testValidateEndDateFormat()
 {
     $this->expectException(Errors\ValidationError::create('end_date', 'must be yyyy-mm-dd'));
     $r = new ReconcileByDateRequest(array('start_date' => '2014-11-01', 'end_date' => '2019-1-1'));
     $r->validate();
 }