From 1be14b5c24df3435807402fa1813ec8f4dbdc8ec Mon Sep 17 00:00:00 2001 From: Bien Date: Thu, 12 Oct 2023 15:10:37 +0700 Subject: [PATCH] fix: friend tech key api - add client id --- pkg/service/friendtech/friend_tech.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pkg/service/friendtech/friend_tech.go b/pkg/service/friendtech/friend_tech.go index c70c73c1..21282cb0 100644 --- a/pkg/service/friendtech/friend_tech.go +++ b/pkg/service/friendtech/friend_tech.go @@ -6,6 +6,7 @@ import ( "net/http" "github.com/defipod/mochi/pkg/config" + "github.com/defipod/mochi/pkg/consts" "github.com/defipod/mochi/pkg/response" "github.com/defipod/mochi/pkg/util" ) @@ -14,6 +15,13 @@ type FriendTech struct { baseUrl string } +var commonHeader = map[string]string{ + "Content-Type": "application/json", + "Accept": "application/json", + "clientData": fmt.Sprintf("{\"source\": \"%s\"}", consts.ClientID), + "x-client-id": consts.ClientID, +} + func NewService(cfg *config.Config) Service { baseUrl := cfg.FriendScanAPI if baseUrl == "" { @@ -35,7 +43,7 @@ func (n *FriendTech) Search(query string, limit int) (*response.FriendTechKeysRe req := util.SendRequestQuery{ URL: url, ParseForm: &data, - Headers: map[string]string{"Content-Type": "application/json", "Accept": "application/json"}, + Headers: commonHeader, } statusCode, err := util.SendRequest(req) if err != nil || statusCode != http.StatusOK { @@ -50,8 +58,9 @@ func (n *FriendTech) GetHistory(accountAddress, interval string) (*response.Frie req := util.SendRequestQuery{ URL: url, ParseForm: &data, - Headers: map[string]string{"Content-Type": "application/json", "Accept": "application/json"}, + Headers: commonHeader, } + statusCode, err := util.SendRequest(req) if err != nil || statusCode != http.StatusOK { return &response.FriendTechKeyPriceHistoryResponse{}, nil @@ -70,7 +79,7 @@ func (n *FriendTech) GetTransactions(subjectAddress string, limit int) (*respons req := util.SendRequestQuery{ URL: url, ParseForm: &data, - Headers: map[string]string{"Content-Type": "application/json", "Accept": "application/json"}, + Headers: commonHeader, } statusCode, err := util.SendRequest(req) if err != nil {