### Install FANCourier API via Composer Source: https://github.com/shusaura85/fancourier-api/blob/main/README.md Installs the FANCourier API library using Composer. This is the recommended method for managing dependencies in PHP projects. ```bash composer require shusaura85/fancourier-api ``` -------------------------------- ### Manual Installation of FANCourier API Source: https://github.com/shusaura85/fancourier-api/blob/main/README.md Includes the autoload.php file manually if not using Composer. This is an alternative installation method for PHP projects. ```php require_once '/path/to/fancourier-api/src/autoload.php'; ``` -------------------------------- ### Get Bank Transfers Source: https://context7.com/shusaura85/fancourier-api/llms.txt Retrieve bank transfer information for COD payments with pagination. This endpoint helps in reconciling cash-on-delivery transactions. ```APIDOC ## GET /bank-transfers ### Description Retrieve bank transfer information for COD payments with pagination. This endpoint helps in reconciling cash-on-delivery transactions. ### Method GET ### Endpoint /bank-transfers ### Parameters #### Query Parameters - **date** (string) - Required - The date for which to retrieve bank transfers (YYYY-MM-DD) - **page** (integer) - Optional - The page number for pagination (defaults to 1) - **perPage** (integer) - Optional - The number of items per page (defaults to 100) ### Response #### Success Response (200) - **total** (integer) - Total number of bank transfers available - **currentPage** (integer) - The current page number - **totalPages** (integer) - The total number of pages - **data** (array) - An array of bank transfer objects, each containing: - **awbNumber** (string) - The AWB number - **awbDate** (string) - The date of the AWB - **amountCollected** (float) - The amount collected for COD - **transferDate** (string) - The date of the bank transfer - **transactionType** (string) - The type of transaction - **transactionDate** (string) - The date of the transaction - **content** (string) - Description of the content - **recipientName** (string) - Name of the recipient - **recipientCity** (string) - City of the recipient - **senderName** (string) - Name of the sender - **returnAwbNumber** (string) - Optional - The return AWB number if applicable #### Response Example ```json { "total": 50, "currentPage": 1, "totalPages": 1, "data": [ { "awbNumber": "AWB67890", "awbDate": "2024-01-15", "amountCollected": 150.75, "transferDate": "2024-01-16", "transactionType": "COD", "transactionDate": "2024-01-16", "content": "Product X", "recipientName": "Customer A", "recipientCity": "City B", "senderName": "My Company", "returnAwbNumber": null } ] } ``` ``` -------------------------------- ### Get Shipping Slips (Borderou) Source: https://context7.com/shusaura85/fancourier-api/llms.txt Retrieve shipping slips (borderouri) for a specific date with pagination support. This endpoint is useful for tracking shipments and their details. ```APIDOC ## GET /shipping-slips ### Description Retrieve shipping slips (borderouri) for a specific date with pagination support. This endpoint is useful for tracking shipments and their details. ### Method GET ### Endpoint /shipping-slips ### Parameters #### Query Parameters - **date** (string) - Required - The date for which to retrieve shipping slips (YYYY-MM-DD) - **page** (integer) - Optional - The page number for pagination (defaults to 1) - **perPage** (integer) - Optional - The number of items per page (defaults to 50) ### Response #### Success Response (200) - **total** (integer) - Total number of shipping slips available - **currentPage** (integer) - The current page number - **totalPages** (integer) - The total number of pages - **data** (array) - An array of shipping slip objects, each containing: - **awbNumber** (string) - The AWB number - **service** (string) - The shipping service used - **weight** (float) - The weight of the shipment in kg - **parcels** (integer) - The number of parcels - **cost** (float) - The cost of the shipment in RON - **reimbursement** (float) - The reimbursement amount - **contents** (string) - Description of the shipment contents - **notes** (string) - Any notes associated with the shipment - **dateTime** (string) - The date and time of the shipment - **recipient** (object) - Recipient details - **sender** (object) - Sender details #### Response Example ```json { "total": 100, "currentPage": 1, "totalPages": 2, "data": [ { "awbNumber": "AWB12345", "service": "Standard", "weight": 2.5, "parcels": 1, "cost": 25.50, "reimbursement": 0.00, "contents": "Documents", "notes": "Handle with care", "dateTime": "2024-01-15T10:30:00", "recipient": { "name": "John Doe", "address": "123 Main St" }, "sender": { "name": "Jane Smith", "address": "456 Oak Ave" } } ] } ``` ``` -------------------------------- ### Get Cities - PHP Source: https://github.com/shusaura85/fancourier-api/blob/main/docs/Classes overview.md Fetches a list of cities. Similar to getting counties, this operation is simplified by the `Fancourier::getCities()` method, eliminating the need for manual request object construction. ```PHP ``` -------------------------------- ### Get Costs (Internal AWB Tariff) - PHP Source: https://github.com/shusaura85/fancourier-api/blob/main/docs/Classes overview.md This function is used to get the tariff costs for internal AWBs. The API call `[Request/Response]\GetCosts` is used, and it does not require a specific PHP object to be instantiated for the request itself. ```PHP ``` -------------------------------- ### Get Shipping Slips with Pagination via Fancourier API Source: https://context7.com/shusaura85/fancourier-api/llms.txt Retrieves shipping slips (borderouri) for a specified date, supporting pagination to handle large datasets. The code iterates through all available pages, extracting details like AWB number, service type, weight, cost, and recipient/sender information for each slip. ```php setDate('2024-01-15') ->setPage(1) ->setPerPage(50); $response = $fan->getShippingSlip($request); if ($response->isOk()) { echo "Total Slips: " . $response->getTotal() . "\n"; echo "Page: " . $response->getCurrentPage() . " of " . $response->getTotalPages() . "\n\n"; $slips = $response->getAll(); foreach ($slips as $slip) { echo "AWB: " . $slip->getAwbNumber() . "\n"; echo "Service: " . $slip->getService() . "\n"; echo "Weight: " . $slip->getWeight() . " kg\n"; echo "Parcels: " . $slip->getParcels() . "\n"; echo "Cost: " . $slip->getCost() . " RON\n"; echo "Reimbursement: " . $slip->getReimbursement() . "\n"; echo "Contents: " . $slip->getContents() . "\n"; echo "Notes: " . $slip->getNotes() . "\n"; echo "DateTime: " . $slip->getDateTime() . "\n"; echo "Recipient: " . print_r($slip->getRecipient(), true) . "\n"; echo "Sender: " . print_r($slip->getSender(), true) . "\n\n"; } // Pagination - get all pages while ($response->getCurrentPage() < $response->getTotalPages()) { $request->setPage($response->getCurrentPage() + 1); $response = $fan->getShippingSlip($request); if ($response->isOk()) { foreach ($response->getAll() as $slip) { echo "AWB: " . $slip->getAwbNumber() . "\n"; } } } } else { echo "Error: " . $response->getErrorMessage(); } ``` -------------------------------- ### Get Romanian Counties using Fancourier API Source: https://context7.com/shusaura85/fancourier-api/llms.txt Retrieves a list of all Romanian counties, useful for address validation and dropdown selections. The response can be iterated to get all counties or queried for a specific county by name. Returns county ID and name. ```php getCounties(); if ($response->isOk()) { $counties = $response->getAll(); foreach ($counties as $county) { echo $county->getId() . ": " . $county->getName() . "\n"; } // Get specific county $arad = $response->getCounty('Arad'); if ($arad) { echo "Arad ID: " . $arad->getId(); } } else { echo "Error: " . $response->getErrorMessage(); } ?> ``` -------------------------------- ### Get PUDO Points (FANBox Lockers) - PHP Source: https://github.com/shusaura85/fancourier-api/blob/main/docs/Classes overview.md Fetches a list of PUDO (Pick-Up/Drop-Off) points, specifically for FANBox lockers. The `Fancourier::getPudo()` method returns the available locker locations. ```PHP ``` -------------------------------- ### Get Cities by County using Fancourier API Source: https://context7.com/shusaura85/fancourier-api/llms.txt Fetches a list of cities within a specified Romanian county. Includes details like agency information and distance. Allows retrieval of all cities in a county or a specific city by name. Returns city ID, name, county, agency, and extra kilometer information. ```php setCounty('Bucuresti'); $response = $fan->getCities($request); if ($response->isOk()) { $cities = $response->getAll(); foreach ($cities as $city) { echo "ID: " . $city->getId() . "\n"; echo "Name: " . $city->getName() . "\n"; echo "County: " . $city->getCounty() . "\n"; echo "Agency: " . $city->getAgency() . "\n"; echo "Extra KM: " . $city->getExtKm() . "\n\n"; } // Get specific city $sector1 = $response->getCity('Sector 1'); if ($sector1) { echo "Agency for Sector 1: " . $sector1->getAgency(); } } else { echo "Error: " . $response->getErrorMessage(); } ?> ``` -------------------------------- ### Get Shipping Slip (Borderou) - PHP Source: https://github.com/shusaura85/fancourier-api/blob/main/docs/Classes overview.md Retrieves the shipping slip (Borderou). The `Objects\ShippingSlip` class is associated with this functionality, and the `Fancourier::getShippingSlip()` method is used to obtain the data. ```PHP ``` -------------------------------- ### Get Bank Transfer Information - PHP Source: https://github.com/shusaura85/fancourier-api/blob/main/docs/Classes overview.md Fetches bank transfer details. The `Objects\BankTransfer` class is relevant for this operation, and the `Fancourier::getBankTransfer()` method is used to retrieve the information. ```PHP ``` -------------------------------- ### Get Countries - PHP Source: https://github.com/shusaura85/fancourier-api/blob/main/docs/Classes overview.md Retrieves a list of international countries. The `Fancourier::getCountries()` method simplifies this process, eliminating the need for manual request object creation. ```PHP ``` -------------------------------- ### Get FANBox PUDO Locations using Fancourier API (PHP) Source: https://github.com/shusaura85/fancourier-api/blob/main/README.md This snippet demonstrates how to retrieve information about available FANBox locations, which are PUDO (Pick Up Drop Off) points. It involves creating a GetPudo request and specifying the type of PUDO location to retrieve. The response contains raw data or an array of PUDO objects. ```php $request = new Fancourier\Request\GetPudo(); $request ->setType(Fancourier\Request\GetPudo::PUDO_FANBOX); ``` ```php $response = $fan->getPudo($request); if ($response->isOk()) { print_r($response->getData()); // raw data print_r($response->getAll()); // array of PUDO objects } else { var_dump($response->getErrorMessage()); } ``` -------------------------------- ### Get External Cities - PHP Source: https://github.com/shusaura85/fancourier-api/blob/main/docs/Classes overview.md Retrieves a list of external cities for supported countries (Moldova, Greece, Bulgaria). The `Fancourier::getCitiesExternal()` method is used to fetch this data. ```PHP ``` -------------------------------- ### Get AWB Events - PHP Source: https://github.com/shusaura85/fancourier-api/blob/main/docs/Classes overview.md Fetches event information for one or more AWBs. The `Objects\AwbEvent` class is relevant here, and the `Fancourier::getAwbEvents()` method is used to retrieve the event data. ```PHP ``` -------------------------------- ### Get PUDO Locations using Fancourier API Source: https://context7.com/shusaura85/fancourier-api/llms.txt Retrieves a list of Pick Up Drop Off (PUDO) locations, including FANBox parcel lockers, PayPoint, and offices. Supports filtering by type and retrieving a specific PUDO by its ID. Returns location details such as ID, name, address, coordinates, schedule, and description. ```php setType(Fancourier\Request\GetPudo::PUDO_FANBOX); // Other types: PUDO_PAYPOINT, PUDO_OFFICE $response = $fan->getPudo($request); if ($response->isOk()) { $locations = $response->getAll(); foreach ($locations as $pudo) { echo "ID: " . $pudo->getId() . "\n"; echo "Name: " . $pudo->getName() . "\n"; echo "Address: " . $pudo->getAddress() . "\n"; echo "Lat/Long: " . $pudo->getLatitude() . ", " . $pudo->getLongitude() . "\n"; echo "Schedule: " . $pudo->getSchedule() . "\n"; echo "Description: " . $pudo->getDescription() . "\n"; echo "Routing Location: " . $pudo->getRoutingLocation() . "\n\n"; } // Get specific PUDO by ID $specificPudo = $response->get('PUDO_ID_HERE'); } else { echo "Error: " . $response->getErrorMessage(); } // Get details for a specific PUDO point $request = new Fancourier\Request\GetPudo(); $request->setId('specific_pudo_id'); // When ID is set, type is ignored $response = $fan->getPudo($request); if ($response->isOk()) { $pudo = $response->get(); echo "PUDO Details: " . $pudo->getName(); } ?> ``` -------------------------------- ### Get Bank Transfers for COD Payments with Fancourier API Source: https://context7.com/shusaura85/fancourier-api/llms.txt Retrieves bank transfer information for Cash on Delivery (COD) payments on a given date, with support for pagination. The code displays details such as AWB number, amount collected, transfer date, and sender/recipient information, and includes logic to process all available pages. ```php setDate('2024-01-15') ->setPage(1) ->setPerPage(100); $response = $fan->getBankTransfers($request); if ($response->isOk()) { echo "Total Transfers: " . $response->getTotal() . "\n"; echo "Page: " . $response->getCurrentPage() . "/" . $response->getTotalPages() . "\n\n"; $transfers = $response->getAll(); foreach ($transfers as $transfer) { echo "AWB: " . $transfer->getAwbNumber() . "\n"; echo "AWB Date: " . $transfer->getAwbDate() . "\n"; echo "Amount Collected: " . $transfer->getAmountCollected() . "\n"; echo "Transfer Date: " . $transfer->getTransferDate() . "\n"; echo "Transaction Type: " . $transfer->getTransactionType() . "\n"; echo "Transaction Date: " . $transfer->getTransactionDate() . "\n"; echo "Content: " . $transfer->getContent() . "\n"; echo "Recipient: " . $transfer->getRecipientName() . "\n"; echo "Recipient City: " . $transfer->getRecipientCity() . "\n"; echo "Sender: " . $transfer->getSenderName() . "\n"; if ($transfer->getReturnAwbNumber()) { echo "Return AWB: " . $transfer->getReturnAwbNumber() . "\n"; } echo "\n"; } // Process all pages while ($response->getCurrentPage() < $response->getTotalPages()) { $request->setPage($response->getCurrentPage() + 1); $response = $fan->getBankTransfers($request); // Process $response->getAll()... } } else { echo "Error: " . $response->getErrorMessage(); } ``` -------------------------------- ### Get Counties - PHP Source: https://github.com/shusaura85/fancourier-api/blob/main/docs/Classes overview.md Retrieves a list of counties. This is a straightforward API call that does not require manual creation of a request object. The `Fancourier::getCounties()` method directly returns the county data. ```PHP ``` -------------------------------- ### Get Costs (External AWB Tariff) - PHP Source: https://github.com/shusaura85/fancourier-api/blob/main/docs/Classes overview.md This function retrieves the tariff costs for external AWBs. The corresponding API call is `[Request/Response]\GetCostsExternal`, and it does not require a specific PHP object for the request. ```PHP ``` -------------------------------- ### Get Estimated Shipping Cost Source: https://github.com/shusaura85/fancourier-api/blob/main/README.md Requests an estimated shipping cost from the FANCourier API. It requires details such as parcels, weight, destination county and city, and declared value. The response can be raw data or specific cost components. ```php $request = new Fancourier\Request\GetCosts(); $request ->setParcels(1) ->setWeight(1) ->setCounty('Arad') ->setCity('Aciuta') ->setDeclaredValue(125); // Assuming $fan is an authenticated Fancourier instance // $response = $fan->getCosts($request); // if ($response->isOk()) { // var_dump($response->getData()); // raw data // echo "extraKmCost: ". $response->getKmCost().'
'; // echo "weightCost: ". $response->getWeightCost().'
'; // echo "insuranceCost: ". $response->getInsuranceCost().'
'; // echo "optionsCost: ". $response->getOptionsCost().'
'; // echo "fuelCost: ". $response->getFuelCost().'
'; // echo "costNoVAT: ". $response->getCost().'
'; // echo "vat: ". $response->getCostVat().'
'; // echo "total: ".$response->getCostTotal().'
'; // } else { // var_dump($response->getErrorMessage()); // print_r($response->getAllErrors()); // } ``` -------------------------------- ### Generate AWB (Air Waybill) - PHP Source: https://github.com/shusaura85/fancourier-api/blob/main/docs/Classes overview.md This section covers functionalities related to generating and managing AWBs. It includes getting service types, options, printing, and deleting AWBs. The PHP API provides specific objects for service and service options, while printing and deleting do not require direct object instantiation. ```PHP ``` -------------------------------- ### Track AWB (Single and Bulk) using Fancourier API Source: https://context7.com/shusaura85/fancourier-api/llms.txt This PHP snippet shows how to track one or multiple shipments using their AWB numbers via the Fancourier API. It retrieves detailed tracking events, status, and other relevant information for each AWB. The response can be processed to get specific AWB details or all tracking results. ```php addAwb('2150900120084') ->addAwb('2150900120085') ->addAwb('2150900120086') ->setLanguage('en'); // 'ro' for Romanian, 'en' for English $response = $fan->trackAwb($request); if ($response->isOk()) { $trackers = $response->getAll(); foreach ($trackers as $tracker) { echo "AWB: " . $tracker->getAwbNumber() . "\n"; echo "Status: " . $tracker->getStatus() . "\n"; echo "Message: " . $tracker->getMessage() . "\n"; echo "Content: " . $tracker->getContent() . "\n"; if ($tracker->hasConfirmation()) { echo "Confirmation: " . $tracker->getConfirmation() . "\n"; } // Related AWBs if ($tracker->getReturnAwbNumber()) { echo "Return AWB: " . $tracker->getReturnAwbNumber() . "\n"; } if ($tracker->getRedirectionAwbNumber()) { echo "Redirection AWB: " . $tracker->getRedirectionAwbNumber() . "\n"; } // Tracking events echo "Events:\n"; foreach ($tracker->getEvents() as $event) { echo " - " . $event['date'] . ": " . $event['status'] . "\n"; } echo "\n"; } // Get specific AWB tracker $specificTracker = $response->getAwb('2150900120084'); if ($specificTracker) { echo "Specific AWB Status: " . $specificTracker->getStatus(); } } else { echo "Error: " . $response->getErrorMessage(); } ``` -------------------------------- ### Track Multiple AWBs in Bulk using Fancourier API (PHP) Source: https://github.com/shusaura85/fancourier-api/blob/main/README.md This snippet shows how to track multiple AWBs in a single request by adding multiple AWB numbers to the same TrackAwb request object. It's an efficient way to get tracking information for several shipments simultaneously. The response handling is similar to tracking a single AWB. ```php $request = new Fancourier\Request\TrackAwb(); $request ->addAwb('2150900120084') ->addAwb('2150900120085') ->addAwb('2150900120086'); ``` ```php $response = $fan->trackAwb($request); if ($response->isOk()) { print_r($response->getData()); // raw data print_r($response->getAll()); // array of AwbTracker objects } else { var_dump($response->getErrorMessage()); } ``` -------------------------------- ### Initialize FANCourier Client and Authenticate (PHP) Source: https://context7.com/shusaura85/fancourier-api/llms.txt Initializes the FANCourier client using provided credentials or a test instance. It handles token generation and caching, with options to disable SSL verification and set custom timeouts. The token is automatically refreshed and can be cached for 24 hours. ```php setVerify(false, false); // Optional: Set custom request timeout (connection timeout, request timeout) $fan->setTimeout(3, 6); // Get and cache the token for subsequent requests $token = $fan->getToken(true); // true forces refresh if ($token) { file_put_contents('token_cache.txt', $token); echo "Token expires at: " . $fan->getTokenExpiresAt(); } else { echo "Error: " . $fan->getTokenMessage(); } ``` -------------------------------- ### FANCourier API Authentication Source: https://github.com/shusaura85/fancourier-api/blob/main/README.md Demonstrates how to authenticate with the FANCourier API using a client ID, username, password, and token. It also shows how to obtain a new token if needed. ```php $clientId = 'your_client_id'; $username = 'your_username'; $password = 'your_password'; $token = 'load from cache or leave as empty string'; $fan = new Fancourier\Fancourier($clientId, $username, $password, $token); // Or use the test instance // $fan = Fancourier\Fancourier::testInstance($token); $force_refresh = false; $token = $fan->getToken($force_refresh); ``` -------------------------------- ### Create Courier Order Source: https://context7.com/shusaura85/fancourier-api/llms.txt Schedule a courier pickup for your shipments. This endpoint allows you to specify details about the parcels, pickup date and time, and recipient information. ```APIDOC ## POST /orders/courier ### Description Schedule a courier pickup for your shipments. This endpoint allows you to specify details about the parcels, pickup date and time, and recipient information. ### Method POST ### Endpoint /orders/courier ### Parameters #### Request Body - **orderType** (string) - Required - Type of order ('Standard' or 'Express Loco ...') - **parcels** (integer) - Required - Number of parcels - **envelopes** (integer) - Required - Number of envelopes - **weight** (float) - Required - Total weight in kg - **sizes** (string) - Required - Estimated max dimensions (e.g., '50,40,40') - **pickupDate** (string) - Required - Pickup date in YYYY-MM-DD format - **pickupHours** (string) - Required - Pickup hours (e.g., '09:00', '17:00') - **notes** (string) - Optional - Additional notes for the pickup - **recipientName** (string) - Optional - Recipient's name (uses account default if not set) - **contactPerson** (string) - Optional - Contact person at the recipient address - **phone** (string) - Optional - Recipient's phone number - **county** (string) - Optional - Recipient's county - **city** (string) - Optional - Recipient's city - **street** (string) - Optional - Recipient's street - **number** (string) - Optional - Recipient's street number - **building** (string) - Optional - Recipient's building - **floor** (string) - Optional - Recipient's floor ### Request Example ```php { "orderType": "Standard", "parcels": 5, "envelopes": 2, "weight": 15, "sizes": "50,40,40", "pickupDate": "2024-01-16", "pickupHours": "09:00-17:00", "notes": "Please call before arrival", "recipientName": "My Company SRL", "contactPerson": "John Manager", "phone": "0721000000", "county": "Bucuresti", "city": "Sector 1", "street": "Str Victoriei", "number": "100", "building": "A", "floor": "2" } ``` ### Response #### Success Response (200) - **data** (string) - The created courier order ID #### Response Example ```json { "data": "ORDER_ID_12345" } ``` ``` -------------------------------- ### Create AWBs in Bulk using Fancourier API (PHP) Source: https://github.com/shusaura85/fancourier-api/blob/main/README.md This snippet shows how to create multiple AWBs in a single request by instantiating multiple AwbIntern objects and adding them to a CreateAwb request. It details the process of setting service details and options for each AWB before sending the request and handling the response. ```php $request = new Fancourier\Request\CreateAwb(); // create the first awb $awb = new Fancourier\Objects\AwbIntern(); $awb ->setService('Cont Colector') .... ->addOption('X'); // add it to the request $request->addAwb($awb); // create another awb $awb = new Fancourier\Objects\AwbIntern(); $awb ->setService('Cont Colector') .... ->addOption('X'); // add it to the request $request->addAwb($awb); // create another awb $awb = new Fancourier\Objects\AwbIntern(); $awb ->setService('Cont Colector') .... ->addOption('X'); // add it to the request $request->addAwb($awb); ``` ```php $response = $fan->createAwb($request); if ($response->isOk()) { var_dump($response->getData()); // raw data // or the AWBIntern objects updated with the response information $al = $response->getAll(); echo "Count: ".count($al)."
"; foreach ($al as $awbr) { if ($awbr->hasErrors()) { print_r($awbr->getErrors()); } else { echo "AWB: ".$awbr->getAwb()."
"; } } } else { var_dump($response->getErrorMessage()); } ``` -------------------------------- ### Get External Counties - PHP Source: https://github.com/shusaura85/fancourier-api/blob/main/docs/Classes overview.md Fetches a list of external counties, specifically for Moldova, Greece, and Bulgaria. The `Fancourier::getCountiesExternal()` method is used for this purpose. ```PHP ``` -------------------------------- ### Retrieve Available Shipping Services (PHP) Source: https://context7.com/shusaura85/fancourier-api/llms.txt Fetches a list of all available shipping services associated with the FANCourier account. The response can be iterated to access individual service details like ID, name, and description. It also allows checking for the availability of a specific service by name. ```php getServices(); if ($response->isOk()) { // Get all services as Service objects $services = $response->getAll(); foreach ($services as $service) { echo "ID: " . $service->getId() . "\n"; echo "Name: " . $service->getName() . "\n"; echo "Description: " . $service->getDescription() . "\n\n"; } // Check if specific service is available if ($response->hasService('Cont Colector')) { $contColector = $response->getService('Cont Colector'); echo "Service ID: " . $contColector->getId(); } } else { echo "Error: " . $response->getErrorMessage(); } ``` -------------------------------- ### Get Countries (International Shipping) Source: https://context7.com/shusaura85/fancourier-api/llms.txt Retrieve available destination countries for international shipments. This endpoint provides a list of countries that can be shipped to internationally. ```APIDOC ## GET /countries ### Description Retrieve available destination countries for international shipments. This endpoint provides a list of countries that can be shipped to internationally. ### Method GET ### Endpoint /countries ### Parameters None ### Response #### Success Response (200) - **data** (array) - An array of country objects, each containing: - **id** (integer) - The unique identifier for the country - **name** (string) - The name of the country #### Response Example ```json { "data": [ { "id": 1, "name": "United States" }, { "id": 2, "name": "Germany" } ] } ``` ``` -------------------------------- ### Create Single Domestic AWB with Fancourier API (PHP) Source: https://context7.com/shusaura85/fancourier-api/llms.txt This snippet demonstrates how to create a single domestic Air Waybill (AWB) using the Fancourier API in PHP. It covers setting up shipment details, recipient information, sender details, and service options. The code initializes an AwbIntern object, populates its properties, and then sends it via a CreateAwb request. It also includes logic to process the API response, checking for errors and displaying AWB numbers or error messages. ```php setService('Cont Colector') ->setPaymentType(Fancourier\Request\CreateAwb::TYPE_SENDER) // TYPE_RECIPIENT for recipient pays ->setParcels(1) ->setWeight(2.5) // in kg ->setSizes(30, 20, 15) // length, height, width in cm ->setReimbursement(199.99) // cash on delivery amount ->setDeclaredValue(500) // insured value ->setContents('Electronics - SKU-1234, SKU-5678') ->setNotes('Fragile - handle with care') ->setBank('RAIFFEISEN BANK') ->setIban('RO53RZBR0000060009520959') // Recipient details ->setRecipientName('John Doe') ->setContactPerson('John Doe') ->setPhone('0723000000') ->setAltPhone('0724000000') ->setEmail('john@example.com') ->setCounty('Bucuresti') ->setCity('Sector 1') ->setStreet('Strada Victoriei') ->setNumber('10') ->setBuilding('A') ->setEntrance('2') ->setFloor('3') ->setApartment('42') ->setPostalCode('010061') // Sender details (optional - uses account defaults if not set) ->setSenderName('My Company SRL') ->setSenderPhone('0721000000') ->setSenderCounty('Arad') ->setSenderCity('Arad') ->setSenderStreet('Str Lunga') ->setSenderNumber('1') // Service options ->addOption('S') // Saturday delivery ->addOption('X'); // ePod electronic confirmation $request = new Fancourier\Request\CreateAwb(); $request->addAwb($awb); $response = $fan->createAwb($request); if ($response->isOk()) { $results = $response->getAll(); foreach ($results as $awbResult) { if ($awbResult->hasErrors()) { echo "AWB Creation Failed:\n"; print_r($awbResult->getErrors()); } else { echo "AWB Number: " . $awbResult->getAwb() . "\n"; print_r($awbResult->getDetails()); } } } else { echo "Error: " . $response->getErrorMessage(); } ``` -------------------------------- ### Create Courier Order with Fancourier API Source: https://context7.com/shusaura85/fancourier-api/llms.txt Schedules a courier pickup for shipments by setting order details, parcel information, pickup date and time, and recipient address. It utilizes the Fancourier SDK to build the request and handle the response, returning an order ID on success or an error message. ```php setOrderType('Standard') // 'Standard' or 'Express Loco ...' ->setParcels(5) ->setEnvelopes(2) ->setWeight(15) // Total weight in kg ->setSizes(50, 40, 40) // Estimated max dimensions ->setPickupDate(date('Y-m-d', strtotime('+1 day'))) // Tomorrow ->setPickupHours('09:00', '17:00') // Min 2 hour window ->setNotes('Please call before arrival') // Pickup address (optional - uses account default if not set) ->setRecipientName('My Company SRL') ->setContactPerson('John Manager') ->setPhone('0721000000') ->setCounty('Bucuresti') ->setCity('Sector 1') ->setStreet('Str Victoriei') ->setNumber('100') ->setBuilding('A') ->setFloor('2'); $response = $fan->createCourierOrder($request); if ($response->isOk()) { $orderId = $response->getData(); echo "Courier Order Created - ID: " . $orderId; } else { echo "Error: " . $response->getErrorMessage(); } ``` -------------------------------- ### Print AWB in ZPL format using Fancourier API (PHP) Source: https://github.com/shusaura85/fancourier-api/blob/main/README.md This snippet demonstrates how to request an AWB in ZPL (Zebra Programming Language) format for label printers. It's important to note that ZPL and PDF cannot be requested simultaneously. The response contains the ZPL data if the request is successful. ```php $request = new Fancourier\Request\PrintAwb(); $request ->setZpl(true) ->setAwb('2150900120086'); ``` ```php $response = $fan->printAwb($request); if ($response->isOk()) { echo $response->getData(); } else { var_dump($response->getErrorMessage()); print_r($response->getAllErrors()); } ``` -------------------------------- ### Get AWB Confirmations - PHP Source: https://github.com/shusaura85/fancourier-api/blob/main/docs/Classes overview.md Retrieves delivery confirmations for one or more AWBs. The `Objects\GetAwbConfirmations` class is associated with this function, and the `Fancourier::getAwbConfirmations()` method fetches the confirmation data. ```PHP ``` -------------------------------- ### Print AWB Labels (PDF, HTML, ZPL) using Fancourier API Source: https://context7.com/shusaura85/fancourier-api/llms.txt This code demonstrates how to generate printable AWB labels in PDF, HTML, and ZPL formats using the Fancourier API. It allows specifying the output format, size, and language. The generated data can be saved to files or output directly. ```php setPdf(true) ->setSize('A5') // '', 'A4', 'A5', or 'A6' (A6 only with ePod) ->setLang('ro') // 'ro' or 'en' ->addAwb('2150900120084') ->addAwb('2150900120085'); $response = $fan->printAwb($request); if ($response->isOk()) { // Save as PDF file file_put_contents('awb_labels.pdf', $response->getData()); echo "PDF saved successfully"; } else { echo "Error: " . $response->getErrorMessage(); } // HTML format $request = new Fancourier\Request\PrintAwb(); $request ->setPdf(false) ->addAwb('2150900120084'); $response = $fan->printAwb($request); if ($response->isOk()) { echo $response->getData(); // Output HTML directly } // ZPL format for label printers $request = new Fancourier\Request\PrintAwb(); $request ->setZpl(true) ->setDpi(203) // DPI for label printer (203 or 300 common) ->addAwb('2150900120084'); $response = $fan->printAwb($request); if ($response->isOk()) { file_put_contents('awb_label.zpl', $response->getData()); } ``` -------------------------------- ### Create Bulk Domestic AWBs with Fancourier API (PHP) Source: https://context7.com/shusaura85/fancourier-api/llms.txt This PHP snippet demonstrates how to create multiple domestic Air Waybills (AWBs) in a single request using the Fancourier API. It involves creating multiple AwbIntern objects, each with its specific shipment details, and adding them to a single CreateAwb request object. The code then sends the request and iterates through the response to report the status of each AWB creation, including any errors encountered. ```php setService('Cont Colector') ->setPaymentType(Fancourier\Request\CreateAwb::TYPE_SENDER) ->setParcels(1) ->setWeight(1) ->setReimbursement(99.99) ->setRecipientName('Customer One') ->setPhone('0723000001') ->setCounty('Cluj') ->setCity('Cluj-Napoca') ->setStreet('Str Memorandumului') ->setNumber('5'); $request->addAwb($awb1); // Second AWB $awb2 = new Fancourier\Objects\AwbIntern(); $awb2 ->setService('Cont Colector') ->setPaymentType(Fancourier\Request\CreateAwb::TYPE_SENDER) ->setParcels(2) ->setWeight(3.5) ->setReimbursement(249.99) ->setRecipientName('Customer Two') ->setPhone('0723000002') ->setCounty('Timis') ->setCity('Timisoara') ->setStreet('Bd Mihai Viteazu') ->setNumber('12'); $request->addAwb($awb2); // Third AWB $awb3 = new Fancourier\Objects\AwbIntern(); $awb3 ->setService('Cont Colector') ->setPaymentType(Fancourier\Request\CreateAwb::TYPE_SENDER) ->setParcels(1) ->setWeight(0.5) ->setReimbursement(49.99) ->setRecipientName('Customer Three') ->setPhone('0723000003') ->setCounty('Iasi') ->setCity('Iasi') ->setStreet('Str Palat') ->setNumber('3'); $request->addAwb($awb3); $response = $fan->createAwb($request); if ($response->isOk()) { $results = $response->getAll(); echo "Created " . count($results) . " AWBs\n"; foreach ($results as $index => $awbResult) { echo "\nAWB #" . ($index + 1) . ":\n"; if ($awbResult->hasErrors()) { echo " Failed: "; print_r($awbResult->getErrors()); } else { echo " AWB Number: " . $awbResult->getAwb() . "\n"; } } } else { echo "Error: " . $response->getErrorMessage(); } ```