demo) return "https://ondemand-stageapi.glovoapp.com/"; else return "https://ondemand-api.glovoapp.com/"; } function getAuthToken(){ $req = new TnxRequest( [ CURLOPT_RETURNTRANSFER => true, CURLOPT_URL => $this->baseUrl()."oauth/token", CURLOPT_POSTFIELDS => json_encode([ "grantType" => "client_credentials", "clientId" => $this->clientId, "clientSecret" => $this->clientSecret, ]), CURLOPT_HTTPHEADER => [ "Content-Type: application/json" ] ], [ // 'debug' => true, ] ); $ret = json_decode($req->exec()); $this->authToken = $ret->accessToken; return $this->authToken; } function getOrder($trackingNumber){ if(!$this->authToken && !$this->getAuthToken()) return false; $req = new TnxRequest( [ CURLOPT_RETURNTRANSFER => true, CURLOPT_URL => $this->baseUrl()."v2/laas/parcels/$trackingNumber", CURLOPT_HTTPHEADER => [ "Content-Type: application/json", "Authorization: Bearer ".$this->authToken ] ], [ 'debug' => true, ] ); return json_decode($req->exec()); } function createOrder($data){ if(!$this->authToken && !$this->getAuthToken()) return false; $req = new TnxRequest( [ CURLOPT_RETURNTRANSFER => true, CURLOPT_URL => $this->baseUrl()."v2/laas/parcels", CURLOPT_POSTFIELDS => json_encode($data), CURLOPT_HTTPHEADER => [ "Content-Type: application/json", "Authorization: Bearer ".$this->authToken ] ], [ // 'debug' => true, ] ); // die(json_encode($data)."

".$req->exec()); return json_decode($req->exec()); //https://logistics-docs.glovoapp.com/laas-partners/index.html#tag/Order-management-V2 // { // "address": { // "cityName": "Barcelona", // "country": "Spain", // "postalCode": "30123", // "rawAddress": "Calle Oporto 2, 30123, Barcelona, Spain", // "details": "2nd door at the left of the elevator.", // "streetName": "Calle Oporto", // "streetNumber": "2", // "coordinates": { // "latitude": 41.47155, // "longitude": 2.011038 // } // }, // "contact": { // "email": "recipient@email.com", // "name": "Juan Namba", // "phone": "+346666666666" // }, // "packageDetails": { // "contentType": "FOOD", // "description": "Burgers and fries", // "parcelValue": 50, // "weight": 1 // }, // "packageId": "string", // "pickupDetails": { // "address": { // "cityName": "Barcelona", // "country": "Spain", // "postalCode": "30123", // "rawAddress": "Calle Oporto 2, 30123, Barcelona, Spain", // "details": "Additional information", // "streetName": "Calle Oporto", // "streetNumber": "2", // "coordinates": { // "latitude": 41.47155, // "longitude": 2.011038 // } // }, // "addressBook": { // "id": "00000000-0000-0000-0000-000000000000" // }, // "pickupOrderCode": "857", // "pickupTime": "2019-08-24T14:15:22Z", // "pickupPhone": "+34666666666" // }, // "price": { // "paymentType": "CASH_ON_DELIVERY", // "delivery": { // "currencyCode": "EUR", // "value": 5.5 // }, // "parcel": { // "currencyCode": "EUR", // "value": 5.5 // } // } // } } } ?>