From fa7c616131967d6b9a53ddf2fed9f38da1b77fa8 Mon Sep 17 00:00:00 2001 From: divyanshusinghh <122528880+divyanshusinghh@users.noreply.github.com> Date: Fri, 25 Oct 2024 11:51:36 +0530 Subject: [PATCH] Response key change integrated (#47) * Response key change integrated * version change --- pom.xml | 2 +- .../model/webhookmodel/BroadcasterConfig.java | 33 +++++++++++++++++++ .../webhookmodel/SubscriberEventMapping.java | 12 +++---- .../extension/service/WebhookService.java | 6 ++-- 4 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/fynd/extension/model/webhookmodel/BroadcasterConfig.java diff --git a/pom.xml b/pom.xml index f3255df..ab765d9 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ com.fynd fynd-extension-java - 0.6.5 + 0.6.6 fynd-extension-java Java Fynd Extension Library diff --git a/src/main/java/com/fynd/extension/model/webhookmodel/BroadcasterConfig.java b/src/main/java/com/fynd/extension/model/webhookmodel/BroadcasterConfig.java new file mode 100644 index 0000000..162e8f1 --- /dev/null +++ b/src/main/java/com/fynd/extension/model/webhookmodel/BroadcasterConfig.java @@ -0,0 +1,33 @@ +package com.fynd.extension.model.webhookmodel; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; +import lombok.Getter; +import lombok.Setter; + +@AllArgsConstructor +@NoArgsConstructor +@Getter +@Setter +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BroadcasterConfig { + + @JsonProperty("topic") + private String topic; + + @JsonProperty("queue") + private String queue; + + @JsonProperty("workflow_name") + private String workflowName; + + @JsonProperty("event_bridge_name") + private String eventBridgeName; + + @JsonProperty("created_on") + private String createdOn; +} \ No newline at end of file diff --git a/src/main/java/com/fynd/extension/model/webhookmodel/SubscriberEventMapping.java b/src/main/java/com/fynd/extension/model/webhookmodel/SubscriberEventMapping.java index 19b2931..1b37843 100644 --- a/src/main/java/com/fynd/extension/model/webhookmodel/SubscriberEventMapping.java +++ b/src/main/java/com/fynd/extension/model/webhookmodel/SubscriberEventMapping.java @@ -38,17 +38,13 @@ public class SubscriberEventMapping{ private Double subscriberId; - - - @JsonProperty("topic") - private String topic; - - - - @JsonProperty("created_on") private String createdOn; + @JsonProperty("broadcaster_config") + private BroadcasterConfig BroadcasterConfig; + + } diff --git a/src/main/java/com/fynd/extension/service/WebhookService.java b/src/main/java/com/fynd/extension/service/WebhookService.java index 2289905..32e038f 100644 --- a/src/main/java/com/fynd/extension/service/WebhookService.java +++ b/src/main/java/com/fynd/extension/service/WebhookService.java @@ -367,7 +367,7 @@ private boolean isEventDiff(SubscriberResponse existingEvents, .filter(e -> event.getSlug().equals(e.getEventCategory() + "/" + e.getEventName() + "/" + e.getEventType() + "/v" + e.getVersion())) .findFirst() .orElse(null); - if (existingEvent != null && !event.getTopic().equals(existingEvent.getSubscriberEventMapping().getTopic())) { + if (existingEvent != null && !event.getTopic().equals(existingEvent.getSubscriberEventMapping().getBroadcasterConfig().getTopic())) { return true; // Topics do not match } } @@ -579,7 +579,7 @@ public void disableSalesChannelWebhook(PlatformClient platformClient, String app Events event = new Events(); event.setSlug(eventConfig.getEventCategory() + "/" + eventConfig.getEventName() + "/" + eventConfig.getEventType() + "/v" + eventConfig.getVersion()); if(configType.equals("kafka")){ - event.setTopic(eventConfig.getSubscriberEventMapping().getTopic()); + event.setTopic(eventConfig.getSubscriberEventMapping().getBroadcasterConfig().getTopic()); } events.add(event); }); @@ -642,7 +642,7 @@ public void enableSalesChannelWebhook(PlatformClient platformClient, String appl Events event = new Events(); event.setSlug(eventConfig.getEventCategory() + "/" + eventConfig.getEventName() + "/" + eventConfig.getEventType() + "/v" + eventConfig.getVersion()); if(configType.equals("kafka")){ - event.setTopic(eventConfig.getSubscriberEventMapping().getTopic()); + event.setTopic(eventConfig.getSubscriberEventMapping().getBroadcasterConfig().getTopic()); } events.add(event); });