/**
  * Resource methods
  */
 public function post()
 {
     // Just a dummy redirect to prevent errors in checkout/reward/reward.
     $this->request->post['redirect'] = 'checkout/cart';
     $data = parent::getInternalRouteData('checkout/reward/reward', true);
     ApiException::evaluateErrors($data);
 }
 /**
  * Resource methods
  */
 public function put($id = NULL)
 {
     $this->request->convertBoolToYesNoRadioValue('newsletter');
     $this->request->server['REQUEST_METHOD'] = 'POST';
     $data = parent::getInternalRouteData('account/newsletter');
     ApiException::evaluateErrors($data);
 }
Пример #3
0
 /**
  * Resource methods
  */
 public function post()
 {
     $data = parent::getInternalRouteData('tool/upload', true);
     ApiException::evaluateErrors($data);
     $file = array("file" => $this->getFile($data));
     $this->response->setOutput($file);
 }
Пример #4
0
 /**
  * Resource methods
  */
 public function get()
 {
     $data = parent::getInternalRouteData('checkout/cart');
     ApiException::evaluateErrors($data, false);
     $cart = array('cart' => $this->getCart($data));
     $this->response->setOutput($cart);
 }
 /**
  * Resource methods
  */
 public function post()
 {
     $this->request->setDefaultParameters($this->defaultParameters);
     $this->request->convertBoolToCheckbox('agree');
     $this->request->convertBoolToYesNoRadioValue('newsletter');
     $data = parent::getInternalRouteData('account/register');
     ApiException::evaluateErrors($data);
 }
Пример #6
0
 /**
  * Resource methods
  */
 public function post()
 {
     $this->user->logout();
     unset($this->session->data['token']);
     $data = array('success' => true);
     $this->response->setOutput($data);
     ApiException::evaluateErrors($data);
 }
 public function delete($id = NULL)
 {
     if ($id !== NULL) {
         $this->request->get['remove'] = $id;
     }
     $data = parent::getInternalRouteData('account/wishlist');
     ApiException::evaluateErrors($data);
 }
 public function post()
 {
     $this->request->setDefaultParameters($this->defaultParameters);
     $data = parent::getInternalRouteData('checkout/shipping_method/save', true);
     if (isset($data['redirect'])) {
         $this->redirect($data['redirect']);
     }
     ApiException::evaluateErrors($data);
 }
Пример #9
0
 public function put()
 {
     $this->request->setDefaultParameters($this->defaultParameters);
     $this->request->server['REQUEST_METHOD'] = 'POST';
     $data = parent::getInternalRouteData('account/edit');
     ApiException::evaluateErrors($data);
     $account = array('account' => $this->getAccount($data));
     $this->response->setOutput($account);
 }
Пример #10
0
 /**
  * Resource methods
  */
 public function get()
 {
     $data = parent::getInternalRouteData('checkout/confirm');
     if (isset($data['redirect'])) {
         $this->redirect($data['redirect']);
     }
     ApiException::evaluateErrors($data);
     $order = array('order' => $this->getOrder($data));
     $this->response->setOutput($order);
 }
Пример #11
0
 /**
  * Resource methods
  */
 public function post()
 {
     $this->request->setDefaultParameters($this->defaultParameters);
     $this->request->convertBoolToCheckbox('shipping_address');
     $data = parent::getInternalRouteData('checkout/guest/save', true);
     if (isset($data['redirect'])) {
         $this->redirect($data['redirect']);
     }
     ApiException::evaluateErrors($data);
 }
Пример #12
0
 public function delete($id)
 {
     $cartItemKeys = explode(',', $id);
     foreach ($cartItemKeys as $cartItemKey) {
         $this->request->post['key'] = $cartItemKey;
         $data = parent::getInternalRouteData('checkout/cart/remove', true);
         ApiException::evaluateErrors($data);
     }
     // Return cart
     $this->request->post = array();
     $this->get();
 }
