Exemplo n.º 1
1
 /**
  * Inserts a value from JSON input. The input should be formatted like this:
  * {
  *      'chart_id': <chart id> [integer]
  *      'auth': <chart auth> [string]
  *      'value': <chart value> [double]
  * }
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function insert()
 {
     if (Input::isJson()) {
         $input = Input::json()->all();
         try {
             $chart = Chart::findOrFail($input['chart_id']);
         } catch (ModelNotFoundException $e) {
             return response()->json(['success' => false, 'message' => 'Chart not found'], 400);
         }
         // Check if correct chart password
         if ($input['auth'] === $chart['auth']) {
             $val = $input['value'];
             if (!$chart->insertValue($val)) {
                 // Error while inserting
                 return response()->json(['success' => false, 'message' => 'Error inserting value'], 400);
             }
             // Successful insert
             return response()->json(['success' => true, 'message' => 'Value successfully inserted'], 200);
         } else {
             return response()->json(['success' => false, 'message' => 'Incorrect auth for chart'], 401);
         }
     } else {
         return response()->json(['success' => false, 'message' => 'Incorrect input type. Expected JSON'], 400);
     }
 }
Exemplo n.º 2
1
 public function login()
 {
     //echo "Came to validation part>>>!";
     if (Auth::attempt(array('email' => Input::json('email'), 'password' => Input::json('password')))) {
         return Response::json(Auth::user());
     } else {
         return Response::json(array('flash' => 'Invalid username or password'), 500);
     }
 }
 public function postAllfundamentaldetails()
 {
     $serviceRequest = $this->GetObjectFromJsonRequest(Input::json()->all());
     $user = $this->GetSessionUser($serviceRequest->Token);
     if ($user->IsSuccess) {
         $serviceResponse = $this->DataProvider->AllFundamentalDetails($serviceRequest->Data);
     } else {
         $serviceResponse = $user;
     }
     return $this->GetJsonResponse($serviceResponse);
 }
 /**
  * @param LaravelMixpanel $mixPanel
  */
 public function postTransaction(LaravelMixpanel $mixPanel)
 {
     $data = Input::json()->all();
     if (!$data || !array_key_exists('data', $data)) {
         throw new Exception('Missing "data" parameter in Stripe webhook POST request: ' . $data);
     }
     $transaction = $data['data']['object'];
     $originalValues = array_key_exists('previous_attributes', $data['data']) ? $data['data']['previous_attributes'] : [];
     $stripeCustomerId = $this->findStripeCustomerId($transaction);
     $user = App::make(config('auth.model'))->where('stripe_id', $stripeCustomerId)->first();
     if (!$user) {
         return;
     }
     $mixPanel->identify($user->id);
     if ($transaction['object'] === 'charge' && !count($originalValues)) {
         $this->recordCharge($mixPanel, $transaction, $user);
     }
     if ($transaction['object'] === 'subscription') {
         $this->recordSubscription($mixPanel, $transaction, $user, $originalValues);
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $this->model->update($id, Input::json()->all());
 }
 public function postDeletefundamental()
 {
     $serviceRequest = $this->GetObjectFromJsonRequest(Input::json()->all());
     $serviceResponse = $this->DataProvider->DeleteFundamental($serviceRequest->Data);
     return $this->GetJsonResponse($serviceResponse);
 }
Exemplo n.º 7
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $key = Input::get('key');
     $json = Input::all();
     //print_r($json);
     /*
                         ->join('members as m','d.merchant_id=m.id','left')
                         ->where('assignment_date',$indate)
                         ->where('device_id',$dev->id)
                         ->and_()
                         ->group_start()
                             ->where('status',$this->config->item('trans_status_admin_courierassigned'))
                             ->or_()
                             ->group_start()
                                 ->where('status',$this->config->item('trans_status_new'))
                                 ->where('pending_count >', 0)
                             ->group_end()
                         ->group_end()
     */
     if (is_null($key) || $key == '') {
         $actor = 'no id : no name';
         \Event::fire('log.api', array($this->controller_name, 'post', $actor, 'empty key'));
         return \Response::json(array('status' => 'ERR:EMPTYKEY', 'timestamp' => time(), 'message' => 'Empty Key'));
     }
     $app = \Application::where('key', '=', $key)->first();
     if ($app) {
         $jsons = Input::json();
         $model = new \Shipment();
         $merchant_id = $app->merchant_id;
         $app_id = $app->id;
         $app_key = $app->key;
         $result = array();
         /*
         foreach ($jsons as $json) {
         
             $order = $this->ordermap;
         
             print_r($json);
         
         }
         
         die();
         */
         foreach ($jsons as $json) {
             //print_r($json);
             $order = $this->ordermap;
             if (isset($json['pick_up_date'])) {
                 if (is_array($json['pick_up_date']) && isset($json['pick_up_date']['sec'])) {
                     $pick_up_date = date('Y-m-d H:i:s', $json['pick_up_date']['sec']);
                 } else {
                     $pick_up_date = $json['pick_up_date'];
                 }
             } else {
                 $pick_up_date = date('Y-m-d H:i:s', time());
             }
             $codval = doubleval($json['cod']);
             //$codval = floor($codval * 100) / 100;
             $codval = round($codval, 0, PHP_ROUND_HALF_UP);
             $order['buyerdeliveryzone'] = isset($json['district']) ? $json['district'] : '';
             $order['merchant_trans_id'] = $json['no_sales_order'];
             $order['buyerdeliverytime'] = $pick_up_date;
             $order['fulfillment_code'] = $json['consignee_olshop_orderid'];
             $order['box_count'] = $json['number_of_package'];
             $order['delivery_type'] = trim($json['delivery_type']);
             $order['total_price'] = $codval;
             $order['email'] = $json['email'];
             $order['buyer_name'] = $json['consignee_olshop_name'];
             $order['recipient_name'] = $json['consignee_olshop_name'];
             $order['shipping_address'] = $json['consignee_olshop_addr'];
             $order['buyerdeliverycity'] = $json['consignee_olshop_city'];
             $order['shipping_zip'] = $json['consignee_olshop_zip'];
             $order['phone'] = $json['consignee_olshop_phone'];
             $order['delivery_bearer'] = 'merchant';
             $order['cod_bearer'] = 'merchant';
             $order['actual_weight'] = strval($json['w_v']);
             $weight = $json['w_v'];
             $delivery_type = trim($json['delivery_type']);
             $order['weight'] = \Prefs::get_weight_tariff($weight, $delivery_type, $app_id);
             $order['merchant_id'] = $merchant_id;
             $order['application_id'] = $app_id;
             $order['application_key'] = $app_key;
             $trx_detail = array();
             $trx_detail[0]['unit_description'] = $json['consignee_olshop_desc'];
             $trx_detail[0]['unit_price'] = $json['cod'];
             $trx_detail[0]['unit_quantity'] = 1;
             $trx_detail[0]['unit_total'] = $json['cod'];
             $trx_detail[0]['unit_discount'] = 0;
             $order['trx_detail'] = $trx_detail;
             $trx_id = $order['merchant_trans_id'];
             $trx = json_encode($order);
             $order['merchant_trans_id'] = $json['no_sales_order'];
             $order['fulfillment_code'] = $json['consignee_olshop_orderid'];
             $inlog = $json;
             $inlog['ts'] = new \MongoDate();
             unset($inlog['_id']);
             $inlog['merchant_api_id'] = $merchant_id;
             \Orderapilog::insert($inlog);
             $check = \Shipment::where('merchant_trans_id', '=', $json['no_sales_order'])->where('fulfillment_code', '=', $json['consignee_olshop_orderid'])->first();
             if ($check) {
                 $result[] = array('order_id' => $check->merchant_trans_id, 'ff_id' => $check->fulfillment_code, 'awb' => $check->delivery_id, 'timestamp' => $check->created, 'pickup_time' => $check->pickuptime, 'delivery_time' => $check->deliverytime, 'pending' => $check->pending_count, 'status' => $check->status, 'note' => $check->delivery_note);
             } else {
                 $saved = $this->order_save($trx, $app_key, $trx_id);
                 $result[] = array('order_id' => $saved['merchant_trans_id'], 'ff_id' => $saved['fulfillment_code'], 'awb' => $saved['delivery_id'], 'timestamp' => $saved['created'], 'pickup_time' => '0000-00-00 00:00:00', 'delivery_time' => '0000-00-00 00:00:00', 'pending' => $saved['pending_count'], 'status' => $saved['status'], 'note' => $saved['delivery_note']);
             }
             //$order[] = [w_v] => 0.9
             //$order[] = [awb] =>
             //$order[] = [consignee_olshop_service] => REG
             //$order[] = [position] => BPDU
             //$order[] = [updated_at] => 2015-11-24 16:44:25
             //$order[] = [created_at] => 2015-11-24 16:44:25
             //$order[] = [createdDate] => stdClass Object
             //$order[] = [lastUpdate] => stdClass Object
             //$order[] = [consignee_olshop_province] =>
             //$order[] = [trip] => 1
             //$order[] = [bucket] => incoming
             //$order[] = [order_id] => 100282527
             //$order[] = [fulfillment_code] => 249977
             //$order[] = [status] => confirmed
             //$order[] = [logistic_status] =>
             //$order[] = [pending_count] => 0
             //$order[] = [courier_status] => at_initial_node
             //$order[] = [warehouse_status] => at_initial_node
             //$order[] = [pickup_status] => to_be_picked_up
             //$order[] = [device_key] =>
             //$order[] = [device_name] =>
             //$order[] = [device_id] =>
             //$order[] = [courier_name] =>
             //$order[] = [courier_id] =>
         }
         /*
         buyerdeliverytime
         delivery_type
         buyer_name
         recipient_name
         shipping_address
         direction
         email
         mobile1
         mobile2
         phone
         weight
         package_description
         merchant_trans_id
         fulfillment_code
         logistic_awb
         total_price
         cod_bearer
         delivery_bearer
         buyerdeliveryzone
         buyerdeliverycity
         width
         height
         length
         box_count
         */
         //$result = $json;
         /*
                 (
         [_id] => 56543184ccae5b6112004278
         [district] =>
         [no_sales_order] => 100282527
         [pick_up_date] => stdClass Object
             (
                 [sec] => 1431104400
                 [usec] => 0
             )
         
         [consignee_olshop_orderid] => 249977
         [number_of_package] => 1
         [delivery_type] => REG
         [cod] => 0
         [email] => bagus_sulaiman@india.com
         [consignee_olshop_name] => 106191 bagus sulaiman
         [consignee_olshop_addr] => bagus sulaiman
             jl.bakti rt.004 rw.008 no.10b cililitan kramatjati 13640
             Jakarta Timur JK 13640
             Indonesia
         [consignee_olshop_city] => Jakarta Timur
         [consignee_olshop_region] => JK
         [consignee_olshop_zip] => 13640
         [consignee_olshop_phone] => 81317857612
         [contact] => 106191 bagus sulaiman
         [consignee_olshop_desc] => Susu dan Perlengkapan Bayi
         [w_v] => 0.9
         [awb] =>
         [consignee_olshop_cust] => 7735
         [consignee_olshop_service] => REG
         [position] => BPDU
         [updated_at] => 2015-11-24 16:44:25
         [created_at] => 2015-11-24 16:44:25
         [createdDate] => stdClass Object
             (
                 [sec] => 1448358276
                 [usec] => 411000
             )
         
         [lastUpdate] => stdClass Object
             (
                 [sec] => 1448358276
                 [usec] => 411000
             )
         
         [logistic] => JEX
         [logistic_type] => external
         [consignee_olshop_province] =>
         [trip] => 1
         [bucket] => incoming
         [delivery_id] => 24-112015-YAMYZ
         [order_id] => 100282527
         [fulfillment_code] => 249977
         [status] => confirmed
         [logistic_status] =>
         [pending_count] => 0
         [courier_status] => at_initial_node
         [warehouse_status] => at_initial_node
         [pickup_status] => to_be_picked_up
         [device_key] =>
         [device_name] =>
         [device_id] =>
         [courier_name] =>
         [courier_id] =>
                 )
         
         $awbs = $model->get();
         
         
         if($awbs){
             foreach($awbs as $awb){
                 $result[] = array(
                     'order_id'=>$awb->merchant_trans_id,
                     'ff_id'=>$awb->fulfillment_code,
                     'awb'=>$awb->delivery_id,
                     'timestamp'=>date('Y-m-d H:i:s',time()),
                     'pending'=>$awb->pending_count,
                     'status'=>$awb->status,
                     'note'=>$awb->delivery_note
                 );
             }
         }
         */
         //print_r($result);
         //die();
         /*
         foreach($jsons as $sheet_id=>$rows){
         
             $app_key = $app_entry[$sheet_id];
             $app_id = get_app_id_from_key($app_key);
         
             $order = $this->ordermap;
             foreach ($rows['data'] as $key => $line) {
                 if(in_array($key, $entry)){
         
                     $line['delivery_type'] = ($line['delivery_type'] == 'DO')?'Delivery Only':$line['delivery_type'];
                     $line['actual_weight'] = $line['weight'];
                     $line['weight'] = get_weight_tariff($line['weight'], $line['delivery_type'] ,$app_id);
         
                     $trx_detail = array();
                     $trx_detail[0]['unit_description'] = $line['package_description'];
                     $trx_detail[0]['unit_price'] = $line['total_price'];
                     $trx_detail[0]['unit_quantity'] = 1;
                     $trx_detail[0]['unit_total'] = $line['total_price'] ;
                     $trx_detail[0]['unit_discount'] = 0;
         
                     unset($line['package_description']);
                     unset($line['no']);
         
                     foreach($line as $k=>$v){
                         $order[$k] = $v;
                     }
         
                     $order['zip'] = '-';
         
                     $order['merchant_id'] = $merchant_id;
                     $order['application_id'] = $app_id;
                     $order['application_key'] = $app_key;
                     $order['trx_detail'] = $trx_detail;
         
                     $trx_id = 'TRX_'.$merchant_id.'_'.str_replace(array(' ','.'), '', microtime());
         
                     //print "order input: \r\n";
                     //print_r($order);
         
                     $trx = json_encode($order);
                     $result = $this->order_save($trx,$app_key,$trx_id);
         
                     //print $result;
         
                 }
         
             }
         
         }
         */
         $actor = $app->key . ' : ' . $app->merchant_id;
         \Event::fire('log.api', array($this->controller_name, 'post', $actor, 'order create array'));
         return Response::json($result);
     } else {
         $actor = 'no id : no name';
         \Event::fire('log.api', array($this->controller_name, 'post', $actor, 'account not found'));
         return \Response::json(array('status' => 'ERR:INVALIDACC', 'timestamp' => time(), 'message' => 'Invalid Account'));
     }
 }
