From 32ff658e841dbd18a2aeacadf03b9c9f4ca033b8 Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Fri, 18 Apr 2025 18:20:01 +0800 Subject: [PATCH] fix: #626 --- internal/pkg/vendors/cdnfly-sdk/models.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/internal/pkg/vendors/cdnfly-sdk/models.go b/internal/pkg/vendors/cdnfly-sdk/models.go index 07497cd3..9622627a 100644 --- a/internal/pkg/vendors/cdnfly-sdk/models.go +++ b/internal/pkg/vendors/cdnfly-sdk/models.go @@ -1,6 +1,6 @@ package cdnflysdk -import "encoding/json" +import "fmt" type BaseResponse interface { GetCode() string @@ -8,12 +8,24 @@ type BaseResponse interface { } type baseResponse struct { - Code json.Number `json:"code"` - Message string `json:"msg"` + Code any `json:"code"` + Message string `json:"msg"` } func (r *baseResponse) GetCode() string { - return r.Code.String() + if r.Code == nil { + return "" + } + + if code, ok := r.Code.(int); ok { + return fmt.Sprintf("%d", code) + } + + if code, ok := r.Code.(string); ok { + return code + } + + return "" } func (r *baseResponse) GetMessage() string {