Returns discount with given id.

@param Pluf_HTTP_Request $request
@param array $match
@return Discount_Discount
487037
public static function get($request, $match)
    {
        $discount = Discount_Views_Discount::getDiscount($request, $match);
        // حق دسترسی
        // CMS_Precondition::userCanAccessContent($request, $content);
        // اجرای درخواست
        return new Pluf_HTTP_Response_Json($discount);
    }
235220
private function _convertGetMatchingProduct($request) {

        $parameters = array();
        $parameters['Action'] = 'GetMatchingProduct';
        if ($request->isSetSellerId()) {
            $parameters['SellerId'] =  $request->getSellerId();
        }
        if ($request->isSetMWSAuthToken()) {
            $parameters['MWSAuthToken'] =  $request->getMWSAuthToken();
        }
        if ($request->isSetMarketplaceId()) {
            $parameters['MarketplaceId'] =  $request->getMarketplaceId();
        }
        if ($request->isSetASINList()) {
            $ASINListGetMatchingProductRequest = $request->getASINList();
            foreach  ($ASINListGetMatchingProductRequest->getASIN() as $ASINASINListIndex => $ASINASINList) {
                $parameters['ASINList' . '.' . 'ASIN' . '.'  . ($ASINASINListIndex + 1)] =  $ASINASINList;
            }
        }

        return $parameters;
    }
669201
private function internalGet($request, $match){
        if ($request->user->hasPerm('tenant.owner')) {
            $sql = new Pluf_SQL('`key`=%s', array(
                $match['key']
            ));
        } else {
            $sql = new Pluf_SQL('`key`=%s AND `mode`=%s', array(
                $match['key'],
                Tenant_Setting::MOD_PUBLIC
            ));
        }
        $model = new Tenant_Setting();
        $model = $model->getOne(array(
            'filter' => $sql->gen()
        ));
        return $model;
    }
1262635
public function createManyToOne($request, $match)
    {
        $parent = Pluf_Shortcuts_GetObjectOr404('Tenant_Ticket', $match['parentId']);
        $object = new Tenant_Comment();
        $form = Pluf_Shortcuts_GetFormForModel($object, $request->REQUEST);
        $object = $form->save(false);
        $object->ticket_id = $parent;
        $object->author_id = $request->user;
        $object->create();
        return $object;
    }
928672
public function create($request, $match)
    {
        // 1- upload & extract
        $key = 'spa-' . md5(microtime() . rand(0, 123456789));
        Pluf_Form_Field_File_moveToUploadFolder($request->FILES['file'], array(
            'file_name' => $key . '.zip',
            'upload_path' => Pluf::f('temp_folder', '/tmp'),
            'upload_path_create' => true,
            'upload_overwrite' => true
        ));
        $spa = Tenant_SpaService::installFromFile(Pluf::f('temp_folder', '/tmp') . '/' . $key . '.zip', true);
        return Tenant_Shortcuts_SpaManager($spa)->apply($spa, 'create');
    }
649207
public static function get($request, $match)
    {
        if(isset($match['userId'])){        
            $user = Pluf_Shortcuts_GetObjectOr404('User_Account', $match['userId']);
        }else{
            $user = $request->user;
        }
        if (array_key_exists('profileId', $match)) {
            return Pluf_Shortcuts_GetObjectOr404('User_Profile', $match['profileId']);
        }
        $profile = self::getProfileOfUser($user);
        if($profile === null){
            $profile = new User_Profile();
            $profile->account_id = $user;
        }
        return $profile;
    }
615871
public function getMatchStatus($matchId) {
        $endpoint = vsprintf('/match/%s', $matchId);
        $requestData = $this->getDefaultRequestData('query', []);

        return $this->sendRequest($endpoint, $requestData, self::HTTP_METHOD_GET);
    }
