/* JSON EXAMPLE
{
"messageId": "PfNxko2cChY94KsiU9cvUL",
"eventId": "client.updated",
"eventSchemaVersion": 1.0,
"eventInstanceOriginationDateTime": "2022-03-07T00:37:23Z",
"eventData": {
"siteId": 123,
"saleId": 96,
"purchasingClientId": "100001049",
"payments": [
{
"paymentId": 103,
"paymentMethodId": 14,
"paymentMethodName": "Cash",
"paymentAmountPaid": 300,
"paymentLastFour": null,
"paymentNotes": null
}
],
"saleDateTime": "2018-05-03T16:52:23Z",
"soldById": 10,
"soldByName": "Jane Doe",
"locationId": 1,
"totalAmountPaid": 150,
"items": [
{
"itemId": 78,
"type": "Service",
"name": "10 Punch Pass",
"amountPaid": 150,
"amountDiscounted": 0,
"quantity": 1,
"recipientClientId": "100000009",
"paymentReferenceId": 44
},
{
"itemId": 79,
"type": "Service",
"name": "10 Kick Pass",
"amountPaid": 150,
"amountDiscounted": 0,
"quantity": 1,
"recipientClientId": "100000009",
"paymentReferenceId": 44
}
]
}
}*/
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);
Comments