### Install euShipments SDK via Composer Source: https://github.com/inouttrade/eushipments-sdk/blob/master/README.md Command to install the library into a PHP project and the required autoloader inclusion. ```bash composer require inouttrade/eushipments-sdk ``` ```php require_once '/path/to/vendor/autoload.php'; ``` -------------------------------- ### Get All Companies (PHP) Source: https://context7.com/inouttrade/eushipments-sdk/llms.txt Retrieves all companies associated with the euShipments account. The company ID is crucial for subsequent API calls. This example includes basic error handling. ```php setAuthToken('your-auth-token')->setSandboxMode(true); try { $request = new CompaniesRequest(); $request->setTestMode(true); $companies = $request->makeRequest($eushipments); foreach ($companies as $company) { echo "Company ID: {$company->id}, Name: {$company->name}\n"; } } catch (Exception $e) { echo 'Error: ' . $e->getMessage(); } ``` -------------------------------- ### Get Available Couriers (PHP) Source: https://context7.com/inouttrade/eushipments-sdk/llms.txt Fetches all couriers enabled for a specific company, returning their IDs necessary for shipment creation and pricing. Requires a valid company ID. ```php setAuthToken('your-auth-token')->setSandboxMode(true); try { $request = new CouriersRequest(); $request->setCompanyId(12345); // Your company ID $couriers = $request->makeRequest($eushipments); foreach ($couriers as $courier) { echo "Courier ID: {$courier->id}, Name: {$courier->name}\n"; } } catch (Exception $e) { echo 'Error: ' . $e->getMessage(); } ``` -------------------------------- ### Calculate Shipping Price to Office with Eushipments PHP SDK Source: https://github.com/inouttrade/eushipments-sdk/blob/master/README.md This example demonstrates calculating a shipping price to a specific office using the Eushipments PHP SDK. It utilizes the ShipmentPriceRequest class, setting various parameters like courier ID, weight, cod amount, and return documents. The calculation is specifically for office delivery. ```php require_once __DIR__ . '/vendor/autoload.php'; use BogdanKovachev\Eushipments\Eushipments; use BogdanKovachev\Eushipments\Request\ShipmentPriceRequest; use BogdanKovachev\Eushipments\ReturnDocs; $eushipments = new Eushipments(); $eushipments->setAuthToken(AUTH_TOKEN)->setSandboxMode(true); try { $request = new ShipmentPriceRequest(); $request->setCourierId(328) ->setCompanyId(COMPANY_ID) ->setWeight(0.75) ->setCodAmount(100.0) ->setOpenPackage(true) ->setInsuranceAmount(100.0) ->setReturnDocs(ReturnDocs::NOTHING) ->setSaturdayDelivery(false) // ->setCity('Brasov') // ->setCounty('Brasov') ->setToOffice(true) ->setCurrency('RON'); $response = $request->makeRequest($eushipments); var_dump($response); } catch (TypeError $e) { echo 'Error: ' . $e->getMessage(); } catch (Exception $e) { echo 'Error: ' . $e->getMessage(); } ``` -------------------------------- ### Get Cities with Pagination (PHP) Source: https://context7.com/inouttrade/eushipments-sdk/llms.txt Fetches cities within a specified country, supporting both full retrieval and paginated results. Essential for address validation and recipient configuration. ```php setAuthToken('your-auth-token')->setSandboxMode(true); try { // Get all cities without pagination $request = new CitiesRequest(); $request->setCountryId(1) // Romania = 1, Bulgaria = 2 ->setPaging(false); $cities = $request->makeRequest($eushipments); // Or with pagination (10 results, skip first 0) $request = new CitiesRequest(); $request->setCountryId(1) ->setPaging(true) ->setFirst(10) ->setSkip(0); $cities = $request->makeRequest($eushipments); foreach ($cities as $city) { echo "City ID: {$city->id}, Name: {$city->name}, ZIP: {$city->zipCode}\n"; } } catch (Exception $e) { echo 'Error: ' . $e->getMessage(); } ``` -------------------------------- ### Receive Order Information with Eushipments PHP SDK Source: https://github.com/inouttrade/eushipments-sdk/blob/master/README.md This snippet shows how to retrieve order information using the Eushipments PHP SDK. It requires the SDK to be installed via Composer and uses the OrdersHistoryRequest class to specify order references. The output is displayed using var_dump. ```php require_once __DIR__ . '/vendor/autoload.php'; use BogdanKovachev\Eushipments\Eushipments; use BogdanKovachev\Eushipments\Request\OrdersHistoryRequest; $eushipments = new Eushipments(); $eushipments->setAuthToken(AUTH_TOKEN)->setSandboxMode(true); try { $request = new OrdersHistoryRequest(); $request->setTestMode(true) ->setOrders([ 'REF-1', 'NOT-FOUND' ]); $response = $request->makeRequest($eushipments); var_dump($response); } catch (TypeError $e) { echo 'Error: ' . $e->getMessage(); } catch (Exception $e) { echo 'Error: ' . $e->getMessage(); } ``` -------------------------------- ### Get PDF File (A4 or Label) with Eushipments SDK Source: https://github.com/inouttrade/eushipments-sdk/blob/master/README.md Fetches a PDF document, either in A4 format or as a label, for a given AWB number. This is used for generating shipping documents or labels. The `setPrintFileType` method determines the output format. ```php require_once __DIR__ . '/vendor/autoload.php'; use BogdanKovachev\Eushipments\Eushipments; use BogdanKovachev\Eushipments\Request\PrintRequest; $eushipments = new Eushipments(); $eushipments->setAuthToken(AUTH_TOKEN)->setSandboxMode(true); try { $request = new PrintRequest(); $request->setAwbNumber('0000000000000') ->setTestMode(true) ->setPrintFileType(1); // 1 for label, potentially other values for A4 $response = $request->makeRequest($eushipments); var_dump($response); } catch (TypeError $e) { echo 'Error: ' . $e->getMessage(); } catch (Exception $e) { echo 'Error: ' . $e->getMessage(); } ``` -------------------------------- ### Get Countries (PHP) Source: https://context7.com/inouttrade/eushipments-sdk/llms.txt Retrieves a list of all countries enabled for the euShipments account. Country IDs are used in subsequent requests for cities and other geographic data. ```php setAuthToken('your-auth-token')->setSandboxMode(true); try { $request = new CountriesRequest(); $countries = $request->makeRequest($eushipments); foreach ($countries as $country) { echo "Country ID: {$country->id}, Name: {$country->name}, ISO: {$country->isoCode}\n"; } } catch (Exception $e) { echo 'Error: ' . $e->getMessage(); } ``` -------------------------------- ### Get city details by ZIP or Name in PHP Source: https://github.com/inouttrade/eushipments-sdk/blob/master/README.md Retrieves specific city data using the CityRequest class. Input parameters include country ID, ZIP code, and city name to identify the exact location. ```php require_once __DIR__ . '/vendor/autoload.php'; use BogdanKovachev\Eushipments\Eushipments; use BogdanKovachev\Eushipments\Request\CityRequest; $eushipments = new Eushipments(); $eushipments->setAuthToken(AUTH_TOKEN)->setSandboxMode(true); try { $request = new CityRequest(); $request->setCountryId(2)->setZipCode('4000')->setCityName('Plovdiv'); $response = $request->makeRequest($eushipments); var_dump($response); } catch (TypeError $e) { echo 'Error: ' . $e->getMessage(); } catch (Exception $e) { echo 'Error: ' . $e->getMessage(); } ``` -------------------------------- ### Initialize euShipments Client (PHP) Source: https://context7.com/inouttrade/eushipments-sdk/llms.txt Demonstrates how to initialize the euShipments client and configure authentication and environment mode (sandbox or production). Requires the autoloader and the Eushipments class. ```php setAuthToken('your-auth-token-here') ->setSandboxMode(true); // For production environment $eushipments->setAuthToken('your-auth-token-here') ->setSandboxMode(false); // API URLs used: // Development: https://test-api.inout.bg/api/v1 // Production: https://api1.inout.bg/api/v1 ``` -------------------------------- ### Manage products in fulfilment system with PHP Source: https://github.com/inouttrade/eushipments-sdk/blob/master/README.md Demonstrates creating a new product using the Product data structure and retrieving all existing products for a company. Requires valid company credentials. ```php require_once __DIR__ . '/vendor/autoload.php'; use BogdanKovachev\Eushipments\Eushipments; use BogdanKovachev\Eushipments\Datastructure\Product; use BogdanKovachev\Eushipments\Request\CreateProductRequest; $eushipments = new Eushipments(); $eushipments->setAuthToken(AUTH_TOKEN)->setSandboxMode(true); try { $product = new Product(); $product->setName('Test Product') ->setBarcode('0000000000000') ->setBarcodeType('EAN-13') ->setDescription('Our new bestseller') ->setLength(40) ->setWidth(25) ->setHeight(15) ->setWeight(2.5) ->setReferenceNumber('TEST-PRODUCT'); $request = new CreateProductRequest(); $request->setTestMode(true)->setCompanyId(COMPANY_ID)->setProduct($product); $productId = $request->makeRequest($eushipments); var_dump($productId); } catch (TypeError $e) { echo 'Error: ' . $e->getMessage(); } catch (Exception $e) { echo 'Error: ' . $e->getMessage(); } ``` ```php require_once __DIR__ . '/vendor/autoload.php'; use BogdanKovachev\Eushipments\Eushipments; use BogdanKovachev\Eushipments\Request\GetProductsRequst; $eushipments = new Eushipments(); $eushipments->setAuthToken(AUTH_TOKEN)->setSandboxMode(true); try { $request = new GetProductsRequst(); $request->setCompanyId(COMPANY_ID); $response = $request->makeRequest($eushipments); var_dump($response); } catch (TypeError $e) { echo 'Error: ' . $e->getMessage(); } catch (Exception $e) { echo 'Error: ' . $e->getMessage(); } ``` -------------------------------- ### POST /products Source: https://context7.com/inouttrade/eushipments-sdk/llms.txt Registers a new product in the euShipments fulfillment system to enable inventory tracking and management. ```APIDOC ## POST /products ### Description Creates a new product in the euShipments fulfillment system for inventory management. ### Method POST ### Endpoint /products ### Parameters #### Request Body - **companyId** (integer) - Required - The ID of the company owning the product - **product** (Object) - Required - Product specifications including dimensions, weight, and barcode ### Request Example { "companyId": 12345, "product": { "name": "Test Product", "barcode": "0000000000000", "weight": 2.5, "referenceNumber": "SKU-12345" } } ### Response #### Success Response (200) - **productId** (integer) - The unique identifier for the created product #### Response Example { "productId": 98765 } ``` -------------------------------- ### Get Latest Shipment Status with Eushipments SDK Source: https://github.com/inouttrade/eushipments-sdk/blob/master/README.md Fetches the most recent status of a shipment using its AWB number. The SDK provides an enum `ShipmentStatus` for easy comparison of the returned status. This is crucial for real-time tracking. ```php require_once __DIR__ . '/vendor/autoload.php'; use BogdanKovachev\Eushipments\Eushipments; use BogdanKovachev\Eushipments\Request\ShipmentStatusRequest; use BogdanKovachev\Eushipments\ShipmentStatus; $eushipments = new Eushipments(); $eushipments->setAuthToken(AUTH_TOKEN)->setSandboxMode(true); try { $request = new ShipmentStatusRequest(); $request->setTestMode(true)->setAwbNumber('0000000000000'); $status = $request->makeRequest($eushipments); if ($status == ShipmentStatus::DELIVERED) { // Perform something } // The last status from the shipment tracking var_dump($status); } catch (TypeError $e) { echo 'Error: ' . $e->getMessage(); } catch (Exception $e) { echo 'Error: ' . $e->getMessage(); } ``` -------------------------------- ### Create Shipment using Eushipments SDK in PHP Source: https://github.com/inouttrade/eushipments-sdk/blob/master/README.md This PHP code snippet demonstrates how to create a shipment using the Eushipments SDK. It involves initializing the SDK, setting authentication credentials, defining sender and recipient objects, configuring airwaybill details, and optionally including customs data. Error handling is included via a try-catch block. ```php require_once __DIR__ . '/vendor/autoload.php'; use BogdanKovachev\Eushipments\Datastructure\Airwaybill; use BogdanKovachev\Eushipments\Datastructure\Recipient; use BogdanKovachev\Eushipments\Datastructure\Sender; use BogdanKovachev\Eushipments\Eushipments; use BogdanKovachev\Eushipments\Request\CreateAwbRequst; use BogdanKovachev\Eushipments\Service; use BogdanKovachev\Eushipments\ShipmentType; $eushipments = new Eushipments(); $eushipments->setAuthToken(AUTH_TOKEN)->setSandboxMode(true); try { $recipient = new Recipient(); $recipient->setName('Test API') ->setCountryIsoCode('RO') // ->setCityId(20003314) ->setCityName('Brasov') ->setZipCode('500007') ->setRegion('Brasov') ->setStreetName('Bulevardul Eroilor 8') ->setBuildingNumber(8) ->setAddressText('fl 1') ->setContactPerson('Test API') ->setPhoneNumber('0888888888') ->setEmail('email@example.com'); $awb = new Airwaybill(); $awb->setShipmentType(ShipmentType::PACK) ->setParcels(1) ->setEnvelopes(0) ->setPallets(0) ->setTotalWeight(2.5) ->setDeclaredValue(100.00) ->setBankRepayment(100.00) ->setOtherRepayment('COD') ->setObservations('Additional info') ->setOpenPackage(false) ->setSaturdayDelivery(true) ->setReferenceNumber('REF-1') ->setProducts('Test 1 Test 2') ->setFragile(false) ->setProductsInfo('Products info') ->setPiecesInPack(2); // ->setPackages([]) // ->setShipmentPayer('sender') $sender = new Sender(); $sender->setName('Test API') ->setPhoneNumber('+359888888888') ->setEmail('email@example.com'); $customsData = [ 'dutyPaymentInfo' => 'DDP', 'customsValue' => 100.0 ]; $document = [ 'content' => 'JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9UaXRsZSA8RkVGRjA0MUQwNDM1MDQzRTA0MzcwNDMwMDQzMzA0M0IwNDMwMDQzMjA0MzUwNDNEMDAyMDA0MzQwNDNFMDQzQTA0NDMwNDNDMDQzNTA0M0QwNDQyPgovUHJvZHVjZXIgKFNraWEvUERGIG0xMDMgR29vZ2xlIERvY3MgUmVuZGVyZXIpPj4KZW5kb2JqCjMgMCBvYmoKPDwvY2EgMQovQk0gL05vcm1hbD4+CmVuZG9iago1IDAgb2JqCjw8L0ZpbHRlciAvRmxhdGVEZWNvZGUKL0xlbmd0aCAxNzM+PiBzdHJlYW0KeJx1j00KAjEMhfc5RS5gJ0nTSQviQhhnrfQG6giCC8f7g+38LQSbkIR8vEfKSCV2XEpUwesL3uAsTNu1lyVjjUu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LmO/OpoODEt/ulz9H9+/fKprFuN3Ol98nt2zevb5/cdFdXqy2tb7feOWpcrNVmtYqx8MMmG3ksIe2O6TcsSw4EQlny51+zLpPXV7lPiPHlhd3S9KrWa+DIhrm36i3HT6wdu+a+y8YEooOjrTK/sHxheYciMd5VnisesTxiXxG2IkK1M1uEPdKWkJFwY8icaNucqBvj7lIX2xeH3RWxMHpx7KK4RZ0WJdyVFGaLtsfakuKik2KTEuKSbDFZ4SGJWTYlPmODAw+O06E7FIefL/Xo2SmelOqUupQFKU0pVj3lSApPcWY0ERMTmI3HBUYtneft6JiXGUMPDXWOnXFMJKjgUMEhrODYsTNobExunpiK3jpFOSlVJxYb3TsnODNVxTnPX7e4hZWwhYF5gW2B1sA81uvz5uZ9n774Yjt/t31Fnc89IDAtsDLwRGA6dtGkfwQQ93/64UfxjkA8UK/FHg2lb1pJMT9tCY8qUPxmm+fWxKxc ``` -------------------------------- ### Constants Reference for Eushipments SDK in PHP Source: https://context7.com/inouttrade/eushipments-sdk/llms.txt Demonstrates the usage of various constant classes provided by the Eushipments SDK for type-safe configuration. This includes service types, shipment types, return document options, and shipment statuses. ```php setAuthToken('your-auth-token')->setSandboxMode(true); try { $product = new Product(); $product->setName('Test Product') ->setBarcode('0000000000000') ->setBarcodeType('EAN-13') ->setDescription('Our new bestseller product') ->setLength(40) // cm ->setWidth(25) // cm ->setHeight(15) // cm ->setWeight(2.5) // kg ->setReferenceNumber('SKU-12345'); $request = new CreateProductRequest(); $request->setTestMode(true) ->setCompanyId(12345) ->setProduct($product); $productId = $request->makeRequest($eushipments); echo "Created Product ID: {$productId}\n"; } catch (Exception $e) { echo 'Error: ' . $e->getMessage(); } ``` -------------------------------- ### Retrieve cities in a country Source: https://github.com/inouttrade/eushipments-sdk/blob/master/README.md Fetches cities for a country, demonstrating both non-paginated and paginated request configurations. ```php // Without pagination $request = new CitiesRequest(); $request->setCountryId(1)->setPaging(false); $response = $request->makeRequest($eushipments); // With pagination $request = new CitiesRequest(); $request->setCountryId(1)->setPaging(true)->setFirst(10)->setSkip(0); $response = $request->makeRequest($eushipments); ``` -------------------------------- ### Get Waybill (AWB) Details with Eushipments SDK Source: https://github.com/inouttrade/eushipments-sdk/blob/master/README.md Retrieves detailed information about a specific Air Waybill (AWB). This function allows you to fetch all associated data for a given AWB number, including shipment details, status, and tracking information. ```php require_once __DIR__ . '/vendor/autoload.php'; use BogdanKovachev\Eushipments\Eushipments; use BogdanKovachev\Eushipments\Request\AwbDetailsRequest; $eushipments = new Eushipments(); $eushipments->setAuthToken(AUTH_TOKEN)->setSandboxMode(true); try { $request = new AwbDetailsRequest(); $request->setTestMode(true)->setAwbNumber('0000000000000'); $response = $request->makeRequest($eushipments); var_dump($response); } catch (TypeError $e) { echo 'Error: ' . $e->getMessage(); } catch (Exception $e) { echo 'Error: ' . $e->getMessage(); } ``` -------------------------------- ### Get Shipment Status with PHP Source: https://context7.com/inouttrade/eushipments-sdk/llms.txt Retrieves the latest status of a shipment using its AWB number. This function requires the Eushipments SDK and utilizes ShipmentStatus constants for comparison. It returns the current status string and allows checking against predefined statuses like DELIVERED or IN_TRANSIT. ```php setAuthToken('your-auth-token')->setSandboxMode(true); try { $request = new ShipmentStatusRequest(); $request->setTestMode(true) ->setAwbNumber('1234567890123'); $status = $request->makeRequest($eushipments); echo "Current Status: {$status}\n"; // Check specific statuses if ($status == ShipmentStatus::DELIVERED) { echo "Package has been delivered!\n"; } elseif ($status == ShipmentStatus::IN_TRANSIT) { echo "Package is in transit.\n"; } elseif ($status == ShipmentStatus::ON_DELIVERY) { echo "Package is out for delivery.\n"; } // Available statuses: // ShipmentStatus::ON_DELIVERY, IN_TRANSIT, DELIVERED, RETURNED, // IN_THE_OFFICE, COD_PAID, NEWNEW, CANCELLED, STOCKOUT, // LOST_SHIPMENT, REDIRECTED, DELETED, WAREHOUSE_RUSE, RETURNING } catch (Exception $e) { echo 'Error: ' . $e->getMessage(); } ```