Skip to content

Commit

Permalink
fix: friend tech key api - add client id
Browse files Browse the repository at this point in the history
  • Loading branch information
baenv authored and sp.bean committed Oct 12, 2023
1 parent 75be124 commit 1be14b5
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/service/friendtech/friend_tech.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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 == "" {
Expand All @@ -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 {
Expand All @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit 1be14b5

Please sign in to comment.