public function __construct(Payload $payload) { parent::__construct($payload); if ($this->isSuccess()) { $this->session = $payload[static::FIELD_SESSION]; $this->userId = $payload[static::FIELD_USER][static::FIELD_USER_ID]; } else { if ($this->getErrorCode() == static::ERROR_INVALID_CREDENTIALS) { throw new InvalidCredentials($payload, 'Password invalid'); } } }
public function __construct(Payload $payload) { parent::__construct($payload); if ($this->isSuccess()) { $this->deposits = $payload[static::FIELD_SUMMARY][static::FIELD_DEPOSITS]; $this->profit = $payload[static::FIELD_SUMMARY][static::FIELD_PROFIT]; $this->bonuses = $payload[static::FIELD_SUMMARY][static::FIELD_BONUSES]; $this->withdrawals = $payload[static::FIELD_SUMMARY][static::FIELD_WITHDRAWALS]; $this->rows = []; foreach ($payload[static::FIELD_ROWS] as $row) { $this->rows[] = new Transaction($row); } } }
public function __construct(Payload $payload) { parent::__construct($payload); if ($this->isSuccess()) { $this->id = $payload[static::FIELD_ID]; } else { switch ($this->getErrorCode()) { case static::ERROR_EMAIL_ALREADY_EXISTS: throw new EmailAlreadyExists($payload, 'Email already exists'); case static::ERROR_BLOCKED_COUNTRY: throw new BlockedCountry($payload, 'Country is not allowed'); default: throw new Exception($payload, 'Trade platform error'); } } }
public function __construct(Payload $payload) { parent::__construct($payload); if ($this->isSuccess()) { $currenciesDictionary = ApiClient::getCurrenciesDictionary(); $this->userId = $this->data[static::FIELD_USER_ID]; $this->dateOfBirth = $this->data[static::FIELD_DATE_OF_BIRTH]; $this->confirmed = $this->data[static::FIELD_CONFIRMED]; $this->validated = $this->data[static::FIELD_VALIDATED]; $this->frozen = $this->data[static::FIELD_FROZEN]; $this->blocked = $this->data[static::FIELD_BLOCKED]; $this->affiliateId = $this->data[static::FIELD_AFFILIATE_ID]; $this->userCurrency = isset($currenciesDictionary[$this->data[static::FIELD_USER_CURRENCY]]) ? $currenciesDictionary[$this->data[static::FIELD_USER_CURRENCY]] : null; } else { switch ($this->getErrorCode()) { default: throw new Exception($payload, 'Trade platform error'); } } }