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("merchant-account") != null) {
this.merchantAccount = new MerchantAccount(wrapperNode.findFirst("merchant-account"));
}
if (wrapperNode.findFirst("transaction") != null) {
this.transaction = new Transaction(wrapperNode.findFirst("transaction"));
}
if (wrapperNode.findFirst("partner-user") != null) {
this.partnerUser = new PartnerUser(wrapperNode.findFirst("partner-user"));
}
if (!wrapperNode.isSuccess()) {
this.errors = new ValidationErrors(wrapperNode);
}
}