Exemplo n.º 8
0
 public function postAllcurrentcalllist()
 {
     $ServiceResponse = new ServiceResponse();
     $CallDataProvider = new CallDataProvider();
     $serviceRequest = $this->GetObjectFromJsonRequest(Input::json()->all());
     $cUser = $this->GetSessionUser($serviceRequest->Token);
     if ($cUser->IsSuccess) {
         $ServiceResponse = $CallDataProvider->AllCurrentcalllist($serviceRequest->Data);
     } else {
         $ServiceResponse = $cUser;
     }
     return $this->GetJsonResponse($ServiceResponse);
 }
Exemplo n.º 9
0
 public function friendsHelpNeeded()
 {
     $input = Input::json();
     $facebookIDs = $input->get('idPlayers');
     $response = ['friends' => []];
     foreach ($facebookIDs as $fid) {
         $jugador = Jugador::where('idFacebook', '=', $fid)->first();
         if ($jugador) {
             $cantidadDerrotas = Puntaje::where('idPlayer', '=', $jugador->idPlayer)->where('defeated', '=', 1)->count();
             if ($cantidadDerrotas > $jugador->continues) {
                 $response['friends'][] = ['idPlayer' => $jugador->idPlayer, 'idFacebook' => $jugador->idFacebook];
             }
         }
     }
     return Response::json($response, 200);
 }
