ソースを参照

To resource names

wfansh 5 ヶ月 前
コミット
74b95e8c0c

+ 4 - 1
src/main/java/com/wechi/adweb/bridge/google/analytics/dto/GAAccountDTO.java

@@ -1,5 +1,6 @@
 package com.wechi.adweb.bridge.google.analytics.dto;
 
+import com.google.common.base.Joiner;
 import com.wechi.adweb.bridge.google.common.ResourceDTO;
 
 import lombok.Data;
@@ -25,6 +26,8 @@ public class GAAccountDTO extends ResourceDTO {
     private long updateTime;
 
     public static String toResourceName(String id) {
-        return StringUtils.isNumeric(id) ? "accounts" + RESOURCE_NAME_SPLITTER + id : id;
+        return StringUtils.isNumeric(id)
+                ? Joiner.on(RESOURCE_NAME_SPLITTER).join("accounts", id)
+                : id;
     }
 }

+ 4 - 1
src/main/java/com/wechi/adweb/bridge/google/analytics/dto/GAPropertyDTO.java

@@ -1,5 +1,6 @@
 package com.wechi.adweb.bridge.google.analytics.dto;
 
+import com.google.common.base.Joiner;
 import com.wechi.adweb.bridge.google.common.ResourceDTO;
 
 import lombok.Data;
@@ -43,6 +44,8 @@ public class GAPropertyDTO extends ResourceDTO {
     private List<GADataStreamDTO> dataStreams;
 
     public static String toResourceName(String id) {
-        return StringUtils.isNumeric(id) ? "properties" + RESOURCE_NAME_SPLITTER + id : id;
+        return StringUtils.isNumeric(id)
+                ? Joiner.on(RESOURCE_NAME_SPLITTER).join("properties", id)
+                : id;
     }
 }

+ 4 - 1
src/main/java/com/wechi/adweb/bridge/google/gtm/dto/GTMAccountDTO.java

@@ -1,5 +1,6 @@
 package com.wechi.adweb.bridge.google.gtm.dto;
 
+import com.google.common.base.Joiner;
 import com.wechi.adweb.bridge.google.common.ResourceDTO;
 
 import lombok.*;
@@ -22,6 +23,8 @@ public class GTMAccountDTO extends ResourceDTO {
     private boolean supportMultipleContainers;
 
     public static String toResourceName(String id) {
-        return StringUtils.isNumeric(id) ? "accounts" + RESOURCE_NAME_SPLITTER + id : id;
+        return StringUtils.isNumeric(id)
+                ? Joiner.on(RESOURCE_NAME_SPLITTER).join("accounts", id)
+                : id;
     }
 }

+ 6 - 2
src/main/java/com/wechi/adweb/bridge/google/gtm/dto/GTMContainerDTO.java

@@ -1,5 +1,6 @@
 package com.wechi.adweb.bridge.google.gtm.dto;
 
+import com.google.common.base.Joiner;
 import com.wechi.adweb.bridge.google.common.ResourceDTO;
 
 import lombok.Data;
@@ -42,7 +43,10 @@ public class GTMContainerDTO extends ResourceDTO {
 
     private List<GTMTagDTO> tags;
 
-    public static String toResourceName(String id) {
-        return StringUtils.isNumeric(id) ? "accounts" + RESOURCE_NAME_SPLITTER + id : id;
+    public static String toResourceName(String accountId, String containerId) {
+        return StringUtils.isNumeric(accountId) && StringUtils.isNumeric(containerId)
+                ? Joiner.on(RESOURCE_NAME_SPLITTER)
+                        .join("accounts", accountId, "containers", containerId)
+                : containerId;
     }
 }