1361232
public function password($request, $match)
    {
        $msg = array(
            'message' => 'succcess'
        );
        // TODO: maso, 2017: recover by mail
        if (array_key_exists('email', $request->REQUEST)) {
            $sql = new Pluf_SQL('email=%s', array(
                $request->REQUEST['email']
            ));
            $user = $request->user->getOne($sql->gen());
            if ($user) {
                $this->sendPasswordToken($request, $user);
            }
            return $msg;
        }
        // TODO: maso, 2017: recover by login
        if (array_key_exists('login', $request->REQUEST)) {
            $sql = new Pluf_SQL('login=%s', array(
                $request->REQUEST['login']
            ));
            $user = $request->user->getOne($sql->gen());
            if ($user) {
                $this->sendPasswordToken($request, $user);
            }
            return $msg;
        }
        // Reset password by token
        if (array_key_exists('token', $request->REQUEST)) {
            $token = new User_PasswordToken();
            $sql = new Pluf_SQL('token=%s', array(
                $request->REQUEST['token']
            ));
            $token = $token->getOne($sql->gen());
            if (! $token || $token->isExpired()) {
                throw new Pluf_Exception_DoesNotExist('Token not exist');
            }
            $user = $token->get_user();
            $user->setPassword($request->REQUEST['new']);
            $user->update();
            $token->delete();
            return $msg;
        }
        // Reset password by old password
        if (array_key_exists('old', $request->REQUEST) || array_key_exists('old_password', $request->REQUEST)) {
            $oldPass = array_key_exists('old', $request->REQUEST) ? 
            $request->REQUEST['old'] : $request->REQUEST['old_password'];
            if ($request->user->isAnonymous()) {
                throw new Pluf_Exception_Unauthorized();
            }
            // Retreive credential
            $cred = User_Credential::getCredential($request->user->id);
            if (! $cred->checkPassword($oldPass)) {
                throw new Pluf_Exception_MismatchParameter('Old pass is not currect');
            }
            $newPass = array_key_exists('new', $request->REQUEST) ? 
                $request->REQUEST['new'] : $request->REQUEST['password'];
            $cred->setPassword($newPass);
            $cred->update();
            return $msg;
        }

        throw new Pluf_Exception_MismatchParameter('Invalid request params');
    }
211746
public function deleteTag ($request, $match)
    {
        $location = Geo_Shortcuts_GetLocationOr404($match[1]);
        Geo_Precondition::canEditLocation($request, $location);
        $tag = SaaSKM_Shortcuts_GetTagOr404($match[2]);
        SaaSKM_TagRow::remove($request->tenant, $location, $tag);
        return new Pluf_HTTP_Response_Json($location);
    }
832207
public function putMap ($request, $match)
    {
        if (isset($match['collectionId'])) {
            $collectionId = $match['collectionId'];
        } else {
            $collectionId = $request->REQUEST['collectionId'];
        }
        // $collection = Pluf_Shortcuts_GetObjectOr404('Collection_Collection',
        // $collectionId);
        if (isset($match['documentId'])) {
            $documentId = $match['documentId'];
        } else {
            $documentId = $request->REQUEST['documentId'];
        }
        $document = Pluf_Shortcuts_GetObjectOr404('Collection_Document', 
                $documentId);
        
        if ($document->collection != $collectionId) {
            throw new Pluf_Exception_DoesNotExist(
                    'Document with id (' . $documentId .
                             ') does not exist in collection with id (' .
                             $collectionId . ')');
        }
        
        $this->putDocumentMap($document, $request->REQUEST);
        return new Pluf_HTTP_Response_Json($this->getDocumentMap($document));
    }
1010438
public function getPayment($request, $match)
    {
        Pluf::loadFunction('Pluf_Shortcuts_GetObjectOr404');
        // Check wallets and permissions to access wallets
        $wallet = Pluf_Shortcuts_GetObjectOr404('Bank_Wallet', $match['parentId']);
        if ($request->user->getId() !== $wallet->owner_id && ! User_Precondition::isOwner($request)) {
            throw new Pluf_Exception_PermissionDenied("Permission is denied");
        }
        // Check payment
        $transfer = Pluf_Shortcuts_GetObjectOr404('Bank_Transfer', $match['modelId']);
        $payment = Pluf_Shortcuts_GetObjectOr404('Bank_Receipt', $transfer->receipt_id);
        if ($payment->owner_id !== 'bank-wallet' && $payment->owner_id !== $wallet->id) {
            throw new Pluf_Exception_DoesNotExist('The payment is not blong to the wallet.');
        }
        $preState = $payment->id >= 0 && $payment->isPayed();
        if ($preState) {
            return $transfer;
        }
        $payment = Bank_Service::update($payment);
        $paid = $payment->isPayed();
        if (! $preState && $paid) {
            // The payment is payed and it is first time that we inform about it.
            // Update balance of wallet
            $wallet->total_deposit += $transfer->amount;
            $wallet->update();
            // Notify user
            if (! Pluf::f('test_unit', false)) {
                $context = array(
                    'wallet' => $wallet,
                    'user' => $request->user,
                    'receipt' => $payment,
                    'transfer' => $transfer
                );
                User_Notify::push($wallet->get_owner(), array(
                    'Message' => 'Bank/Message/wallet-charge.txt'
                ), $context);
            }
        }
        return $transfer;
    }
223970
public function create($request, $match)
    {
        // initial content data
        $extra = array(
            'user' => $request->user,
            'model' => new CMS_Content()
        );

        // Create content and get its ID
        $form = new CMS_Form_ContentCreate($request->REQUEST, $extra);

        // Upload content file and extract information about it (by updating
        // content)
        $extra['model'] = $form->save();
        $form = new CMS_Form_ContentUpdate(array_merge($request->REQUEST, $request->FILES), $extra);
        try {
            $content = $form->save();
        } catch (Pluf_Exception $e) {
            $content = $extra['model'];
            $content->delete();
            throw $e;
        }
        return $content;
    }
1143268
public function remove ($request, $match)
    {
        if (isset($match['collectionId'])) {
            $collectionId = $match['collectionId'];
        } else {
            $collectionId = $request->REQUEST['collectionId'];
        }
        $collection = Pluf_Shortcuts_GetObjectOr404('Collection_Collection', 
                $collectionId);
        if (isset($match['documentId'])) {
            $documentId = $match['documentId'];
        } else {
            $documentId = $request->REQUEST['documentId'];
        }
        $document = Pluf_Shortcuts_GetObjectOr404('Collection_Document', 
                $documentId);
        
        if ($document->collection !== $collection->id) {
            throw new Pluf_Exception_DoesNotExist(
                    'Document with id (' . $documentId .
                             ') does not exist in collection with id (' .
                             $collectionId . ')');
        }
        $documentCopy = Pluf_Shortcuts_GetObjectOr404('Collection_Document', 
                $documentId);
        $document->delete();
        return new Pluf_HTTP_Response_Json($documentCopy);
    }
1165091
public function create($request, $match)
    {
        $type = 'not set';
        if (array_key_exists('type', $request->REQUEST)) {
            $type = $request->REQUEST['type'];
        }
        $engine = Bank_Shortcuts_GetEngineOr404($type);
        $params = array(
            'engine' => $engine
        );
        $form = new Bank_Form_BackendNew($request->REQUEST, $params);
        $backend = $form->save();
        return new Pluf_HTTP_Response_Json($backend);
    }
1261848
public function deleteTagBykeyvalue ($request, $match)
    {
        $location = Geo_Shortcuts_GetLocationOr404($match[1]);
        Geo_Precondition::canEditLocation($request, $location);
        $tag = SaaSKM_Tag::getFromString($request->tenant, $request->REQUEST['tag']);
        if(! $tag){
            throw new Pluf_Exception("Tag not found");
        }
        // XXX: maso, 1394: بررسی وجود برچسب
        SaaSKM_TagRow::remove($request->tenant, $location, $tag);
        return new Pluf_HTTP_Response_Json($location);
    }
349847
public function get($match = [], $except = [])
    {
        return $this->routes->filterMatch($match)
            ->filterExcept($except)
            ->values();
    }
1166140
public function matchUrl(RequestInterface $request, array $maps)
    {
        $matched = [];

        $uri = (string)$request->getUri();

        /** @var RequestMap $map */
        foreach ($maps as $map) {
            if ((string)$map->getRequest()->getUri() === $uri) {
                $matched[] = $map;
            }
        }

        return $matched;
    }