Example #1
0
 /**
  * @method POST
  */
 function add()
 {
     // get token
     $token = Utilities::ValidateJWTToken();
     // check if token is not null
     if ($token != NULL) {
         // parse request
         parse_str($this->request->data, $request);
         // get request paramters
         $productId = $request['productId'];
         $sku = $request['sku'];
         $pageId = $request['pageId'];
         $name = $request['name'];
         $price = $request['price'];
         $shipping = $request['shipping'];
         $weight = $request['weight'];
         $download = $request['download'];
         // adds a version
         Product::Add($productId, $sku, $pageId, $name, $price, $shipping, $weight, $download);
         // return a 200
         return new Tonic\Response(Tonic\Response::OK);
     } else {
         // unauthorized access
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }