This Get Order Details endpoint allows a developer to pull the details of a single order.
NOTE: We’ll send new order notification to the webhook provided by the Integrator to receive any new event from DiDiFood. Please keep differentiate them with type. For more details please check the documentation in Order Webhooks.
Request Path Parameter
Name Type Description Required Example
auth_token string The auth_token for the shop. Yes ZGQ5ZjVlZGUyYmFhNDM2ZmE0ZDA5OTE5ZjI1YzBhNjU=
order_id long The ID of the order in DiDiFood’s system. Yes 5764607653830199020
Response Body Parameters
Name Type Description
order_id long 19-digit unique identification number order in DiDiFood system that is used for tracking and after sales services
status int The current state of the order. Check the table below for details.
shop_accept_status int The status of the order
before_status int The status of the order before the one displayed in status. Check the table below for details
order_index int A handshake number (which is much simplier than the 19 digit order_id) of the order that is used to match the number in the courier APP. This number will be repeated in every Store, every day starting from 1 until the last secuence number of the order of the day in DiDiFood
remark string Instructions from a consumer in regards to the preparation of the order. This function can be enabled or unenabled in the DiDiStore application
city_id int The ID of the city in DiDi’s system
country string The identification of the country of the order
timezone string The identification of the time zone of the order
pay_type int The payment method chosen by the consumer to DiDiFood. It is important to highlight that when they pay cash it doesn't mean that the store needs to receive cash. It is essencial to combine the results of pay_type 2 with values > 0 under shop_paid_money for DiDiFood delivery and pay_type 2 with values > 0 under customer_need_paying_money for Store delivery, to determine whether a Store should receive any cash from the courier or the consumer depending on the delivery type. Map directly the values received in the values of shop_paid_money or customer_need_paying_money to avoid any discrepancy in the store payment reconciliation with DiDiFood. Values for pay_type: 1-Online payment; 2-Cash; 3-POS (Payment method that requires the courier to take a POS machine to receive the payment from consumer); 4: Wallet (when DiDi’s wallet/99Pay is selected); 5: PayPay without secret; 6: PayPay with secret
delivery_type int How the order will be delivered. This depends on the agreement of the store with DiDiFood. Values for delivery_type: 1-Delivery done by DiDi; 2-Delivery done by the store
expected_cook_eta int It is recommended to inform the shop prepared before this time. After this time, the rider can report the meal timeout. Unit: second
expected_arrived_eta int The time DiDiFood that the order will be delivered to the consumer. Unit: seconds
create_time int When the order was placed. Unit: unix_timestamp
pay_time int When the order was paid. Unit: unix_timestamp
complete_time int When the order was completed. Unit: unix_timestamp
cancel_time int When the order was canceled. Unit: unix_timestamp
shop_confirm_time int When the order was confirmed by the shop. Unit: unix_timestamp
price array A structure with all the order’s prices. Check below for all the information sent. Note: Price is always an integer value (never decimals) because the price is set in the lowest denomination (e.g. cents for MXN currency, not Peso)
shop struct A structure with the shop information. Check below for all the information sent.
receive_address struct A structure with the customer information. Check below for all the information sent
order_items struct A structure with the item information. Check below for all the information sent
promotions array A structure with all promotion information of the whole order. Check below for all the information sent
Order Status
DiDi Status
100 Order created
200 Order accepted (The store sent confirmation)
400 The rider took the order for delivery
500 The rider arrived at the customer's location
600 Order finished, completed
901, 902 Cancelation -- Cancelled by the consumer
921, 923 Cancelation -- Cancelled by the store (after receiving the order)
922 Cancelation -- Cancelled by the store due to timeout (Not confirmed order acceptance within the permitted timeframe)
961 Cancelation -- Cancelled by DiDiFood customer service due to request of the consumer
971, 981 Cancelation -- Cancelled by courier
Response Body Parameters - Price
Note: Price is always an integer value up to 2 decimals. The price is set in the lowest denomination of the currency of the applicable country. Mexico and Peru allows decimals , therefore you can receive prices of 123.45 as 12345. Colombia and Costa Rica, decimals are not allowed, you'll never receive prices like 123.45, but you will receive prices like 123.00 as 12300.
Assistant
DiDiFood price structure has 3 different models depending on:
The Integrator collaboration start date with DiDiFood.
The delivery method selected by the Store to collaborate with DiDiFood.
Price Model 1 -- DiDiFood delivery and Integrators who started collaboration with DiDiFood after 2021-03-09 (Current used)
Name Type Description
order_price int The sum of all the item prices of the order. This price is without any promotion applied and does NOT contain any amount related to the delivery fee.
items_discount int The total promotion (including delivery) of the order perceived by the consumer
delivery_discount int The total promotion of delivery perceived by the consumer
shop_paid_money int The value the couriers will pay in the store when taking the order when the consumer selects cash payment (pay_type 2). If the store allows cash payment, you will also need to have the function of Confirm Cash Payment allowing the store staff confirm that the cash has been duly received. The value of this field will only be provided after DiDiFood assigns the courier. DiDiFood recommends that by receiving pay_type 2, you need to also call the Get Order Details endpoint to ensure that there is no update in this field
refund_price int The total refund amount of the order
in_sale_refund_to_c_fee int The amount that the order was underbilled to the Store for the cancellation of some items after the in-sale refund occurred.
Price Model 2 -- Store Delivery and Integrators who started collaboration with DiDiFood after 2021-03-09 (Current used)
Name Type Description
order_price int The sum of all the item prices of the order. This price is without any promotion applied and does NOT contain any amount related to the delivery fee
delivery_price int The actual delivery cost charged less all types of delivery promotions applied to the consumer
delivery_discount int The total promotion of delivery perceived by the consumer
items_discount int The total promotion (including delivery) of the order perceived by the consumer
store_charged_delivery_price int is the delivery cost set by store without any promotions
real_price int Total of the order to be received by the store (including delivery) without the promotions subsidized by DiDiFood
real_pay_price int Total of the order (including delivery) paid by the consumer
refund_price int The total refund amount of the order
others_fees array A structure with other fees as described below
customer_need_paying_money int The amount customer needs to pay
in_sale_refund_to_c_fee int This field represents the amount that the order was underbilled to the Store for the cancellation of some items after the in-sale refund occurred
Other Fees Structure under price model 2
Name Type Description
small_order_price int The amount charged by the Store to the consumer for placing an order with amount less than the acceptable one to be delivered
total_tip_money int The amount of tips that the consumer is paying to the couriers of the Store
service_price int An additional service amount charged to the consumer
coupon_discount int The total amount of coupons used by the consumer to place the order
Price Model 3 -- Integrators who started collaboration with DiDiFood before 2021-03-09 (Reference only)
Name Type Description
order_price int The sum of all the item prices of the order. This price is without any promotion applied
delivery_price int The actual delivery cost charged less all types of delivery promotions applied to the consumer
store_charged_delivery_price" int is the delivery cost set by store without any promotions
real_price int Total of the order to be received by the store (including delivery) without the promotions subsidized by DiDiFood
real_pay_price int Total of the order (including delivery) paid by the consumer
shop_paid_money int The value the couriers will pay in the store when taking the order when the consumer selects cash payment (pay_type 2). If the store allows cash payment, you will also need to have the function of Confirm Cash Payment allowing the store staff confirm that the cash has been duly received. The value of this field will only be provided after DiDiFood assigns the courier. DiDiFood recommends that by receiving pay_type 2, you need to also call the Get Order Details endpoint to ensure that there is no update in this field
refund_price int The total refund amount of the order.
currency string Provides the type of currency applicable to the order like "COP", "MXN".
in_sale_refund_to_c_fee int The amount that the order was underbilled to the Store for the cancellation of some items after the in-sale refund occurred.
Response Body Parameters - Shop
Name Type Description
shop_id long The unique identification number of a store in DiDiFood's system
app_shop_id string The unique identification string of a store in the Store/Integrator's system. DiDiFood supports letters, numbers and special characters, but spaces are not permitted within the string
shop_addr string The address of the Store
shop_name string The name of the Store displayed to the customer
shop_phone array A json structure of the phone number of the store. Ex: [{"calling_code": 52,"phone": 15011498822,"type": "0"}]
Response Body Parameters - Receive Address
IMPORTANT: DiDiFood Delivery and Integrators who started collaboration with DiDiFood after 2021-03-09 will receive the receive_address array with Consumer processed with DiDiFood privacy protection policy. The ones whiles who started collaboration with DiDiFood before 2021-03-09 will still receive the full information.
Receive Address - Without being Processed according to the Data Privacy Policy
Name Type Description
uid int The unique identification of a Consumer in DiDiFood system
name string The name that the Consumer input in DiDiFood application. This is not mandatory to the Consumer, therefore it can come without any value""
first_name string The first name that the Consumer input in DiDiFood application. It may come without any value "" as it is not mandatory for the Consumer
last_name string The last name that the Consumerinput in DiDiFood application. It may come without any value "" as it is not mandatory for the Consumer
calling_code string The country code of the Consumer's phone number
phone string Consumer's phone number
city string Delivery address city’s name
country_code string Shorthand code for the delivery address country
poi_address string Delivery address mapped by POI. An object representing the physical location
house_number string Delivery address house number
poi_lat string Latitude for the delivery address in Google Maps
poi_lng string Longitude for the delivery address in Google Maps
coordinate_type string Type of the coordinates being used
poi_display_name string The address displayed in DiDiFood application to the Consumer
Receive Address - Being Processed according to the Data Privacy Policy
Name Type Description
uid int Processed value: 0
name string Processed value: privacy protection
first_name string Processed value: privacy protection. If you want DiDiFood to show the first_name instead of the last_name, please contact DiDiFood to set it up. Once set up, it may come without any value "" as it is not mandatory for the Consumer
last_name string Consumer's last name. It may come without any value "" as it is not mandatory for the Consumer. If you want DiDiFood to show the first_name instead of the last_name, please contact DiDiFood to set it up
calling_code string The country code of the user’s phone number.
phone string Processed value: Ex: 000****1406
city string Delivery address city’s name.
country_code string Shorthand code for the delivery address country.
poi_address string Processed value: privacy protection
house_number string Processed value: privacy protection
poi_lat string Processed value: floor the numeric, such as 25
poi_lng string Processed value: floor the numeric, such as -101
coordinate_type string Type of the coordinates being used.
poi_display_name string Processed value: privacy protection
Response Body Parameters - Order items
Name Type Description
app_item_id string The unique identification of an item in the Store / Integrator's system
name string The item name that is displayed in the menu of the Store
sku_price integer The price for each item/subItem. Note: Price is always an integer value and is set in the lowest denomination (e.g. cents for MXN, not Peso).
total_price integer The total price of the item without any promotion: and is calculated in accordance to this equation: [(sku_price of the main item + sku_price of the subitems) * amount of the main item]; Note: Price is always an integer value (never decimals) because the price is set in the lowest denomination (e.g. cents for MXN currency, not Peso).
amount integer Quantity of the item.
submit_refund_amount integer This field represents the number of items refunded: Amount − submit_refund_amount = Actual number of items currently in order.
sub_item_list struct List of the selected subitems of the store's modifier groups. Note: The amount in the sub_item_list is the quantity of the sub_item for each main item, meaning that the real required quantity of subitems that needs to be served to the Consumer is [(amount under the main item) * (amount under the sub_item_list)]
real_price integer The actual amount paid by the Consumer for the item
promotion_detail array A json structure that contains all details related to the item. Check below for more details
promo_list array List of all promotion under the item
Response Body Parameters - Promotion Detail (Item level)
DiDiFood allows the Consumers to apply different types of promotions to a certain item to maximize their experience in the sense of value for money, meaning that they can apply parallely coupons and price discount to the same item in the same order.
Promotion detail provides the summary of all promotions that are applicable to a certain item.
Name Type Description
promo_type int The type of the promotion that is applicable to the item. Please see more details in https://developer.didi-food.com/en-US/openapi > Order API > Promotions. When the Consumer uses more than one type of promotion, DiDiFood will always display the value 2
promo_discount int The total promotion amount that is applicable to the item and perceived by the Consumer. If the same item is chosen more than once, to obtain the unit promotion amount perceived by the Consumer under the certain promo_type, this promo_discount must be divided into the amount of the main item
shop_subside_price int The total promotion amount that is applicable to the item and subsidized/invested by the Store. If the same item is chosen more than once, to obtain the unit promotion amount perceived by the Consumer under the certain promo_type, this promo_discount must be divided into the amount of the main item
Response Body Parameters - Promo List (Item level)
DiDiFood allows the Consumers to apply different types of promotions to a certain item to maximize their experience in the sense of value for money, meaning that they can apply parallely coupons and price discount to the same item in the same order.
Promotion detail provides the each of the promotions that are applicable to a certain item.
Name Type Description
promo_type int The specific type of the promotion that is applicable to the item. Please see more details in https://developer.didi-food.com/en-US/openapi > Order API > Promotions
promo_discount int The specific promotion amount that is applicable to the item and perceived by the Consumer. If the same item is chosen more than once, to obtain the unit promotion amount perceived by the Consumer under the certain promo_type, this promo_discount must be divided into the amount of the main item
shop_subside_price int The specific promotion amount that is applicable to the item and subsidized/invested by the Store. If the same item is chosen more than once, to obtain the unit promotion amount perceived by the user under the certain promo_type, this promo_discount must be divided into the amount of the main item
Response Body Parameters - Promotion (Order level)
Promotion provides the summary of all promotions that are applicable to a specific order. It lists out all kinds of promotions in terms of item level, order level and delivery level.
Name Type Description
promo_type int The type of the promotion that is applicable to the order. Please see more details in https://developer.didi-food.com/en-US/openapi > Order API > Promotions. When the Consumer uses more than one type of promotion in an item, DiDiFood will always display the value 2 for that item promo
promo_discount int The promotion amount that is applicable to that specific listed promotion and perceived by the Consumer
shop_subside_price int The promotion amount that is applicable to that specific listed promotion and subsidized/invested by the Store
Response Body Parameters - Shopper Info
Name Type Description
name string The name of the shopper.The information is only sent in Grocery Shopper Mode stores.
phone string The phone of the shopper.The information is only sent in Grocery Shopper Mode stores.
Certainly! Below are the C# model classes designed to represent the response from the DiDiFood "Get Order Details" API endpoint based on the provided documentation. These classes are structured to accurately reflect the hierarchical nature of the JSON response, including handling different price models, nested objects, and arrays.
Overview
Main Response Class: OrderDetailResponse encapsulates all the response data.
Nested Classes: Represent various sections of the response such as Price, Shop, ReceiveAddress, OrderItem, Promotion, etc.
Handling Different Price Models: Utilizes inheritance to represent different price models (PriceModel1, PriceModel2, PriceModel3) derived from a base Price class.
JSON Serialization Attributes: Uses [JsonProperty] attributes from Newtonsoft.Json to map JSON property names to C# property names, ensuring accurate serialization/deserialization.
Nullable Types: Represents optional fields using nullable types (int?, long?, etc.) to handle cases where data might be missing or empty.
C# Model Classes
First, ensure you have the Newtonsoft.Json NuGet package installed, as it's used for JSON serialization attributes.
csharp
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace DiDiFoodApi.Models
{
public class OrderDetailResponse
{
[JsonProperty("order_id")]
public long OrderId { get; set; }
[JsonProperty("status")]
public int Status { get; set; }
[JsonProperty("shop_accept_status")]
public int ShopAcceptStatus { get; set; }
[JsonProperty("before_status")]
public int BeforeStatus { get; set; }
[JsonProperty("order_index")]
public int OrderIndex { get; set; }
[JsonProperty("remark")]
public string Remark { get; set; }
[JsonProperty("city_id")]
public int CityId { get; set; }
[JsonProperty("country")]
public string Country { get; set; }
[JsonProperty("timezone")]
public string Timezone { get; set; }
[JsonProperty("pay_type")]
public int PayType { get; set; }
[JsonProperty("delivery_type")]
public int DeliveryType { get; set; }
[JsonProperty("expected_cook_eta")]
public int ExpectedCookEta { get; set; }
[JsonProperty("expected_arrived_eta")]
public int ExpectedArrivedEta { get; set; }
[JsonProperty("create_time")]
public long CreateTime { get; set; }
[JsonProperty("pay_time")]
public long PayTime { get; set; }
[JsonProperty("complete_time")]
public long CompleteTime { get; set; }
[JsonProperty("cancel_time")]
public long CancelTime { get; set; }
[JsonProperty("shop_confirm_time")]
public long ShopConfirmTime { get; set; }
[JsonProperty("price")]
public Price Price { get; set; }
[JsonProperty("shop")]
public Shop Shop { get; set; }
[JsonProperty("receive_address")]
public ReceiveAddress ReceiveAddress { get; set; }
[JsonProperty("order_items")]
public List<OrderItem> OrderItems { get; set; }
[JsonProperty("promotions")]
public List<Promotion> Promotions { get; set; }
[JsonProperty("shopper_info")]
public ShopperInfo ShopperInfo { get; set; }
}
// Base Price Class
public abstract class Price
{
[JsonProperty("order_price")]
public int OrderPrice { get; set; }
[JsonProperty("items_discount")]
public int ItemsDiscount { get; set; }
[JsonProperty("delivery_discount")]
public int DeliveryDiscount { get; set; }
[JsonProperty("refund_price")]
public int RefundPrice { get; set; }
[JsonProperty("in_sale_refund_to_c_fee")]
public int InSaleRefundToCFee { get; set; }
}
// Price Model 1
public class PriceModel1 : Price
{
[JsonProperty("shop_paid_money")]
public int ShopPaidMoney { get; set; }
}
// Price Model 2
public class PriceModel2 : Price
{
[JsonProperty("delivery_price")]
public int DeliveryPrice { get; set; }
[JsonProperty("store_charged_delivery_price")]
public int StoreChargedDeliveryPrice { get; set; }
[JsonProperty("real_price")]
public int RealPrice { get; set; }
[JsonProperty("real_pay_price")]
public int RealPayPrice { get; set; }
[JsonProperty("others_fees")]
public List<OtherFee> OthersFees { get; set; }
[JsonProperty("customer_need_paying_money")]
public int CustomerNeedPayingMoney { get; set; }
}
// Price Model 3
public class PriceModel3 : Price
{
[JsonProperty("delivery_price")]
public int DeliveryPrice { get; set; }
[JsonProperty("store_charged_delivery_price")]
public int StoreChargedDeliveryPrice { get; set; }
[JsonProperty("real_price")]
public int RealPrice { get; set; }
[JsonProperty("real_pay_price")]
public int RealPayPrice { get; set; }
[JsonProperty("shop_paid_money")]
public int ShopPaidMoney { get; set; }
[JsonProperty("currency")]
public string Currency { get; set; }
}
// Other Fee Structure (Used in Price Model 2)
public class OtherFee
{
[JsonProperty("small_order_price")]
public int SmallOrderPrice { get; set; }
[JsonProperty("total_tip_money")]
public int TotalTipMoney { get; set; }
[JsonProperty("service_price")]
public int ServicePrice { get; set; }
[JsonProperty("coupon_discount")]
public int CouponDiscount { get; set; }
}
// Shop Information
public class Shop
{
[JsonProperty("shop_id")]
public long ShopId { get; set; }
[JsonProperty("app_shop_id")]
public string AppShopId { get; set; }
[JsonProperty("shop_addr")]
public string ShopAddress { get; set; }
[JsonProperty("shop_name")]
public string ShopName { get; set; }
[JsonProperty("shop_phone")]
public List<ShopPhone> ShopPhones { get; set; }
}
public class ShopPhone
{
[JsonProperty("calling_code")]
public int CallingCode { get; set; }
[JsonProperty("phone")]
public long Phone { get; set; }
[JsonProperty("type")]
public string Type { get; set; }
}
// Receive Address
public class ReceiveAddress
{
// Fields when not processed according to Data Privacy Policy
[JsonProperty("uid")]
public int Uid { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("first_name")]
public string FirstName { get; set; }
[JsonProperty("last_name")]
public string LastName { get; set; }
[JsonProperty("calling_code")]
public string CallingCode { get; set; }
[JsonProperty("phone")]
public string Phone { get; set; }
[JsonProperty("city")]
public string City { get; set; }
[JsonProperty("country_code")]
public string CountryCode { get; set; }
[JsonProperty("poi_address")]
public string PoiAddress { get; set; }
[JsonProperty("house_number")]
public string HouseNumber { get; set; }
[JsonProperty("poi_lat")]
public string PoiLat { get; set; }
[JsonProperty("poi_lng")]
public string PoiLng { get; set; }
[JsonProperty("coordinate_type")]
public string CoordinateType { get; set; }
[JsonProperty("poi_display_name")]
public string PoiDisplayName { get; set; }
// Processed fields according to Data Privacy Policy
[JsonProperty("processed_uid")]
public int ProcessedUid { get; set; }
[JsonProperty("processed_name")]
public string ProcessedName { get; set; }
[JsonProperty("processed_first_name")]
public string ProcessedFirstName { get; set; }
[JsonProperty("processed_last_name")]
public string ProcessedLastName { get; set; }
[JsonProperty("processed_phone")]
public string ProcessedPhone { get; set; }
[JsonProperty("processed_poi_address")]
public string ProcessedPoiAddress { get; set; }
[JsonProperty("processed_house_number")]
public string ProcessedHouseNumber { get; set; }
[JsonProperty("processed_poi_lat")]
public string ProcessedPoiLat { get; set; }
[JsonProperty("processed_poi_lng")]
public string ProcessedPoiLng { get; set; }
[JsonProperty("processed_poi_display_name")]
public string ProcessedPoiDisplayName { get; set; }
}
// Order Items
public class OrderItem
{
[JsonProperty("app_item_id")]
public string AppItemId { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("sku_price")]
public int SkuPrice { get; set; }
[JsonProperty("total_price")]
public int TotalPrice { get; set; }
[JsonProperty("amount")]
public int Amount { get; set; }
[JsonProperty("submit_refund_amount")]
public int SubmitRefundAmount { get; set; }
[JsonProperty("sub_item_list")]
public List<SubItem> SubItemList { get; set; }
[JsonProperty("real_price")]
public int RealPrice { get; set; }
[JsonProperty("promotion_detail")]
public PromotionDetail PromotionDetail { get; set; }
[JsonProperty("promo_list")]
public List<PromoList> PromoList { get; set; }
}
public class SubItem
{
[JsonProperty("sub_item_id")]
public string SubItemId { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("sku_price")]
public int SkuPrice { get; set; }
[JsonProperty("amount")]
public int Amount { get; set; }
}
// Promotion Detail at Item Level
public class PromotionDetail
{
[JsonProperty("promo_type")]
public int PromoType { get; set; }
[JsonProperty("promo_discount")]
public int PromoDiscount { get; set; }
[JsonProperty("shop_subside_price")]
public int ShopSubsidePrice { get; set; }
}
// Promo List at Item Level
public class PromoList
{
[JsonProperty("promo_type")]
public int PromoType { get; set; }
[JsonProperty("promo_discount")]
public int PromoDiscount { get; set; }
[JsonProperty("shop_subside_price")]
public int ShopSubsidePrice { get; set; }
}
// Promotion at Order Level
public class Promotion
{
[JsonProperty("promo_type")]
public int PromoType { get; set; }
[JsonProperty("promo_discount")]
public int PromoDiscount { get; set; }
[JsonProperty("shop_subside_price")]
public int ShopSubsidePrice { get; set; }
}
// Shopper Info
public class ShopperInfo
{
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("phone")]
public string Phone { get; set; }
}
}
Explanation of the Classes
OrderDetailResponse: Represents the entire response from the API. It includes all the top-level fields such as order_id, status, shop, price, etc.
Price and Its Models:
Price: An abstract base class that includes common fields across different price models.
PriceModel1, PriceModel2, PriceModel3: Derived classes that include additional fields specific to each price model.
OtherFee: Represents additional fees applicable in Price Model 2.
Shop: Contains information about the shop, including a list of phone numbers represented by the ShopPhone class.
ReceiveAddress: Represents the customer's delivery address. It includes fields for both processed and unprocessed data according to the data privacy policy. Depending on the integrator's collaboration date, only relevant fields will be populated.
OrderItem: Represents each item in the order, including sub-items, real price, and promotions at the item level.
SubItem: Represents sub-items or modifiers for a main order item.
PromotionDetail and PromoList: Capture promotional details at the item level.
Promotion: Represents promotions applied at the order level.
ShopperInfo: Contains information about the shopper, applicable only in Grocery Shopper Mode stores.
Handling Different Price Models
Depending on the integrator's collaboration start date and delivery method, the price field in the response will correspond to one of the three price models. To handle this dynamically during deserialization, you can use a custom JSON converter. However, for simplicity, the above structure uses inheritance to represent different price models. You can determine the price model based on your business logic and cast the Price property to the appropriate derived class.
Example Usage
Here's how you might deserialize the JSON response into the OrderDetailResponse class using Newtonsoft.Json:
csharp
using Newtonsoft.Json;
using DiDiFoodApi.Models;
// Assume jsonResponse is the JSON string obtained from the API
string jsonResponse = /* your JSON response */;
OrderDetailResponse orderDetails = JsonConvert.DeserializeObject<OrderDetailResponse>(jsonResponse);
// Accessing data
long orderId = orderDetails.OrderId;
string shopName = orderDetails.Shop.ShopName;
// and so on...
Notes
Nullable Fields: If certain fields are optional or can be null, consider using nullable types (int?, long?, etc.) in the model classes.
Data Privacy Handling: The ReceiveAddress class includes both unprocessed and processed fields. Depending on the ReceiveAddress data, you may need to implement additional logic to handle which fields are populated.
Dynamic Price Model Handling: If the API response includes a field that indicates the price model, you can implement a custom JSON converter to deserialize into the correct price model class. Alternatively, you can handle this after deserialization by checking which fields are populated.
Validation: Implement validation logic as needed to ensure data integrity when working with these models.
Feel free to extend these models further based on additional requirements or nuances in the API responses.