Пример #13
0
 /**
  * Resource methods
  */
 public function post()
 {
     $user = $this->user;
     $data = array();
     if (isset($this->request->post['username']) && isset($this->request->post['username']) && $user->login($this->request->post['username'], $this->request->post['password'])) {
         $data['user'] = array('username' => $user->getUserName(), 'user_id' => $user->getId(), 'user_group_id' => $user->getGroupId(), 'vendor_id' => $user->getVP());
     } else {
         // Need to keep the static messages in a separate file (Keep it in API end ?)
         $data['errors'] = array('code' => "error_warning", 'message' => "Warning: No match for Username and/or Password.");
     }
     $this->response->setOutput($data);
     ApiException::evaluateErrors($data);
 }
 /**
  * Resource methods
  */
 public function post()
 {
     // Validate if customer is logged in. This is needed because in the parent::validate the checkout/checkout route serves two purposes.
     if (!$this->customer->isLogged()) {
         throw new ApiException(ApiResponse::HTTP_RESPONSE_CODE_BAD_REQUEST, ErrorCodes::ERRORCODE_USER_NOT_LOGGED_IN, ErrorCodes::getMessage(ErrorCodes::ERRORCODE_USER_NOT_LOGGED_IN));
     }
     $this->request->setDefaultParameters($this->defaultParameters);
     $data = parent::getInternalRouteData('checkout/shipping_address/save', true);
     if (isset($data['redirect'])) {
         $this->redirect($data['redirect']);
     }
     ApiException::evaluateErrors($data);
 }
Пример #15
0
 public function getRecurringDescription($id = NULL)
 {
     $this->request->post['product_id'] = $id;
     $this->request->post['recurring_id'] = $this->request->get['recurring_id'];
     if (isset($this->request->get['quantity'])) {
         $this->request->post['quantity'] = $this->request->get['quantity'];
     }
     $data = parent::getInternalRouteData('product/product/getRecurringDescription', true);
     ApiException::evaluateErrors($data);
     if (isset($data['success'])) {
         $product = array('recurring_description' => $data['success']);
         $this->response->setOutput($product);
     } else {
         // No description found.
         throw new ApiException(ApiResponse::HTTP_RESPONSE_CODE_NOT_FOUND, ErrorCodes::ERRORCODE_RECURRING_DESCRIPTION_NOT_FOUND, ErrorCodes::getMessage(ErrorCodes::ERRORCODE_RECURRING_DESCRIPTION_NOT_FOUND));
     }
 }
Пример #16
0
 /**
  * Resource methods
  */
 public function post()
 {
     $user = $this->user;
     $data = array();
     if ($this->user->isLogged()) {
         if (!$this->user->hasPermission('modify', 'user/vdi_user_password')) {
             throw new ApiException(ApiResponse::HTTP_RESPONSE_CODE_BAD_REQUEST, ErrorCodes::ERRORCODE_VENDOR_NOT_ALLOWED, "not allowed");
         }
         //log in to check old password
         if (!$user->login($this->user->getUserName(), $this->request->post['old_password'])) {
             throw new ApiException(ApiResponse::HTTP_RESPONSE_CODE_UNAUTHORIZED, ErrorCodes::ERRORCODE_USER_NOT_LOGGED_IN, "error confirming old password");
         }
         //now set new password
         if ($this->user->getId()) {
             $this->load->model('user/vdi_user_password');
             $this->model_user_vdi_user_password->editPassword($this->user->getId(), $this->request->post['new_password']);
             $data = array('success' => true);
         }
     } else {
         throw new ApiException(ApiResponse::HTTP_RESPONSE_CODE_UNAUTHORIZED, ErrorCodes::ERRORCODE_USER_NOT_LOGGED_IN, "user not logged in");
     }
     $this->response->setOutput($data);
     ApiException::evaluateErrors($data);
 }
 /**
  * Resource methods
  */
 public function post()
 {
     $data = parent::getInternalRouteData('account/forgotten');
     ApiException::evaluateErrors($data);
 }
Пример #18
0
 public function deleteProduct($id = NULL)
 {
     if ($this->user->isLogged()) {
         $this->request->post['vendor'] = $this->user->getVP();
     }
     $productIds = explode(',', $id);
     foreach ($productIds as $productId) {
         if (is_numeric($productId)) {
             $this->request->post['key'] = $productId;
             $data = parent::getInternalRouteData('product/product/delete', true);
             ApiException::evaluateErrors($data);
         }
     }
     $this->response->addHeader('Content-Type: application/json');
     $this->response->setOutput($data);
 }
Пример #19
0
 /**
  * Resource methods
  */
 public function get($id = NULL)
 {
     $data = parent::getInternalRouteData('account/logout');
     ApiException::evaluateErrors($data);
 }
Пример #20
0
 /**
  * Resource methods
  */
 public function post()
 {
     $data = parent::getInternalRouteData('checkout/voucher/voucher', true);
     ApiException::evaluateErrors($data);
 }
Пример #21
0
 public function delete($id = NULL)
 {
     if ($id !== NULL) {
         $this->request->get['address_id'] = $id;
     }
     $data = parent::getInternalRouteData('account/address/delete');
     ApiException::evaluateErrors($data);
 }