### Install CourierDZ Library with Composer Source: https://github.com/piteurstudio/courierdz/blob/main/README.md Use this command to install the Courier CourierDZ PHP library as a dependency in your project using the Composer package manager. ```bash composer require piteurstudio/courierdz ``` -------------------------------- ### Example Output for Retrieving a Label Source: https://github.com/piteurstudio/courierdz/blob/main/README.md Provides examples of the expected output structure when retrieving a shipping label using the `orderLabel` method. The output is an array indicating the label type ('pdf' or 'url') and the corresponding data (base64 string or URL). ```json [ [type] => 'pdf' [data] => 'base64 encoded string' ] -- OR -- [ [type] => 'url' [url] => 'https://example.com/label.pdf' ] ``` -------------------------------- ### Initializing Shipping Provider in PHP Source: https://github.com/piteurstudio/courierdz/blob/main/DOCUMENTATION.md This snippet demonstrates how to initialize a shipping provider instance using the CourierDZ facade or by directly instantiating a provider class. It shows examples of credential structures for different providers like Ecotrack, Procolis (ZREXPRESS), Yalidine, and Mayestro Delivery. ```php // Ecotrack providers $credentials = ['token' => '****']; // Procolis providers ( ZREXPRESS ) $credentials = ['id' => '****', 'token' => '****']; // Yalidine providers $credentials = ['token' => '****', 'key' => '****']; // Mayestro Delivery providers $credentials = ['token' => '****']; $shipping_provider = CourierDZ::provider(ShippingProvider::ZREXPRESS, $credentials); // or $shipping_provider = new XyzProvider($credentials); // where Xyz is the provider name ``` -------------------------------- ### Getting Provider Metadata in PHP Source: https://github.com/piteurstudio/courierdz/blob/main/DOCUMENTATION.md This code snippet shows how to retrieve specific metadata for an initialized shipping provider instance using the `metadata()` method. This can provide details about the provider's capabilities or configuration. ```php $metadata = $shipping_provider->metadata(); ``` -------------------------------- ### Getting Order Creation Validation Rules in CourierDZ PHP Source: https://github.com/piteurstudio/courierdz/blob/main/README.md Shows how to retrieve the validation rules required for creating an order for a specific shipping provider using the `getCreateOrderValidationRules` method. This helps determine the necessary fields for the `createOrder` method. ```php $rules = $shipping_provider->getCreateOrderValidationRules(); ``` -------------------------------- ### Getting Parcel Creation Validation Rules in PHP Source: https://github.com/piteurstudio/courierdz/blob/main/DOCUMENTATION.md This snippet demonstrates how to retrieve the validation rules required for creating a parcel or order for the specific shipping provider. This method helps determine the necessary fields and their formats before attempting to create an order. ```php $rules = $shipping_provider->getCreateOrderValidationRules(); ``` -------------------------------- ### Getting Parcel/Order Details in PHP Source: https://github.com/piteurstudio/courierdz/blob/main/DOCUMENTATION.md This snippet demonstrates how to retrieve the detailed information for a specific parcel or order using its tracking ID via the `getOrder()` method. The structure and content of the returned array may vary depending on the specific shipping provider. ```php /* * return array of order details * Note : results may vary depending on the provider */ $result = $shippingService->getOrder('CourierDz-123'); ` ``` -------------------------------- ### Initialize Shipping Provider with Credentials Source: https://github.com/piteurstudio/courierdz/blob/main/README.md This snippet shows how to initialize a specific shipping provider instance using the CourierDZ library. It demonstrates different credential structures required for various providers and two methods for instantiation. ```php // Ecotrack providers $credentials = ['token' => '****']; // Procolis providers ( ZREXPRESS ) $credentials = ['id' => '****', 'token' => '****']; // Yalidine providers $credentials = ['token' => '****', 'key' => '****']; // Mayestro Delivery providers $credentials = ['token' => '****']; $shipping_provider = CourierDZ::provider(ShippingProvider::ZREXPRESS, $credentials); // or $shipping_provider = new XyzProvider($credentials); // where Xyz is the provider name ``` -------------------------------- ### Running Tests for CourierDZ Package using Bash Source: https://github.com/piteurstudio/courierdz/blob/main/README.md Shows the command line instruction to execute the test suite for the CourierDZ package using Composer. This command is typically run in the project's root directory to verify functionality. ```bash composer test ``` -------------------------------- ### Creating a Parcel/Order using CourierDZ PHP Source: https://github.com/piteurstudio/courierdz/blob/main/README.md Demonstrates how to create a new shipping order (parcel) using the `createOrder` method of a shipping provider instance. The method accepts an array of order details. Note that the required fields and response format may vary depending on the specific provider. ```php /* * return array of provider response * Note : results may vary depending on the provider */ $result = $shipping_provider->createOrder([ 'Tracking' => 'CourierDz-123', 'TypeLivraison' => 1, 'TypeColis' => 0, 'Confrimee' => 0, 'Client' => 'Mohamed', 'MobileA' => '0990909090', 'MobileB' => '0880808080', 'Adresse' => 'Rue 39', 'IDWilaya' => "09", 'Commune' => 'Maraval', 'Total' => "2000", 'Note' => 'test test', 'TProduit' => 'Article1', "id_Externe" => 'CourierDz-123', "Source" => 'CourierDz', ])) ``` -------------------------------- ### Listing Available Providers in PHP Source: https://github.com/piteurstudio/courierdz/blob/main/DOCUMENTATION.md This snippet demonstrates how to use the `CourierDZ::providers()` static method to retrieve metadata for all available shipping providers integrated with the library. This can be used to dynamically list or select providers. ```php use CourierDZ\CourierDZ; $providersMetaData = CourierDZ::providers(); ``` -------------------------------- ### Creating a Parcel/Order in PHP Source: https://github.com/piteurstudio/courierdz/blob/main/DOCUMENTATION.md This code snippet shows how to create a parcel or order using the `createOrder` method of the shipping provider instance. It takes an array of order details as input and returns an array representing the provider's response. The required fields for the order data depend on the specific provider's requirements. ```php /* * return array of provider response * Note : results may vary depending on the provider */ $result = $shipping_provider->createOrder([ 'Tracking' => 'CourierDz-123', 'TypeLivraison' => 1, 'TypeColis' => 0, 'Confrimee' => 0, 'Client' => 'Mohamed', 'MobileA' => '0990909090', 'MobileB' => '0880808080', 'Adresse' => 'Rue 39', 'IDWilaya' => "09", 'Commune' => 'Maraval', 'Total' => "2000", 'Note' => 'test test', 'TProduit' => 'Article1', "id_Externe" => 'CourierDz-123', "Source" => 'CourierDz', ]) ``` -------------------------------- ### Retrieving Shipping Rates in PHP Source: https://github.com/piteurstudio/courierdz/blob/main/DOCUMENTATION.md This code snippet shows how to fetch shipping rates using the `getRates()` method. It demonstrates retrieving all available rates, rates to a specific destination wilaya, or rates between specified origin and destination wilayas, depending on the provider's API capabilities. ```php /* * return array of rates of shipping from one wilaya to another * or all rates depending on the parameters / provider api. */ $rates = $shipping_provider->getRates(); // all rates $rates = $shipping_provider->getRates(null , $to_wilaya_id); // rates to specific wilaya $rates = $shipping_provider->getRates($from_wilaya_id , $to_wilaya_id); // Yalidine require $from_wilaya_id , $to_wilaya_id ``` -------------------------------- ### Validating Provider Credentials in PHP Source: https://github.com/piteurstudio/courierdz/blob/main/DOCUMENTATION.md This snippet demonstrates how to check the validity of the credentials provided during the initialization of a shipping provider instance using the `testCredentials()` method. It returns a boolean value indicating whether the credentials are valid. ```php /* * Check if the provided credentials are valid. * * return bool */ echo $shipping_provider->testCredentials() ? 'Valid.' : 'Invalid.'; ``` -------------------------------- ### Retrieving a Parcel/Order Label in CourierDZ PHP Source: https://github.com/piteurstudio/courierdz/blob/main/README.md Illustrates how to fetch a shipping label for a specific order using the `orderLabel` method. The method takes the order tracking ID as input and returns an array containing the label data, which can be a base64 encoded string or a URL. ```php /* * return array of label data ( base64 encoded string or url ) */ $label = $shipping_provider->orderLabel('CourierDz-123'); ``` -------------------------------- ### Retrieving Shipping Label in PHP Source: https://github.com/piteurstudio/courierdz/blob/main/DOCUMENTATION.md This code snippet shows how to retrieve the shipping label for a previously created order using its tracking ID. The `orderLabel` method returns an array containing the label data, which can be a base64 encoded string or a URL, depending on the provider. ```php /* * return array of label data ( base64 encoded string or url ) */ $label = $shipping_provider->orderLabel('CourierDz-123'); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.