random_key = rand(1001,5000); $this->date = Carbon::now()->format('Ymd'); $this->uri = new Uri(Config::get('app.cyware')); $this->url = Config::get('app.cyware'); } protected $url; protected $user = "APP"; protected $branch = "APP"; protected $cashier = "APP"; protected $entry_type = "APP"; protected $payment_type = "CC"; protected $item_code = "PREPAID"; protected $register_num = "1"; protected $dummy_transactions = false; protected $dummy_id_entry = false; protected $dummy_app_entry = false; protected $dummy_data_success = false; public $response; public $status_code; // generated private $random_key; private $date; private $card_number; private $uri; // user inputs private $called_function = ""; private $dummy_data = ""; private $first_name; private $last_name; private $birthday; private $mobile; private $email; private $address; private $pin; private $start_date; private $end_date; private $si_num; private $total_amount; private $civil_status_code; private $gender_code; private $occupation_code; private $number_cars; private $is_petron; private $is_phoenix; private $is_shell; private $is_flyingv; private $is_caltex; private $is_ptt; private $is_total; private $is_jetti; private $is_seaoil; private $is_sm; private $is_robinson; private $is_cebupacific; private $is_petronv; private $is_bdo; private $is_mabuhay; private $is_starbucks; // private $is_s&r; // this is to be checked r only private $snr; private $is_national; private $is_happy; private $is_mercury; private $fuel_type; private $vehicle_own; private $city_code; private $card_type_code; private $id_number; private $lcard_id; private $user_id; /** * @return mixed */ public function getOccupationCode() { return $this->occupation_code; } /** * @param mixed $occupation_code */ public function setOccupationCode($occupation_code): void { $this->occupation_code = $occupation_code; } /** * @return mixed */ public function getNumberCars() { return $this->number_cars; } /** * @param mixed $number_cars */ public function setNumberCars($number_cars): void { $this->number_cars = $number_cars; } /** * @return mixed */ public function getisPetron() { return $this->is_petron; } /** * @param mixed $is_petron */ public function setIsPetron($is_petron): void { $this->is_petron = $is_petron; } /** * @return mixed */ public function getisPhoenix() { return $this->is_phoenix; } /** * @param mixed $is_phoenix */ public function setIsPhoenix($is_phoenix): void { $this->is_phoenix = $is_phoenix; } /** * @return mixed */ public function getisShell() { return $this->is_shell; } /** * @param mixed $is_shell */ public function setIsShell($is_shell): void { $this->is_shell = $is_shell; } /** * @return mixed */ public function getisFlyingv() { return $this->is_flyingv; } /** * @param mixed $is_flyingv */ public function setIsFlyingv($is_flyingv): void { $this->is_flyingv = $is_flyingv; } /** * @return mixed */ public function getisCaltex() { return $this->is_caltex; } /** * @param mixed $is_caltex */ public function setIsCaltex($is_caltex): void { $this->is_caltex = $is_caltex; } /** * @return mixed */ public function getisPtt() { return $this->is_ptt; } /** * @param mixed $is_ptt */ public function setIsPtt($is_ptt): void { $this->is_ptt = $is_ptt; } /** * @return mixed */ public function getisTotal() { return $this->is_total; } /** * @param mixed $is_total */ public function setIsTotal($is_total): void { $this->is_total = $is_total; } /** * @return mixed */ public function getisJetti() { return $this->is_jetti; } /** * @param mixed $is_jetti */ public function setIsJetti($is_jetti): void { $this->is_jetti = $is_jetti; } /** * @return mixed */ public function getisSeaoil() { return $this->is_seaoil; } /** * @param mixed $is_seaoil */ public function setIsSeaoil($is_seaoil): void { $this->is_seaoil = $is_seaoil; } /** * @return mixed */ public function getisSm() { return $this->is_sm; } /** * @param mixed $is_sm */ public function setIsSm($is_sm): void { $this->is_sm = $is_sm; } /** * @return mixed */ public function getisRobinson() { return $this->is_robinson; } /** * @param mixed $is_robinson */ public function setIsRobinson($is_robinson): void { $this->is_robinson = $is_robinson; } /** * @return mixed */ public function getisCebupacific() { return $this->is_cebupacific; } /** * @param mixed $is_cebupacific */ public function setIsCebupacific($is_cebupacific): void { $this->is_cebupacific = $is_cebupacific; } /** * @return mixed */ public function getisPetronv() { return $this->is_petronv; } /** * @param mixed $is_petronv */ public function setIsPetronv($is_petronv): void { $this->is_petronv = $is_petronv; } /** * @return mixed */ public function getisBdo() { return $this->is_bdo; } /** * @param mixed $is_bdo */ public function setIsBdo($is_bdo): void { $this->is_bdo = $is_bdo; } /** * @return mixed */ public function getisMabuhay() { return $this->is_mabuhay; } /** * @param mixed $is_mabuhay */ public function setIsMabuhay($is_mabuhay): void { $this->is_mabuhay = $is_mabuhay; } /** * @return mixed */ public function getisStarbucks() { return $this->is_starbucks; } /** * @param mixed $is_starbucks */ public function setIsStarbucks($is_starbucks): void { $this->is_starbucks = $is_starbucks; } /** * @return mixed */ public function getSnr() { return $this->snr; } /** * @param mixed $r */ public function setR($snr): void { $this->snr = $snr; } /** * @return mixed */ public function getisNational() { return $this->is_national; } /** * @param mixed $is_national */ public function setIsNational($is_national): void { $this->is_national = $is_national; } /** * @return mixed */ public function getisHappy() { return $this->is_happy; } /** * @param mixed $is_happy */ public function setIsHappy($is_happy): void { $this->is_happy = $is_happy; } /** * @return mixed */ public function getisMercury() { return $this->is_mercury; } /** * @param mixed $is_mercury */ public function setIsMercury($is_mercury): void { $this->is_mercury = $is_mercury; } /** * @return mixed */ public function getFuelType() { return $this->fuel_type; } /** * @param mixed $fuel_type */ public function setFuelType($fuel_type): void { $this->fuel_type = $fuel_type; } /** * @return mixed */ public function getVehicleOwn() { return $this->vehicle_own; } /** * @param mixed $vehicle_own */ public function setVehicleOwn($vehicle_own): void { $this->vehicle_own = $vehicle_own; } /** * @return mixed */ public function getGenderCode() { return $this->gender_code; } /** * @param mixed $gender_code */ public function setGenderCode($gender_code): void { $this->gender_code = $gender_code; } /** * @return mixed */ public function getCivilStatusCode() { return $this->civil_status_code; } /** * @param mixed $civil_status_code */ public function setCivilStatusCode($civil_status_code): void { $this->civil_status_code = $civil_status_code; } /** * @return mixed */ public function getAddress() { return $this->address; } /** * @param mixed $address */ public function setAddress($address): void { $this->address = $address; } /** * @return string */ public function getPaymentType(): string { return $this->payment_type; } /** * @param string $payment_type */ public function setPaymentType(string $payment_type): void { $this->payment_type = $payment_type; } /** * @return string */ public function getItemCode(): string { return $this->item_code; } /** * @param string $item_code */ public function setItemCode(string $item_code): void { $this->item_code = $item_code; } /** * @return mixed */ public function getTotalAmount() { return $this->total_amount; } /** * @param mixed $total_amount */ public function setTotalAmount($total_amount): void { $this->total_amount = $total_amount; } /** * @return mixed */ public function getSiNum() { return $this->si_num; } /** * @param mixed $si_num */ public function setSiNum($si_num): void { $this->si_num = $si_num; } /** * @return string */ public function getRegisterNum(): string { return $this->register_num; } /** * @param string $register_num */ public function setRegisterNum(string $register_num): void { $this->register_num = $register_num; } /** * @return string */ public function getCashier(): string { return $this->cashier; } /** * @param string $cashier */ public function setCashier(string $cashier): void { $this->cashier = $cashier; } /** * @return string */ public function getEntryType(): string { return $this->entry_type; } /** * @param string $entry_type */ public function setEntryType(string $entry_type): void { $this->entry_type = $entry_type; } /** * @return mixed */ function setCardNumber($card_number) { $this->card_number = $card_number; } /** * @return mixed */ function getCardNumber() { return $this->card_number; } /** * @return mixed */ function setBirthday($birthday) { $this->birthday = $birthday; } /** * @return mixed */ function getBirthday() { return $this->birthday; } /** * @return mixed */ public function getStartDate() { return $this->start_date; } /** * @param mixed $start_date */ public function setStartDate($start_date): void { $this->start_date = $start_date; } /** * @return mixed */ public function getEndDate() { return $this->end_date; } /** * @param mixed $end_date */ public function setEndDate($end_date): void { $this->end_date = $end_date; } /** * @return mixed */ public function getBranch() { return $this->branch ?? 'APP'; } /** * @param mixed $branch */ public function setBranch($branch): void { $this->branch = $branch; } /** * @return mixed */ public function getPin() { return $this->pin; } /** * @param mixed $pin */ public function setPin($pin): void { $this->pin = $pin; } /** * @return mixed */ public function getFirstName() { return $this->first_name; } /** * @param mixed $first_name */ public function setFirstName($first_name): void { $this->first_name = $first_name; } /** * @return mixed */ public function getLastName() { return $this->last_name; } /** * @param mixed $last_name */ public function setLastName($last_name): void { $this->last_name = $last_name; } /** * @return mixed */ public function getMobile() { return $this->mobile; } /** * @param mixed $mobile */ public function setMobile($mobile): void { $this->mobile = $mobile; } /** * @return mixed */ public function getEmail() { return $this->email; } /** * @param mixed $email */ public function setEmail($email): void { $this->email = $email; } /** * @return mixed */ public function getCardTypeCode() { return $this->card_type_code; } /** * @param mixed $card_type_code */ public function setCardTypeCode($card_type_code): void { $this->card_type_code = $card_type_code; } /** * @return mixed */ public function getIDNumber() { return $this->id_number; } /** * @param mixed $id_number */ public function setIDNumber($id_number): void { $this->id_number = $id_number; } /** * @return mixed */ public function getLcardID() { return $this->lcard_id; } /** * @param mixed $id_number */ public function setLcardID($lcard_id): void { $this->lcard_id = $lcard_id; } /** * @return mixed */ public function getUserID() { return $this->user_id; } /** * @param mixed $id_number */ public function setUserID($user_id): void { $this->user_id = $user_id; } /** * @return mixed */ public function getCityCode() { return $this->city_code; } /** * @param mixed $mobile */ public function setCityCode($city_code): void { $this->city_code = $city_code; } public function create_request($params) { $client = new Client(); try{ $response = $client->request('GET', $this->url, [ 'query' => $params, 'http_errors' => false ]); $this->setResponse($response); // $request = $client->get($this->uri->withQuery(http_build_query($params))); // $this->setResponse($request); } catch (RequestException $e) { if ($e->hasResponse()) { $this->response = $e->getResponse()->getBody()->getContents(); } } } function setResponse($var) { // for dummy data $bypass = false; if( ($this->called_function == "state_trans" && $this->dummy_transactions == true) || ($this->called_function == "state_id_entry" && $this->dummy_id_entry == true) || ($this->called_function == "state_app_entry" && $this->dummy_app_entry == true) ) { $bypass = true; } $return = []; if($bypass == true || $var->getStatusCode() == '200') { if($bypass == true) $result = $this->dummy_data; else $result = json_decode($var->getBody()->getContents()); $return['data'] = null; if (isset($result->loyalty->status->sql)) { if ($result->loyalty->status->sql == 'success' ) { if ( isset($result->loyalty->data) ) { // dd($result->loyalty->data); if ( count($result->loyalty->data) == 1 ) { $return['data'] = $result->loyalty->data[0]; } else { $return['data'] = isset($result->loyalty->data) ? $result->loyalty->data : null; } $return['message'] = $result->loyalty->status->sql == 'success' ? 'Success' : $result->loyalty->status->result ; } else { // $return['message'] = $result->loyalty->status->sql == 'success' ? $result->loyalty->status->success : $result->loyalty->status->result ; $return['message'] = $result->loyalty->status->sql == 'success' ? $result->loyalty->status->sql : $result->loyalty->status->result ; // include other arrays in $result->loyalty->status $other = collect($result->loyalty->status); if(count($other) > 0) { foreach ($other as $k => $v) { if($k != 'sql') $return[$k] = $v; } } } } } else { $return['message'] = isset($result) ? $result->loyalty->status->result : null; } } else { $return['message'] = "Cyware Internal Server Error"; } $return['status_code'] = $bypass == true ? 200 : $var->getStatusCode(); $this->response = $return; } function setBadResponse($message) { $return['data'] = null; $return['message'] = $message; $return['status_code'] = "500"; $this->response = $return; } function getResponse() { return $this->response ?? null; } function validate_card_number($card_number){ if(strlen($card_number) == 0 ){ return false; } if(strlen($card_number) > 16 ){ return false; } if(!is_numeric($card_number) ){ return false; } return $card_number; } private function vendor_key(){ return md5('UPPI'.$this->card_number.$this->random_key.$this->date); } private function vendor_key_mobile(){ return md5('UPPI'.$this->mobile.$this->random_key.$this->date); } private function vendor_key_id_number(){ return md5('UPPI'.$this->id_number.$this->random_key.$this->date); } private function vendor_key_sign_up(){ return md5('UPPI'.$this->user_id.$this->random_key.$this->date); } public function state_validate() { if (!$this->validate_card_number($this->getCardNumber())){ $this->setBadResponse("Card Number is not valid"); return false; } // if (!$this->getBirthday()){ // $this->setBadResponse("Birthday is not valid"); // return false; // } $params = array( 'birthdate' => $this->getBirthday(), 'yyyymmdd' => $this->date, 'card_number'=> $this->getCardNumber(), 'random_key' => $this->random_key, 'vendor_key' => $this->vendor_key(), 'state' => 'state_validate' ); $this->create_request($params); } public function state_mobilevalidate() { $params = array( 'yyyymmdd' => $this->date, 'mobile_number' => $this->getMobile(), 'random_key' => $this->random_key, 'vendor_key' => $this->vendor_key_mobile(), 'state' => 'state_mobile' ); $this->create_request($params); } public function state_entry() { if (!$this->validate_card_number($this->getCardNumber())){ $this->setBadResponse("Card Number is not valid"); return false; } $params = array( 'first_name' => $this->getFirstName(), 'last_name' => $this->getLastName(), 'birthdate' => $this->getBirthday(), 'mobile' => $this->getMobile(), 'email' => $this->getEmail(), 'user' => $this->user, 'branch' => $this->getBranch(), 'card_number' => $this->getCardNumber(), 'pin' => $this->getPin(), 'yyyymmdd' => $this->date, 'random_key' => $this->random_key, 'vendor_key' => $this->vendor_key(), 'state' => 'state_entry' ); $this->create_request($params); } public function state_trans() { $this->called_function = "state_trans"; if(!$this->dummy_transactions) { if (!$this->validate_card_number($this->getCardNumber())){ $this->setBadResponse("Card Number is not valid"); return false; } if ($this->getStartDate() > $this->getEndDate() ){ $this->setBadResponse("Start Date is Greater than End Date"); return false; } $params = array( 'card_number' => $this->getCardNumber(), 'user' => $this->user, 'branch' => $this->getBranch(), 'start_date' => $this->getStartDate(), 'end_date' => $this->getEndDate(), 'yyyymmdd' => $this->date, 'random_key' => $this->random_key, 'vendor_key' => $this->vendor_key(), 'state' => 'state_trans' ); $this->create_request($params); } else { $this->dummy_data = $this->_get_state_trans_dummy($this->dummy_data_success); $this->setResponse([]); } } public function state_promo() { if (!$this->validate_card_number($this->getCardNumber())){ $this->setBadResponse("Card Number is not valid"); return false; } $params = array( 'card_number' => $this->getCardNumber(), 'yyyymmdd' => $this->date, 'random_key' => $this->random_key, 'vendor_key' => $this->vendor_key(), 'state' => 'state_promo' ); $this->create_request($params); } public function state_retrieve() { if (!$this->validate_card_number($this->getCardNumber())){ $this->setBadResponse("Card Number is not valid"); return false; } $params = array( 'card_number' => $this->getCardNumber(), 'yyyymmdd' => $this->date, 'random_key' => $this->random_key, 'vendor_key' => $this->vendor_key(), 'state' => 'state_retrieve' ); $this->create_request($params); } public function state_update() { if (!$this->validate_card_number($this->getCardNumber())){ $this->setBadResponse("Card Number is not valid"); return false; } if (!$this->validate_civil_status_code($this->getCivilStatusCode())){ $this->setBadResponse("Civil Status Code is not valid"); return false; } if (!$this->validate_gender_code($this->getGenderCode())){ $this->setBadResponse("Gender Code is not valid"); return false; } $params = array( 'card_number' => $this->getCardNumber(), 'user' => $this->user, 'branch' => $this->branch, 'first_name' => $this->getFirstName(), 'last_name' => $this->getLastName(), 'address' => $this->getAddress() . ($this->getCityCode() != '' ? $this->getCityCode() : ''), 'mobile' => $this->getMobile(), 'email' => $this->getEmail(), 'vehicle_own' => $this->getVehicleOwn(), 'fuel_type' => $this->getFuelType(), 'civil_status_code' => $this->getCivilStatusCode(), 'gender_code' => $this->getGenderCode(), 'occupation_code' => $this->getOccupationCode(), 'number_cars' => $this->getNumberCars(), 'is_petron' => $this->getisPetron(), 'is_phoenix' => $this->getisPhoenix(), 'is_shell' => $this->getisShell(), 'is_flyingv' => $this->getisFlyingv(), 'is_caltex' => $this->getisCaltex(), 'is_ptt' => $this->getisPtt(), 'is_total' => $this->getisTotal(), 'is_jetti' => $this->getisJetti(), 'is_seaoil' => $this->getisSeaoil(), 'is_sm' => $this->getisSm(), 'is_robinson' => $this->getisRobinson(), 'is_cebupacific' => $this->getisCebupacific(), 'is_petronv' => $this->getisPetronv(), 'is_bdo' => $this->getisBdo(), 'is_mabuhay' => $this->getisMabuhay(), 'is_starbucks' => $this->getisStarbucks(), 'is_s&r' => $this->getSnr(), 'is_national' => $this->getisNational(), 'is_happy' => $this->getisHappy(), 'is_mercury' => $this->getisMercury(), 'yyyymmdd' => $this->date, 'random_key' => $this->random_key, 'vendor_key' => $this->vendor_key(), 'state' => 'state_update' ); $this->create_request($params); } public function state_points() { if (!$this->validate_card_number($this->getCardNumber())){ $this->setBadResponse("Card Number is not valid"); return false; } $params = array( 'card_number' => $this->getCardNumber(), 'cashier' => $this->getCashier(), 'branch' => $this->getBranch(), 'entry_type' => $this->getEntryType(), 'register_num' => $this->getRegisterNum(), 'si_num' => $this->getSiNum(), 'total_amount' => $this->getTotalAmount(), 'payment_type' => $this->getPaymentType(), 'item_code' => $this->getItemCode(), 'yyyymmdd' => $this->date, 'random_key' => $this->random_key, 'vendor_key' => $this->vendor_key(), 'state' => 'state_points' ); // $client = new Client(); // $request = $client->get($this->uri->withQuery(http_build_query($params))); // $result = json_decode($request->getBody()->getContents()); // // dd($result); $this->create_request($params); } public function state_redeemed() { if (!$this->validate_card_number($this->getCardNumber())){ $this->setBadResponse("Card Number is not valid"); return false; } if ($this->getStartDate() > $this->getEndDate() ){ $this->setBadResponse("Start Date is Greater than End Date"); return false; } $params = array( 'card_number' => $this->getCardNumber(), 'start_date' => $this->getStartDate(), 'end_date' => $this->getEndDate(), 'yyyymmdd' => $this->date, 'random_key' => $this->random_key, 'vendor_key' => $this->vendor_key(), 'state' => 'state_redeemed' ); $this->create_request($params); } public function state_id_entry() { $this->called_function = "state_id_entry"; if(!$this->dummy_id_entry) { $params = array( 'card_type_code'=> $this->getCardTypeCode(), 'id_number' => $this->getIDNumber(), 'yyyymmdd' => $this->date, 'random_key' => $this->random_key, 'vendor_key' => $this->vendor_key_id_number(), 'state' => 'state_id_entry' ); $this->create_request($params); } else { $this->dummy_data = $this->_get_state_id_entry_dummy($this->dummy_data_success); $this->setResponse([]); } } public function state_app_entry() { $this->called_function = "state_app_entry"; if(!$this->dummy_app_entry) { $params = array( 'user' => $this->user, 'branch' => $this->getBranch(), 'card_type_code' => $this->getCardTypeCode(), 'user_id' => $this->getUserID(), // for confirmation 'first_name' => $this->getFirstName(), 'last_name' => $this->getLastName(), 'birthdate' => $this->getBirthday(), 'mobile' => $this->getMobile(), 'email' => $this->getEmail(), 'id_number' => $this->getIDNumber(), 'yyyymmdd' => $this->date, 'random_key' => $this->random_key, 'vendor_key' => $this->vendor_key_sign_up(), 'state' => 'state_app_entry' ); $this->create_request($params); } else { $this->dummy_data = $this->_get_state_app_entry_dummy($this->dummy_data_success); $this->setResponse([]); } } private function validate_civil_status_code($getCivilStatusCode) { $array = array( "S" => "SINGLE", "M" => "MARRIED", "0" => "NO DATA ENTERED", "W" => "WIDOW", "SE" => "SEPARATED", ); return $array[$getCivilStatusCode] ? true : false; } private function validate_gender_code($gender_code) { $array = array( "0"=>"NO DATA ENTERED", "M"=>"MALE", "F"=>"FEMALE", ); return $array[$gender_code] ? true : false; } //todo please remove validation on library. /* |======================================================================================= | DUMMY DATA |======================================================================================= */ private function _get_state_trans_dummy($success = true) { if($success) { $data = '{ "loyalty": { "status": { "rows": "0", "sql": "success", "result": "ok" }, "data": [ { "ref_num": "APP-190329000001.00", "store_id": "APP", "store_name": "APP", "date": "2019-03-03", "time": "0624", "trans_num": "'.$this->getLcardID().'0329000001.00", "reward_code": "SHARED", "reward_desc": "SHARED", "total_amount": "1.00", "total_points": "1.00", "items": [ { "item_code": "G00000001012", "item_desc": "Beef Bowl", "qty": "1.00", "price": "1.00" } ] }, { "ref_num": "1032-310838", "store_id": "1032", "store_name": "UNIOIL MINDANAO AVENUE 1", "date": "2019-03-02", "time": "1029", "entry_type_code": "BP2", "entry_type_desc": "BONUS POINTS LEVEL 2", "trans_num": "'.$this->getLcardID().'310838", "total_amount": "1000000", "total_points": "100.00", "items": [ { "item_code": "SAMPLE", "item_desc": "sample", "qty": "1", "price": "1000000" } ] }, { "ref_num": "1032-255345", "store_id": "1032", "store_name": "UNIOIL MINDANAO AVENUE 1", "date": "2019-03-04", "time": "1431", "entry_type_code": "1", "entry_type_desc": "POS", "trans_num": "'.$this->getLcardID().'255345", "total_amount": "2600.01", "total_points": "13.00", "items": [ { "item_code": "ID944070", "item_desc": "ID SN/CF 5W-40 FS (24X1)", "qty": "1.00", "price": "650.00" }, { "item_code": "ID944070", "item_desc": "ID SN/CF 5W-40 FS (24X1)", "qty": "1.00", "price": "650.00" }, { "item_code": "ID944070", "item_desc": "ID SN/CF 5W-40 FS (24X1)", "qty": "1.00", "price": "650.00" }, { "item_code": "ID944070", "item_desc": "ID SN/CF 5W-40 FS (24X1)", "qty": "1.00", "price": "650.00" }, { "item_code": "FAD 17LOTUSEVORAS", "item_desc": "(FREE) LOTUS EVORA S", "qty": "1.00", "price": "0.01" } ] } ] } }'; } else { $data = '{ "loyalty": { "status": { "rows": "0", "No Records Found": "No Records Found", "result": "No Records Found" } } }'; } return json_decode($data); } private function _get_state_id_entry_dummy($success = true) { if($success) { $data = '{ "loyalty": { "status": { "rows": "1", "sql": "success", "result ": "Valid ID Number" } } }'; } else { $data = '{ "loyalty": { "status": { "rows": "0", " card_type_code": "card_type_code ", "result": "Invalid Card Type " } } }'; } return json_decode($data); } private function _get_state_app_entry_dummy($success = true) { if($success) { $data = '{ "loyalty": { "status": { "rows": "1", "sql": "success", "card_number": "11000000000'.StringHelper::random_num(5).'", "pin": "'.StringHelper::random_num(8).'" } } }'; } else { $data = '{ "loyalty": { "status": { "rows": "0", " birthdate": " birthdate ", "result": "Invalid birthdate" } } }'; } return json_decode($data); } }