public WebhookNotification(NodeWrapper node) {
this.kind = EnumUtils.findByName(Kind.class, node.findString("kind"));
this.timestamp = node.findDateTime("timestamp");
NodeWrapper wrapperNode = node.findFirst("subject");
if (wrapperNode.findFirst("api-error-response") != null) {
wrapperNode = wrapperNode.findFirst("api-error-response");
}
if (wrapperNode.findFirst("subscription") != null) {
this.subscription = new Subscription(wrapperNode.findFirst("subscription"));
}
if (wrapperNode.findFirst("disbursement") != null) {
this.disbursement = new Disbursement(wrapperNode.findFirst("disbursement"));
}
if (wrapperNode.findFirst("merchant-account") != null) {
this.merchantAccount = new MerchantAccount(wrapperNode.findFirst("merchant-account"));
}
if (wrapperNode.findFirst("dispute") != null) {
this.dispute = new Dispute(wrapperNode.findFirst("dispute"));
}
if (wrapperNode.findFirst("transaction") != null) {
this.transaction = new Transaction(wrapperNode.findFirst("transaction"));
}
if (wrapperNode.findFirst("partner-merchant") != null) {
this.partnerMerchant = new PartnerMerchant(wrapperNode.findFirst("partner-merchant"));
}
if (!wrapperNode.isSuccess()) {
this.errors = new ValidationErrors(wrapperNode);
}
}