Skip to content

Commit

Permalink
fix(adraise): get status parse error
Browse files Browse the repository at this point in the history
  • Loading branch information
bububa committed Apr 26, 2022
1 parent 605579f commit 8227595
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions marketing-api/api/tools/adraise/status.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package adraise

import (
"encoding/json"
"regexp"
"strconv"

"github.com/bububa/oceanengine/marketing-api/core"
"github.com/bububa/oceanengine/marketing-api/enum"
Expand All @@ -15,8 +16,15 @@ func Status(clt *core.SDKClient, accessToken string, req *adraise.StatusRequest)
return nil, err
}
ret := make(map[uint64]enum.AdRaiseStatus, len(req.AdIDs))
if err := json.Unmarshal([]byte(resp.Data.Status), &ret); err != nil {
return nil, err
re := regexp.MustCompile(`(\d+):\s+'(.*?)'`)
matches := re.FindAllStringSubmatch(resp.Data.Status, -1)
for _, match := range matches {
if len(match) != 3 {
continue
}
adID, _ := strconv.ParseUint(match[1], 10, 64)
status := match[2]
ret[adID] = enum.AdRaiseStatus(status)
}
return ret, nil
}

0 comments on commit 8227595

Please sign in to comment.