what is order placed response structure?

trade_then
@tonystark

when we place an order then the response when json deserialized is
{"status":"success","data":{"order_id":"180213000027740"}}
it only gives status and order_id.
Since data: part is dynamic in your code, does that mean it can contain something more than OrderId
in future or would below representation hold right and wont break-up.

public class OrderPlacedResponse
{

[DataMember]
public string status { get; set; }
[DataMember]
public string message { get; set; }
[DataMember]
public string error_type { get; set; }
[DataMember]
public OnlyOrderId data { get; set; }

public OrderPlacedResponse()
{ }

public OrderPlacedResponse( Dictionary<string,dynamic> response )
{
data = new OnlyOrderId () ;

if ( response == null ) return ;

if ( response.Keys?.Contains("status") ?? false )
status = response["status"] ;

if ( response.Keys?.Contains("data") ?? false ) {

var a = ( Dictionary<string,dynamic> ) response["data"] ;
if ( a?.Keys?.Contains("order_id") ?? false )
{
data.order_id = a["order_id"] ;
}
}
if ( response.Keys?.Contains( "message" ) ?? false ) {
message = response["message"] ;
}
if ( response.Keys?.Contains( "error_type" ) ?? false ) {
error_type = response["error_type"] ;
}

}

}

Thanks
Regards


This discussion has been closed.