Mapping JSON to Salesforce Object

PHOTO EMBED

Wed Jun 29 2022 00:05:25 GMT+0000 (Coordinated Universal Time)

Saved by @yinmaster #salesforce #static #keywords #class #apex #json

public class Sale {
public String messageId;
public String eventId;
public Decimal eventSchemaVersion;
public String eventInstanceOriginationDateTime;
public SaleEventData eventData;
}


public class SaleEventData {
public Integer siteId;
public Integer saleId;
public String purchasingClientId;
public List<PaymentDetails> payments;
public String saleDateTime;
public String soldById;
public String soldByName;
public Integer locationId;
public Integer totalAmountPaid;
public List<SaleItemDetails> items;
}

public class PaymentDetails {
public Integer paymentId;
public Integer paymentMethodId;
public String paymentMethodName;
public String paymentAmountPaid;
public Integer paymentLastFour;
public String paymentNotes;
}

public class SaleItemDetails {
public Integer itemId;
public String type;
public String name;
public Integer amountPaid;
public Integer amountDiscounted;
public Integer quantity;
public String recipientClientId;
public Integer paymentReferenceId;
}

Sale mbSale = (Sale)JSON.deserialize(jsonInput, Sale.class);
content_copyCOPY