'POS Terminal', self::TYPE_E_COMMERCE => 'E-Commerce / Datatrans Terminal', self::TYPE_MERCHANT => 'Virtual Terminal Merchant', self::TYPE_E_SHOP => 'Virtual Terminal E-Shop / Voucher shop', self::TYPE_MOBILE_APP => 'Virtual Terminal Mobile App', ]; /** * @param int $type * @return array * @throws InnocadLoyaltyException */ public static function get($type = null) { if (null !== $type && !array_key_exists($type, self::$allowed_types)) { throw new InnocadLoyaltyException('Unknown Terminal Type'); } $userSessionID = User::signin(); $response = Request::get('LOIN/Terminal', ['UserSessionID' => $userSessionID]); User::signout($userSessionID); if (Request::RESPONSE_STATUS_OK != $response['LOINTerminalSelect']['Status']) { throw new InnocadLoyaltyException($response['LOINTerminalSelect']['UserMessage'], $response['LOINTerminalSelect']['Status']); } if (!$response['LOINTerminalSelect']['RowCount']) { throw new InnocadLoyaltyException('There are no terminals found'); } $terminals = $response['LOINTerminalSelect']['Terminals']; if (null !== $type) { foreach ($terminals as $terminal) { if ($type == $terminal['Terminal']['TerminalType'] && self::STATUS_ACTIVE == $terminal['Terminal']['Status']) { return $terminal['Terminal']; } } throw new InnocadLoyaltyException('There is no active "' . self::$allowed_types[$type] . '"'); } return $terminals; } }