### Install Doordash PHP SDK using Composer Source: https://github.com/hyperzod/doordash-sdk-php/blob/main/README.md This snippet shows how to install the Doordash PHP SDK using Composer, the dependency manager for PHP. Ensure Composer is installed and accessible in your environment. ```bash composer require hyperzod/doordash-sdk-php ``` -------------------------------- ### GET /deliveries/{order_id} Source: https://context7.com/hyperzod/doordash-sdk-php/llms.txt Retrieves the current status and detailed information of an existing delivery using its unique order ID. ```APIDOC ## GET /deliveries/{order_id} ### Description Retrieves the current status and details of an existing delivery by its order ID. Use this to track delivery progress and get updated ETAs. ### Method GET ### Endpoint /deliveries/{order_id} ### Parameters #### Path Parameters - **order_id** (string) - Required - The unique identifier for the delivery order. ### Request Example $params = ['order_id' => 'ORDER-abc123def456']; ### Response #### Success Response (200) - **delivery_status** (string) - The current state of the delivery (e.g., created, confirmed, picked_up, delivered). - **pickup_address** (string) - The origin address of the delivery. - **dropoff_address** (string) - The destination address of the delivery. #### Response Example { "delivery_status": "delivered", "pickup_address": "901 Market Street, San Francisco, CA 94103", "dropoff_address": "123 Main Street, San Francisco, CA 94105" } ``` -------------------------------- ### Execute Custom API Requests Source: https://context7.com/hyperzod/doordash-sdk-php/llms.txt This snippet shows how to bypass service classes to perform direct API calls. It supports various HTTP methods like GET, POST, and PATCH for endpoints not explicitly covered by the SDK. ```php request('GET', '/deliveries', []); // Custom POST $response = $client->request('POST', '/deliveries/quotes', [ 'pickup_address' => '901 Market Street, San Francisco, CA 94103', 'dropoff_address' => '123 Main Street, San Francisco, CA 94105', 'order_value' => 2500 ]); // Custom PATCH $response = $client->request('PATCH', '/deliveries/ORDER-123', [ 'dropoff_instructions' => 'Updated: Please leave at side gate' ]); ``` -------------------------------- ### Initialize the Client Source: https://context7.com/hyperzod/doordash-sdk-php/llms.txt Initializes the DoordashClient with developer credentials and the API base URL. The client handles JWT token generation automatically. ```APIDOC ## Initialize the Client ### Description Initializes the `DoordashClient` with your DoorDash developer credentials (developer_id, key_id, signing_secret) and the API base URL. This client is the main entry point for all API interactions and automatically handles JWT token generation. ### Method Instantiation of `DoordashClient` class. ### Endpoint N/A (Client-side initialization) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```php delivery; ``` ### Response #### Success Response (200) N/A (Client initialization does not return a response in this context) #### Response Example N/A ``` -------------------------------- ### Initialize DoordashClient Source: https://context7.com/hyperzod/doordash-sdk-php/llms.txt Instantiate the DoordashClient using your developer credentials. This client manages JWT token generation and provides access to delivery services. ```php require_once 'vendor/autoload.php'; use Hyperzod\DoordashSdkPhp\Client\DoordashClient; $client = new DoordashClient( 'your_developer_id', 'your_key_id', 'your_signing_secret', 'https://openapi.doordash.com' ); $deliveryService = $client->delivery; ``` -------------------------------- ### Create a Delivery Job Source: https://context7.com/hyperzod/doordash-sdk-php/llms.txt Create a new delivery by passing an array of pickup and dropoff details to the delivery service. This snippet demonstrates handling the response and catching potential exceptions. ```php $deliveryParams = [ 'external_delivery_id' => 'ORDER-' . uniqid(), 'pickup_address' => '901 Market Street, San Francisco, CA 94103', 'pickup_business_name' => 'My Restaurant', 'pickup_phone_number' => '+14155551234', 'pickup_instructions' => 'Enter through the back door', 'dropoff_address' => '123 Main Street, San Francisco, CA 94105', 'dropoff_business_name' => 'Customer Name', 'dropoff_phone_number' => '+14155555678', 'dropoff_instructions' => 'Leave at door, ring doorbell', 'order_value' => 2500, 'tip' => 500, 'items' => [ ['name' => 'Burger Combo', 'quantity' => 2, 'description' => 'Double cheeseburger with fries'], ['name' => 'Large Drink', 'quantity' => 2, 'description' => 'Coca-Cola'] ] ]; try { $response = $client->delivery->create($deliveryParams); echo "Delivery created successfully!\n"; } catch (Exception $e) { echo "Error creating delivery: " . $e->getMessage() . "\n"; } ``` -------------------------------- ### Implement SDK Error Handling Source: https://context7.com/hyperzod/doordash-sdk-php/llms.txt This snippet illustrates how to catch specific SDK exceptions like InvalidArgumentException and general API errors. Proper error handling ensures application stability when dealing with configuration issues or failed network requests. ```php getMessage() . "\n"; } $client = new DoordashClient('id', 'key', 'secret', 'https://openapi.doordash.com'); try { $delivery = $client->delivery->get(['order_id' => 'non-existent-order']); } catch (Exception $e) { echo "API Error: " . $e->getMessage() . "\n"; error_log("DoorDash API Error: " . $e->getMessage()); } ``` -------------------------------- ### Retrieve Delivery Status with PHP SDK Source: https://context7.com/hyperzod/doordash-sdk-php/llms.txt This snippet demonstrates how to fetch the current status and details of a specific delivery using the order ID. It includes a switch statement to handle various delivery lifecycle states. ```php 'ORDER-abc123def456' ]; try { $delivery = $client->delivery->get($params); echo "Delivery Status: " . $delivery['delivery_status'] . "\n"; switch ($delivery['delivery_status']) { case 'created': echo "Delivery is pending assignment\n"; break; case 'delivered': echo "Order has been delivered!\n"; break; } } catch (Exception $e) { echo "Error retrieving delivery: " . $e->getMessage() . "\n"; } ``` -------------------------------- ### DeliveryService::create() - Create a Delivery Source: https://context7.com/hyperzod/doordash-sdk-php/llms.txt Creates a new delivery job on DoorDash by passing an array containing pickup and dropoff details, order information, and special instructions. ```APIDOC ## POST /delivery ### Description Creates a new delivery job on DoorDash. This method requires detailed information about the pickup location, dropoff location, order details, and any specific instructions for the delivery. ### Method POST ### Endpoint /delivery ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **external_delivery_id** (string) - Required - A unique identifier for the delivery from your system. - **pickup_address** (string) - Required - The full address for the pickup location. - **pickup_business_name** (string) - Optional - The name of the business at the pickup location. - **pickup_phone_number** (string) - Required - The phone number for the pickup contact. - **pickup_instructions** (string) - Optional - Special instructions for the pickup. - **dropoff_address** (string) - Required - The full address for the dropoff location. - **dropoff_business_name** (string) - Optional - The name of the business at the dropoff location. - **dropoff_phone_number** (string) - Required - The phone number for the dropoff contact. - **dropoff_instructions** (string) - Optional - Special instructions for the dropoff. - **order_value** (integer) - Required - The total value of the order in cents. - **tip** (integer) - Optional - The tip amount in cents. - **items** (array) - Optional - An array of items included in the delivery. - **name** (string) - Required - The name of the item. - **quantity** (integer) - Required - The quantity of the item. - **description** (string) - Optional - A description of the item. ### Request Example ```json { "external_delivery_id": "ORDER-12345", "pickup_address": "901 Market Street, San Francisco, CA 94103", "pickup_business_name": "My Restaurant", "pickup_phone_number": "+14155551234", "pickup_instructions": "Enter through the back door", "dropoff_address": "123 Main Street, San Francisco, CA 94105", "dropoff_business_name": "Customer Name", "dropoff_phone_number": "+14155555678", "dropoff_instructions": "Leave at door, ring doorbell", "order_value": 2500, "tip": 500, "items": [ { "name": "Burger Combo", "quantity": 2, "description": "Double cheeseburger with fries" }, { "name": "Large Drink", "quantity": 2, "description": "Coca-Cola" } ] } ``` ### Response #### Success Response (200) - **external_delivery_id** (string) - The unique identifier for the delivery. - **delivery_status** (string) - The current status of the delivery. - **pickup_time_estimated** (string) - The estimated pickup time. - **dropoff_time_estimated** (string) - The estimated dropoff time. #### Response Example ```json { "external_delivery_id": "ORDER-12345", "delivery_status": "pending", "pickup_time_estimated": "2023-10-27T10:00:00Z", "dropoff_time_estimated": "2023-10-27T10:30:00Z" } ``` ``` -------------------------------- ### Custom API Requests Source: https://context7.com/hyperzod/doordash-sdk-php/llms.txt Allows developers to perform arbitrary HTTP requests to the DoorDash API for endpoints not explicitly covered by the SDK service classes. ```APIDOC ## Custom API Requests ### Description For endpoints not covered by the service classes, use the client's request method directly to make custom API calls with any HTTP method. ### Method GET, POST, PATCH, DELETE ### Endpoint /deliveries/* ### Parameters #### Request Body - **method** (string) - Required - The HTTP verb (GET, POST, PATCH, etc.). - **path** (string) - Required - The API endpoint path. - **params** (array) - Optional - The payload or query parameters for the request. ### Request Example $response = $client->request('POST', '/deliveries/quotes', [ 'pickup_address' => '901 Market Street, San Francisco, CA 94103', 'dropoff_address' => '123 Main Street, San Francisco, CA 94105', 'order_value' => 2500 ]); ### Response #### Success Response (200) - **response** (array) - The decoded JSON response from the DoorDash API. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.