Exemplo n.º 10
0
 /**
 * Url:
 * /public/api/v1.0/update/bus/destination/{dropping_id}
 * 
 * Payload:
    {
        "params": {
            "buses_id": 27,
            "bus_departure_points_id": 5,
            "dropping_point": "Tada",
            "dropping_time": "9am",
            "price": "1003"
        }
    }
 */
 public function updateDroppingDetails(Request $request)
 {
     $data = Input::json()->all();
     $response = $this->response;
     $validateAndHandleError = new ValidateAndHandleError();
     if (!Auth::user()->id) {
         return $validateAndHandleError->invalidUser();
     }
     if (!$request->route('dropping_id')) {
         return $response->errorResponse("dropping_id_not_exist");
     }
     $dropping_id = $request->route('dropping_id');
     if (!isset($data) || !isset($data['params']) || !isset($data['params']['buses_id']) || !isset($data['params']['bus_departure_points_id']) || !isset($data['params']['dropping_point']) || !isset($data['params']['place_id']) || !isset($data['params']['dropping_time']) || !isset($data['params']['price'])) {
         return $response->errorResponse('invalid_params');
         //                return $validateAndHandleError->errorIdentifier("invalid_params");
     }
     $buses_id = $data['params']['buses_id'];
     $bus_departure_points_id = $data['params']['bus_departure_points_id'];
     $dropping_point = $data['params']['dropping_point'];
     $dropping_time = $data['params']['dropping_time'];
     $place_id = $data['params']['place_id'];
     $price = $data['params']['price'];
     /* Null validation */
     $validateNullData = array("buses_id" => $buses_id, "bus_departure_points_id" => $bus_departure_points_id, "dropping_point" => $dropping_point, "dropping_time" => $dropping_time, "price" => $price, "place_id" => $place_id);
     $nullValidator = $validateAndHandleError->multiValidator($validateNullData, "string");
     if ($nullValidator != "success") {
         return $nullValidator;
     }
     /* Bus id is number or not */
     $validateBusId = $validateAndHandleError->multiValidator(['buses_id' => $buses_id, 'dropping_id_not_number' => $dropping_id, 'place_id' => $place_id, 'departure_id_not_number' => $bus_departure_points_id], "number");
     if ($validateBusId != "success") {
         return $validateBusId;
     }
     $place = Place::where('id', $place_id)->get()[0]->place;
     if ($place != $dropping_point) {
         return $response->errorResponse('to_place_mismatch');
         //                return $validateAndHandleError->errorIdentifier("to_place_mismatch");
     }
     /* Validate dropping id present in db or not */
     $check_dropping_id = BusDroppingPoint::where('id', $dropping_id)->get();
     if (count($check_dropping_id) <= 0) {
         return $response->errorResponse("dropping_details_not_available");
     }
     /* for this dropping id check bus_id and departure id is matching or not */
     if ($check_dropping_id[0]->buses_id != $buses_id || $check_dropping_id[0]->bus_departure_points_id != $bus_departure_points_id) {
         return $response->errorResponse("bus_id_and_departure_id_mismatch");
     }
     /* Bus id exist or not */
     $check_bus_availability = Bus::where('id', $buses_id)->get();
     if (count($check_bus_availability) <= 0) {
         return $response->errorResponse("bus_details_not_available");
     }
     /* Departure id exist or not */
     $prev_departure_details = BusDeparturePoint::where('id', $bus_departure_points_id)->get();
     if (count($prev_departure_details) <= 0) {
         return $response->errorResponse('bus_departure_details_does_not_exist');
         //                return $validateAndHandleError->errorIdentifier("bus_departure_details_does_not_exist");
     }
     /* bus id passed through param should be equal with bus id of db */
     if ($prev_departure_details[0]->buses_id != $buses_id) {
         return $response->errorResponse('invalid_departure_details');
         //                return $validateAndHandleError->errorIdentifier("invalid_departure_details");
     }
     $user_id = Auth::user()->id;
     $bus_owners_id = $check_bus_availability[0]->bus_owners_id;
     /* $user_id_temp is used to check whether the details are accessible or not */
     $user_id_temp = BusOwner::where('id', $bus_owners_id)->get()[0]->user_id;
     $user_type = $validateAndHandleError->userIdentifier($user_id);
     /* details are only accessible by admin and bus owner */
     if ($user_type == "customer" || $user_type == "dealer" || $user_type == "unknown" || $user_type == "bus_owner" && $user_id_temp != $user_id) {
         return $response->errorResponse("details_not_accessible");
     }
     $is_dropping_details_updated = BusDroppingPoint::where('id', $dropping_id)->where('buses_id', $buses_id)->where('bus_departure_points_id', $bus_departure_points_id)->update(['dropping_point' => $dropping_point, 'dropping_time' => $dropping_time, 'price' => $price]);
     $info = array('bus_dropping_id' => $dropping_id, 'bus_id' => $buses_id, 'bus_owners_id' => $bus_owners_id, 'departure_id' => $bus_departure_points_id, 'dropping_point' => $dropping_point, 'dropping_time' => $dropping_time, 'price' => $price);
     if ($is_dropping_details_updated == 1) {
         return $response->successResponse(200, "Bus dropping details has been updated successully", $info);
     }
     return $response->errorResponse("update_unsuccessfull");
 }
Exemplo n.º 11
0
 public function postEnableGroup()
 {
     $serviceRequest = $this->GetObjectFromJsonRequest(Input::json()->all());
     $serviceResponse = $this->GroupDataProvider->EnableGroup($serviceRequest->Data);
     return $this->GetJsonResponse($serviceResponse);
 }
Exemplo n.º 12
0
 /**
  * Get the inputs as an array.
  *
  * @param bool $jsonInput JSON or not
  *
  * @return array
  */
 private static function inputsArray($jsonInput)
 {
     if ($jsonInput) {
         $inputs = Input::json();
     } else {
         $inputs = Input::all();
         // Don't send the token back
         unset($inputs['_token']);
         foreach ($inputs as $key => $value) {
             if (Input::file($key)) {
                 unset($inputs[$key]);
             }
         }
     }
     return $inputs;
 }
Exemplo n.º 13
0
 /**
  * @return array
  */
 public static function all()
 {
     return Request::isJson() ? Input::json()->all() : Input::all();
 }
Exemplo n.º 14
0
 public function submit()
 {
     $payload = Input::json();
     Log::info('payload: ' . var_export($payload, true));
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($questionId, $id)
 {
     return $this->model->update($id, Input::json()->all());
 }