### Create Sameday Service Instance in PHP Source: https://github.com/sameday-courier/php-sdk/blob/master/docs/getting_started.md After initializing the `SamedayClient`, create a `SamedaySameday` service instance. This service aggregates all the SDK components for easier use. ```php $sameday = new SamedaySameday($samedayClient); ``` -------------------------------- ### Get Sameday Courier Services (PHP) Source: https://github.com/sameday-courier/php-sdk/blob/master/docs/getting_started.md This snippet shows how to initialize the Sameday Courier client and retrieve available services using a GET request. It includes error handling for both server-side and SDK-specific exceptions. ```php $samedayClient = new Sameday\SamedayClient(/* . . . */); $sameday = new Sameday\Sameday($samedayClient); try { // Get services for delivery. $sameday->getServices(new \Sameday\Requests\SamedayGetServicesRequest()); } catch (\Sameday\Exceptions\SamedayServerException $e) { // When server returns an error. echo 'Server returned an error: ' . $e->getMessage(); exit; } catch (\Sameday\Exceptions\SamedaySDKException $e) { // When validation fails or other local issues. echo 'Sameday SDK returned an error: ' . $e->getMessage(); exit; } ``` -------------------------------- ### Get Sameday Courier Pickup Points in PHP Source: https://context7.com/sameday-courier/php-sdk/llms.txt Provides a PHP code example for fetching configured pickup points associated with a client account using the Sameday SDK. It demonstrates setting pagination, iterating through pickup points to display details like ID, alias, address, and contact persons, and includes error handling for authentication failures. ```php setPage(1); $request->setCountPerPage(20); $response = $sameday->getPickupPoints($request); foreach ($response->getPickupPoints() as $pickupPoint) { echo "Pickup Point ID: " . $pickupPoint->getId() . "\n"; echo "Alias: " . $pickupPoint->getAlias() . "\n"; echo "County: " . $pickupPoint->getCounty()->getName() . "\n"; echo "City: " . $pickupPoint->getCity()->getName() . "\n"; echo "Address: " . $pickupPoint->getAddress() . "\n"; echo "Is Default: " . ($pickupPoint->isDefault() ? 'Yes' : 'No') . "\n"; // Get contact persons for this pickup point foreach ($pickupPoint->getContactPersons() as $contact) { echo " Contact: " . $contact->getName() . "\n"; echo " Phone: " . $contact->getPhone() . "\n"; echo " Is Default: " . ($contact->isDefault() ? 'Yes' : 'No') . "\n"; } } // Cache the first pickup point ID for AWB creation $pickupPointId = $response->getPickupPoints()[0]->getId(); } catch (\Sameday\Exceptions\SamedayAuthenticationException $e) { echo "Authentication failed: " . $e->getMessage(); } ``` -------------------------------- ### Initialize SamedayClient in PHP Source: https://github.com/sameday-courier/php-sdk/blob/master/docs/getting_started.md To interact with the Sameday Courier API, you need to initialize the `SamedayClient` service with your user credentials. Replace '{user}' and '{password}' with your actual credentials. ```php $samedayClient = new SamedaySamedayClient('{user}', '{password}'); ``` -------------------------------- ### Manually Include SDK Autoloader in PHP Source: https://github.com/sameday-courier/php-sdk/blob/master/docs/getting_started.md If you are unable to use Composer, you can manually install the SDK by downloading the source files. This code snippet shows how to include the SDK's autoloader. ```php require_once __DIR__ . '/path/to/php-sdk/src/Sameday/autoload.php'; ``` -------------------------------- ### Include Composer Autoloader in PHP Source: https://github.com/sameday-courier/php-sdk/blob/master/docs/getting_started.md After installing the SDK with Composer, you need to include the Composer autoloader in your PHP script to enable automatic class loading. ```php require_once __DIR__ . '/vendor/autoload.php'; ``` -------------------------------- ### Manually Include SDK with Defined Source Directory Source: https://github.com/sameday-courier/php-sdk/blob/master/docs/getting_started.md In cases where the SDK autoloader has trouble detecting the source file path, you can explicitly define the source directory using a constant before including the autoloader. ```php define('SAMEDAY_PHP_SDK_SRC_DIR', __DIR__ . '/sameday-php-sdk/'); require_once __DIR__ . '/sameday-php-sdk/autoload.php'; ``` -------------------------------- ### Install Sameday Courier SDK via Composer Source: https://github.com/sameday-courier/php-sdk/blob/master/README.md Use the Composer package manager to add the Sameday Courier SDK dependency to your PHP project. ```bash composer require sameday-courier/php-sdk ``` -------------------------------- ### GET /pickup-points Source: https://github.com/sameday-courier/php-sdk/blob/master/docs/reference/SamedayGetPickupPointsResponse.md Retrieves a paginated list of available pickup points for the Sameday courier service. ```APIDOC ## GET /pickup-points ### Description Retrieves a list of available pickup points. The response is paginated and returns an array of PickupPointObject entities. ### Method GET ### Endpoint /pickup-points ### Parameters #### Query Parameters - **page** (integer) - Optional - The page number to retrieve. - **limit** (integer) - Optional - The number of results per page. ### Request Example GET /pickup-points?page=1&limit=10 ### Response #### Success Response (200) - **pickupPoints** (array) - An array of Sameday\Objects\PickupPoint\PickupPointObject entities. #### Response Example { "pickupPoints": [ { "id": "PP001", "name": "Main Street Locker", "address": "123 Main St, City" } ] } ``` -------------------------------- ### Get Available Sameday Courier Services in PHP Source: https://context7.com/sameday-courier/php-sdk/llms.txt Shows how to retrieve a list of available delivery services using the Sameday SDK for PHP. It includes setting pagination options and iterating through the response to access service details like ID, name, code, delivery types, and optional taxes. Error handling for API exceptions is also demonstrated. ```php setPage(1); $request->setCountPerPage(50); $response = $sameday->getServices($request); // Access service data foreach ($response->getServices() as $service) { echo "Service ID: " . $service->getId() . "\n"; echo "Service Name: " . $service->getName() . "\n"; echo "Service Code: " . $service->getCode() . "\n"; // Get delivery types for this service foreach ($service->getDeliveryTypes() as $deliveryType) { echo " Delivery Type ID: " . $deliveryType->getId() . "\n"; } // Get optional taxes/services foreach ($service->getOptionalTaxes() as $tax) { echo " Optional Tax: " . $tax->getName() . "\n"; } } // Pagination info echo "Total Services: " . $response->getTotalCount() . "\n"; echo "Current Page: " . $response->getCurrentPage() . "\n"; } catch (\Sameday\Exceptions\SamedayServerException $e) { echo "Server error: " . $e->getMessage(); } ``` -------------------------------- ### Perform API Operations with Sameday Service Source: https://github.com/sameday-courier/php-sdk/blob/master/docs/reference/Sameday.md Examples of common API operations including fetching available services, retrieving pickup points, and deleting an AWB using specific request objects. ```php // Get services for current user. $services = $sameday->getServices(new Sameday\Requests\SamedayGetServicesRequest()); // Get pickup points for current user. $response = $sameday->getPickupPoints(new Sameday\Requests\SamedayGetPickupPointsRequest()); // Delete an AWB. $response = $sameday->deleteAwb(new Sameday\Requests\SamedayDeleteAwbRequest('{awb_number}')); ``` -------------------------------- ### GET /lockers Source: https://context7.com/sameday-courier/php-sdk/llms.txt Retrieves the list of available parcel lockers (easybox) for locker delivery services. ```APIDOC ## GET /lockers ### Description Retrieves a list of all available parcel lockers (easybox) including their location details and available box sizes. ### Method GET ### Endpoint /lockers ### Response #### Success Response (200) - **lockers** (array) - List of locker objects containing ID, name, address, city, county, latitude, longitude, and box availability. #### Response Example { "lockers": [ { "id": "123", "name": "Easybox Location", "address": "Street Name 1", "city": "Bucharest", "boxes": [{"type": "small", "count": 5}] } ] } ``` -------------------------------- ### GET /status-sync Source: https://context7.com/sameday-courier/php-sdk/llms.txt Retrieves all status updates that occurred between two timestamps for batch processing. ```APIDOC ## GET /status-sync ### Description Retrieves all status updates that occurred between two timestamps. Useful for batch processing and keeping local order status synchronized. ### Method GET ### Endpoint /status-sync ### Parameters #### Query Parameters - **startDate** (timestamp) - Required - Start of the sync window - **endDate** (timestamp) - Required - End of the sync window - **page** (integer) - Optional - Page number for pagination - **countPerPage** (integer) - Optional - Number of records per page ### Response #### Success Response (200) - **statuses** (array) - List of status update objects containing AWB number, parcel AWB, status name, status ID, and date. - **totalCount** (integer) - Total number of updates found. #### Response Example { "statuses": [ { "awbNumber": "123456789", "status": {"id": 1, "name": "Delivered"}, "date": "2023-10-27 10:00:00" } ], "totalCount": 1 } ``` -------------------------------- ### GET /counties Source: https://github.com/sameday-courier/php-sdk/blob/master/docs/reference/SamedayGetCountiesRequest.md Retrieves a paginated list of available counties, with optional filtering by name. ```APIDOC ## GET /counties ### Description Retrieves a list of available counties from the Sameday Courier service. Supports pagination and name-based filtering. ### Method GET ### Endpoint /counties ### Parameters #### Query Parameters - **name** (string) - Optional - Filter results by county name. - **page** (int) - Optional - The page number to retrieve. - **countPerPage** (int) - Optional - The number of elements to retrieve per page. ### Request Example GET /counties?name=Bucuresti&page=1&countPerPage=20 ### Response #### Success Response (200) - **counties** (array) - List of county objects. - **total** (int) - Total number of counties available. #### Response Example { "counties": [ { "id": "1", "name": "Bucuresti" } ], "total": 1 } ``` -------------------------------- ### GET /awb/{awbNumber}/status-history Source: https://github.com/sameday-courier/php-sdk/blob/master/docs/reference/SamedayGetAwbStatusHistoryResponse.md Retrieves the complete status history and tracking details for a specific AWB number. ```APIDOC ## GET /awb/{awbNumber}/status-history ### Description Retrieves the status history, expedition status, and parcel information for a given AWB. ### Method GET ### Endpoint /awb/{awbNumber}/status-history ### Parameters #### Path Parameters - **awbNumber** (string) - Required - The unique AWB tracking number. ### Request Example GET /awb/123456789/status-history ### Response #### Success Response (200) - **summary** (SummaryObject) - The summary of the AWB status. - **history** (HistoryObject[]) - Array of status history events. - **expeditionStatus** (ExpeditionObject) - The current expedition status. - **parcels** (ParcelObject[]) - List of parcels associated with the AWB. #### Response Example { "summary": { "status": "delivered" }, "history": [ { "date": "2023-10-01", "status": "in_transit" } ], "expeditionStatus": { "id": 1 }, "parcels": [ { "id": "P1" }] } ``` -------------------------------- ### Get Available Parcel Lockers (PHP) Source: https://context7.com/sameday-courier/php-sdk/llms.txt Retrieves a list of available parcel lockers (easybox) for locker delivery services. This function iterates through the response to display locker details and available box sizes. It requires an initialized Sameday client and handles potential server exceptions. ```php getLockers($lockersRequest); foreach ($lockersResponse->getLockers() as $locker) { echo "Locker ID: " . $locker->getId() . "\n"; echo "Name: " . $locker->getName() . "\n"; echo "Address: " . $locker->getAddress() . "\n"; echo "City: " . $locker->getCity() . "\n"; echo "County: " . $locker->getCounty() . "\n"; echo "Latitude: " . $locker->getLat() . "\n"; echo "Longitude: " . $locker->getLong() . "\n"; // Check available box sizes foreach ($locker->getBoxes() as $box) { echo " Box Type: " . $box->getType() . " - Available: " . $box->getCount() . "\n"; } } } catch (SamedayExceptionsSamedayServerException $e) { echo "Error fetching lockers: " . $e->getMessage(); } ``` -------------------------------- ### Synchronize Status Updates (PHP) Source: https://context7.com/sameday-courier/php-sdk/llms.txt Retrieves all status updates between two specified timestamps, ideal for batch processing and synchronizing local order statuses. It requires a Sameday client, start and end dates (as timestamps), and allows setting pagination for the results. Handles bad request exceptions for invalid date ranges. ```php modify('-24 hours'); $endDate = new DateTime(); $syncRequest = new SamedayRequestsSamedayGetStatusSyncRequest( $startDate->getTimestamp(), $endDate->getTimestamp() ); $syncRequest->setPage(1); $syncRequest->setCountPerPage(100); $syncResponse = $sameday->getStatusSync($syncRequest); foreach ($syncResponse->getStatuses() as $status) { echo "AWB: " . $status->getAwbNumber() . "\n"; echo "Parcel AWB: " . $status->getParcelAwbNumber() . "\n"; echo "Status: " . $status->getStatus()->getName() . "\n"; echo "Status ID: " . $status->getStatus()->getId() . "\n"; echo "Date: " . $status->getDate()->format('Y-m-d H:i:s') . "\n"; echo "---\n"; } echo "Total updates: " . $syncResponse->getTotalCount() . "\n"; } catch (SamedayExceptionsSamedayBadRequestException $e) { echo "Invalid date range: " . $e->getMessage(); } ``` -------------------------------- ### Get Status Updates - PHP Source: https://github.com/sameday-courier/php-sdk/blob/master/docs/reference/SamedayGetStatusSyncResponse.md Retrieves an array of status update objects from a Sameday API response. This method is part of the SamedayGetStatusSyncResponse class and is used to access the paginated status data. ```php getStatuses(); foreach ($statuses as $status) { // Process each status object echo "Status ID: " . $status->getId() . "\n"; echo "Timestamp: " . $status->getTimestamp() . "\n"; // ... other properties } ``` -------------------------------- ### Instantiate Sameday Service Source: https://github.com/sameday-courier/php-sdk/blob/master/docs/reference/Sameday.md Demonstrates how to initialize the Sameday service class by injecting a client implementation that adheres to the SamedayClientInterface. ```php $sameday = new Sameday\Sameday($samedayClient); ``` -------------------------------- ### Initialize Client and Generate AWB in PHP Source: https://github.com/sameday-courier/php-sdk/blob/master/README.md Demonstrates how to initialize the Sameday client, retrieve available pickup points and services, create a new AWB request, and download the resulting PDF. ```php require_once __DIR__ . '/vendor/autoload.php'; $samedayClient = new \Sameday\SamedayClient('user', 'password'); $sameday = new \Sameday\Sameday($samedayClient); $pickupPoints = $sameday->getPickupPoints(new \Sameday\Requests\SamedayGetPickupPointsRequest()); $pickupPointId = $pickupPoints->getPickupPoints()[0]->getId(); $services = $sameday->getServices(new \Sameday\Requests\SamedayGetServicesRequest()); $serviceId = $services->getServices()[0]->getId(); try { $awb = $sameday->postAwb(new \Sameday\Requests\SamedayPostAwbRequest( $pickupPointId, null, new \Sameday\Objects\Types\PackageType(\Sameday\Objects\Types\PackageType::PARCEL), [ new \Sameday\Objects\ParcelDimensionsObject(0.5), new \Sameday\Objects\ParcelDimensionsObject(3, 15, 28, 67) ], $serviceId, new \Sameday\Objects\Types\AwbPaymentType(\Sameday\Objects\Types\AwbPaymentType::CLIENT), new \Sameday\Objects\PostAwb\Request\AwbRecipientEntityObject('Huedin', 'Cluj', 'str. Otesani', 'Nume Destinatar', '0700111111', 'destinatar.colet@gmail.com', new \Sameday\Objects\PostAwb\Request\CompanyEntityObject('nume companie SRL')), 0, 100 )); } catch (\Sameday\Exceptions\SamedayBadRequestException $e) { var_dump($e->getErrors()); exit; } $pdf = $sameday->getAwbPdf(new \Sameday\Requests\SamedayGetAwbPdfRequest($awb->getAwbNumber(), new \Sameday\Objects\Types\AwbPdfType(\Sameday\Objects\Types\AwbPdfType::A6))); echo $pdf->getPdf(); ``` -------------------------------- ### Initialize Sameday Courier SDK Client in PHP Source: https://context7.com/sameday-courier/php-sdk/llms.txt Demonstrates how to initialize the SamedayClient for the PHP SDK. It covers basic initialization with production or demo APIs, as well as advanced configuration with custom HTTP clients (Guzzle, cURL, stream) and token storage (session, memory). ```php setReference('ORDER-2024-001'); $awbRequest->setObservation('Handle with care'); $awbRequest->setClientObservation('Gift package'); $awbResponse = $sameday->postAwb($awbRequest); echo "AWB Number: " . $awbResponse->getAwbNumber() . "\n"; echo "Shipping Cost: " . $awbResponse->getCost() . " RON\n"; } catch (\Sameday\Exceptions\SamedayBadRequestException $e) { foreach ($e->getErrors() as $field => $errors) { echo " $field: " . implode(', ', $errors) . "\n"; } } catch (\Sameday\Exceptions\SamedayServerException $e) { echo "Server error: " . $e->getMessage(); } ``` -------------------------------- ### Retrieve Counties and Cities using PHP Source: https://context7.com/sameday-courier/php-sdk/llms.txt Fetches lists of counties and cities, useful for address validation and building selection forms. ```php $sameday = new \Sameday\Sameday($samedayClient); // Get all counties $countiesRequest = new \Sameday\Requests\SamedayGetCountiesRequest(); $countiesRequest->setPage(1); $countiesRequest->setCountPerPage(50); $countiesResponse = $sameday->getCounties($countiesRequest); foreach ($countiesResponse->getCounties() as $county) { echo "County ID: " . $county->getId() . " - " . $county->getName() . "\n"; } // Get cities filtered by county $citiesRequest = new \Sameday\Requests\SamedayGetCitiesRequest( 12, // County ID filter null, // Name filter (optional) null // Postal code filter (optional) ); $citiesRequest->setPage(1); $citiesRequest->setCountPerPage(100); $citiesResponse = $sameday->getCities($citiesRequest); foreach ($citiesResponse->getCities() as $city) { echo "City: " . $city->getName() . " (ID: " . $city->getId() . ")\n"; echo " Postal Code: " . $city->getPostalCode() . "\n"; } ``` -------------------------------- ### Calculate Shipping Cost Estimation with Sameday PHP SDK Source: https://context7.com/sameday-courier/php-sdk/llms.txt Shows how to request a shipping cost estimate before finalizing an order. This is useful for checkout pages to provide users with accurate shipping fees based on parcel weight and destination. ```php $sameday = new \Sameday\Sameday($samedayClient); try { $recipient = new \Sameday\Objects\PostAwb\Request\AwbRecipientEntityObject( 'Cluj-Napoca', 'Cluj', 'Str. Test nr. 1', 'Test Recipient', '0722222222', 'test@example.com' ); $parcels = [ new \Sameday\Objects\ParcelDimensionsObject(5.0, 40, 50, 30) ]; $estimationRequest = new \Sameday\Requests\SamedayPostAwbEstimationRequest( $pickupPointId, null, new \Sameday\Objects\Types\PackageType(\Sameday\Objects\Types\PackageType::PARCEL), $parcels, $serviceId, new \Sameday\Objects\Types\AwbPaymentType(\Sameday\Objects\Types\AwbPaymentType::CLIENT), $recipient, 1000.0, 500.0 ); $estimation = $sameday->postAwbEstimation($estimationRequest); echo "Estimated Cost: " . $estimation->getCost() . " RON\n"; echo "Currency: " . $estimation->getCurrency() . "\n"; } catch (\Sameday\Exceptions\SamedayBadRequestException $e) { echo "Invalid request: " . $e->getMessage(); } ``` -------------------------------- ### Set Pagination for Pickup Points Request (PHP) Source: https://github.com/sameday-courier/php-sdk/blob/master/docs/reference/SamedayGetPickupPointsRequest.md This snippet demonstrates how to set pagination parameters for retrieving pickup points using the Sameday SDK. It utilizes the setPage and setCountPerPage methods to control the paginated results. ```php setPage(1); // Set the desired page number $request->setCountPerPage(50); // Set the number of items per page // The $request object is now configured for a paginated pickup points retrieval. // You would typically pass this object to a Sameday client method. ?> ``` -------------------------------- ### Complete Error Handling with Sameday SDK Exceptions (PHP) Source: https://context7.com/sameday-courier/php-sdk/llms.txt Demonstrates comprehensive error handling using specific exception types provided by the Sameday SDK. This allows for precise management of various error scenarios, including authentication, authorization, bad requests, not found resources, server errors, and SDK-internal issues. Each catch block handles a different type of Sameday SDK exception. ```php postAwb($awbRequest); } catch (SamedayExceptionsSamedayAuthenticationException $e) { // Invalid credentials error_log("Auth failed: " . $e->getMessage()); } catch (SamedayExceptionsSamedayAuthorizationException $e) { // Insufficient permissions error_log("Unauthorized: " . $e->getMessage()); } catch (SamedayExceptionsSamedayBadRequestException $e) { // Validation errors echo "Validation failed:\n"; foreach ($e->getErrors() as $field => $messages) { echo " {$field}: " . implode(', ', (array)$messages) . "\n"; } } catch (SamedayExceptionsSamedayNotFoundException $e) { // Resource not found (AWB, pickup point, etc.) echo "Not found: " . $e->getMessage(); } catch (SamedayExceptionsSamedayServerException $e) { // Server-side error error_log("Server error: " . $e->getMessage()); } catch (SamedayExceptionsSamedayOtherException $e) { // Unknown HTTP status code error_log("Unknown error: " . $e->getMessage()); } catch (SamedayExceptionsSamedaySDKException $e) { // SDK internal error error_log("SDK error: " . $e->getMessage()); } ``` -------------------------------- ### Download AWB PDF Label using PHP Source: https://context7.com/sameday-courier/php-sdk/llms.txt Retrieves and saves or outputs a printable PDF label for a specific AWB. Supports A4 and A6 formats. ```php $sameday = new \Sameday\Sameday($samedayClient); try { $awbNumber = '1SD123456789'; // Get A6 format (standard shipping label size) $pdfRequest = new \Sameday\Requests\SamedayGetAwbPdfRequest( $awbNumber, new \Sameday\Objects\Types\AwbPdfType(\Sameday\Objects\Types\AwbPdfType::A6) ); $pdfResponse = $sameday->getAwbPdf($pdfRequest); // Save to file file_put_contents("awb_label_{$awbNumber}.pdf", $pdfResponse->getPdf()); echo "PDF saved successfully\n"; // Or output directly to browser header('Content-Type: application/pdf'); header('Content-Disposition: attachment; filename="awb_label.pdf"'); echo $pdfResponse->getPdf(); } catch (\Sameday\Exceptions\SamedayNotFoundException $e) { echo "AWB not found: " . $e->getMessage(); } ``` -------------------------------- ### SamedayGetAwbPdfResponse Source: https://github.com/sameday-courier/php-sdk/blob/master/docs/reference/SamedayGetAwbPdfResponse.md This entity represents a response to download a PDF for an existing AWB. It provides a method to retrieve the PDF content. ```APIDOC ## Sameday\Responses\SamedayGetAwbPdfResponse ### Description This entity represents a response to download a PDF for an existing AWB. It provides a method to retrieve the PDF content. ### Public Methods #### `string getPdf()` ##### Description Get the content of the PDF file. ##### Method `getPdf()` ##### Return Type `string` - The content of the PDF file. ##### Example ```php // Assuming $response is an instance of SamedayGetAwbPdfResponse $pdfContent = $response->getPdf(); header('Content-Type: application/pdf'); echo $pdfContent; ``` ``` -------------------------------- ### Core API Classes Source: https://github.com/sameday-courier/php-sdk/blob/master/docs/reference.md These are the fundamental classes at the core of the Sameday Courier SDK for PHP, used for service interaction and client management. ```APIDOC ## Core API Classes ### Description Core classes for the Sameday Courier SDK. ### Classes * **Sameday\Sameday** * Description: The main service object that helps tie all the SDK components together. * Reference: [reference/Sameday.md](reference/Sameday.md) * **Sameday\SamedayClient** * Description: An entity that represents a Sameday Courier client and is required to send requests. * Reference: [reference/SamedayClient.md](reference/SamedayClient.md) ``` -------------------------------- ### Track AWB Status History using PHP Source: https://context7.com/sameday-courier/php-sdk/llms.txt Fetches the full tracking history, expedition details, and parcel status for a given AWB. ```php $sameday = new \Sameday\Sameday($samedayClient); try { $awbNumber = '1SD123456789'; $statusRequest = new \Sameday\Requests\SamedayGetAwbStatusHistoryRequest($awbNumber); $statusResponse = $sameday->getAwbStatusHistory($statusRequest); // Get summary $summary = $statusResponse->getSummary(); echo "AWB: " . $statusResponse->getAwbNumber() . "\n"; echo "Current Status: " . $summary->getName() . "\n"; echo "Status Code: " . $summary->getId() . "\n"; echo "Delivered: " . ($summary->isDelivered() ? 'Yes' : 'No') . "\n"; // Get expedition details $expedition = $statusResponse->getExpedition(); echo "\nExpedition Details:\n"; echo "Weight: " . $expedition->getWeight() . " kg\n"; // Get all parcels echo "\nParcels:\n"; foreach ($statusResponse->getParcels() as $parcel) { echo " Parcel AWB: " . $parcel->getParcelAwbNumber() . "\n"; echo " Status: " . $parcel->getSummary()->getName() . "\n"; } // Get complete history echo "\nHistory:\n"; foreach ($statusResponse->getHistory() as $event) { echo " " . $event->getDate()->format('Y-m-d H:i:s') . " - "; echo $event->getName() . " (" . $event->getCounty() . ", " . $event->getCountry() . ")\n"; if ($event->getReason()) { echo " Reason: " . $event->getReason() . "\n"; } } } catch (\Sameday\Exceptions\SamedayNotFoundException $e) { echo "AWB not found"; } ``` -------------------------------- ### SamedayGetStatusSyncRequest Source: https://github.com/sameday-courier/php-sdk/blob/master/docs/reference/SamedayGetStatusSyncRequest.md Represents a request to retrieve all status updates between two UNIX timestamps, with support for pagination. ```APIDOC ## SamedayGetStatusSyncRequest ### Description This entity represents a request to get all status updated between two given UNIX timestamps (paginated). ### Constructor Parameters - **startTimestamp** (int) - Required - Specifies the starting UNIX timestamp for statuses to retrieve. - **endTimestamp** (int) - Required - Specifies the ending UNIX timestamp for statuses to retrieve. > Please note that the difference between starting and ending timestamps cannot be bigger than 7200 (2 hours). ### Pagination To specify pagination parameters use the following setters on this object: - **setPage(int $page)**: Specifies the page to retrieve. - **setCountPerPage(int $countPerPage)**: Specifies the number of elements to retrieve. ``` -------------------------------- ### Update COD Amount using PHP Source: https://context7.com/sameday-courier/php-sdk/llms.txt Updates the Cash on Delivery (COD) value for an AWB before the delivery process is completed. ```php $sameday = new \Sameday\Sameday($samedayClient); try { $awbNumber = '1SD123456789'; $newCodAmount = 350.50; $codRequest = new \Sameday\Requests\SamedayPutAwbCODAmountRequest( $awbNumber, $newCodAmount ); $codResponse = $sameday->putAwbCODAmount($codRequest); echo "COD amount updated to {$newCodAmount} RON\n"; } catch (\Sameday\Exceptions\SamedayBadRequestException $e) { echo "Cannot update COD: " . $e->getMessage(); } ``` -------------------------------- ### API Request Classes Source: https://github.com/sameday-courier/php-sdk/blob/master/docs/reference.md Classes used to construct various API requests for interacting with the Sameday Courier service. ```APIDOC ## API Request Classes ### Description Classes representing different API requests for the Sameday Courier SDK. ### Request Types * **Sameday\Requests\SamedayAuthenticateRequest** * Description: Represents an authentication request. * Reference: [reference/SamedayAuthenticateRequest.md](reference/SamedayAuthenticateRequest.md) * **Sameday\Requests\SamedayDeleteAwbRequest** * Description: Represents a request to delete an AWB (Air Waybill). * Reference: [reference/SamedayDeleteAwbRequest.md](reference/SamedayDeleteAwbRequest.md) * **Sameday\Requests\SamedayGetAwbPdfRequest** * Description: Represents a request to download a PDF for an existing AWB. * Reference: [reference/SamedayGetAwbPdfRequest.md](reference/SamedayGetAwbPdfRequest.md) * **Sameday\Requests\SamedayGetCountiesRequest** * Description: Represents a request to get all counties (paginated). * Reference: [reference/SamedayGetCountiesRequest.md](reference/SamedayGetCountiesRequest.md) * **Sameday\Requests\SamedayGetCitiesRequest** * Description: Represents a request to get all/filtered cities (paginated). * Reference: [reference/SamedayGetCitiesRequest.md](reference/SamedayGetCitiesRequest.md) * **Sameday\Requests\SamedayGetParcelStatusHistoryRequest** * Description: Represents a request to get status history for a parcel. * Reference: [reference/SamedayGetParcelStatusHistoryRequest.md](reference/SamedayGetParcelStatusHistoryRequest.md) * **Sameday\Requests\SamedayGetPickupPointsRequest** * Description: Represents a request to get pickup points for the current user (paginated). * Reference: [reference/SamedayGetPickupPointsRequest.md](reference/SamedayGetPickupPointsRequest.md) * **Sameday\Requests\SamedayGetServicesRequest** * Description: Represents a request to get available delivery services for the current user (paginated). * Reference: [reference/SamedayGetServicesRequest.md](reference/SamedayGetServicesRequest.md) * **Sameday\Requests\SamedayGetStatusSyncRequest** * Description: Represents a request to get all status updates that happened between two timestamps (paginated). * Reference: [reference/SamedayGetStatusSyncRequest.md](reference/SamedayGetStatusSyncRequest.md) * **Sameday\Requests\SamedayPostAwbRequest** * Description: Represents a request to create a new AWB. * Reference: [reference/SamedayPostAwbRequest.md](reference/SamedayPostAwbRequest.md) * **Sameday\Requests\SamedayPostAwbEstimationRequest** * Description: Represents a request to calculate the estimation cost for a new AWB. * Reference: [reference/SamedayPostAwbEstimationRequest.md](reference/SamedayPostAwbEstimationRequest.md) * **Sameday\Requests\SamedayPutAwbCODAmountRequest** * Description: Represents a request to update the Cash On Delivery amount for an AWB. * Reference: [reference/SamedayPutAwbCODAmountRequest.md](reference/SamedayPutAwbCODAmountRequest.md) * **Sameday\Requests\SamedayPostParcelRequest** * Description: Represents a request to create a new parcel for an existing AWB. * Reference: [reference/SamedayPostParcelRequest.md](reference/SamedayPostParcelRequest.md) * **Sameday\Requests\SamedayPutParcelSizeRequest** * Description: Represents a request to update the size for an existing parcel. * Reference: [reference/SamedayPutParcelSizeRequest.md](reference/SamedayPutParcelSizeRequest.md) * **Sameday\Requests\SamedayGetAwbPdfRequest** * Description: Represents a request to get a PDF for an AWB. * Reference: [reference/SamedayGetAwbPdfRequest.md](reference/SamedayGetAwbPdfRequest.md) * **Sameday\Requests\SamedayGetAwbStatusHistoryRequest** * Description: Represents a request to get the status history for an AWB. * Reference: [reference/SamedayGetAwbStatusHistoryRequest.md](reference/SamedayGetAwbStatusHistoryRequest.md) ``` -------------------------------- ### Delete AWB using PHP Source: https://context7.com/sameday-courier/php-sdk/llms.txt Cancels an existing AWB that has not yet been picked up by the courier. ```php $sameday = new \Sameday\Sameday($samedayClient); try { $awbNumber = '1SD123456789'; $deleteRequest = new \Sameday\Requests\SamedayDeleteAwbRequest($awbNumber); $deleteResponse = $sameday->deleteAwb($deleteRequest); echo "AWB {$awbNumber} deleted successfully\n"; } catch (\Sameday\Exceptions\SamedayNotFoundException $e) { echo "AWB not found or already processed"; } catch (\Sameday\Exceptions\SamedayBadRequestException $e) { echo "Cannot delete: " . $e->getMessage(); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.