Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
linstohu committed Dec 20, 2023
1 parent f30b5eb commit 88cb5d3
Show file tree
Hide file tree
Showing 18 changed files with 63 additions and 29 deletions.
5 changes: 4 additions & 1 deletion binance/coinmfutures/utils/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ func (u *CoinMarginedClient) GetRecvWindow() int {
}

func (u *CoinMarginedClient) GenHeaders(t usdmutils.SecurityType) (map[string]string, error) {
headers := usdmutils.DefaultContentType
headers := map[string]string{
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json",
}

// SecurityType each endpoint has a security type that determines how you will interact with it
// docs: https://binance-docs.github.io/apidocs/delivery/en/#endpoint-security-type
Expand Down
5 changes: 4 additions & 1 deletion binance/europeanoptions/utils/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ func (o *OptionsClient) GetRecvWindow() int {
}

func (o *OptionsClient) GenHeaders(t usdmutils.SecurityType) (map[string]string, error) {
headers := usdmutils.DefaultContentType
headers := map[string]string{
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json",
}

// SecurityType each endpoint has a security type that determines how you will interact with it
// docs: https://binance-docs.github.io/apidocs/voptions/en/#endpoint-security-type
Expand Down
5 changes: 4 additions & 1 deletion binance/portfoliomargin/utils/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ func (p *PortfolioMarginClient) GetRecvWindow() int {
}

func (p *PortfolioMarginClient) GenHeaders(t SecurityType) (map[string]string, error) {
headers := DefaultContentType
headers := map[string]string{
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json",
}

// SecurityType each endpoint has a security type that determines how you will interact with it
// docs: https://binance-docs.github.io/apidocs/pm/en/#endpoint-security-type
Expand Down
5 changes: 0 additions & 5 deletions binance/portfoliomargin/utils/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,3 @@ var (
USER_DATA SecurityType = "USER_DATA"
USER_STREAM SecurityType = "USER_STREAM"
)

var DefaultContentType = map[string]string{
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json",
}
5 changes: 4 additions & 1 deletion binance/usdmfutures/utils/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ func (u *USDMarginedClient) GetRecvWindow() int {
}

func (u *USDMarginedClient) GenHeaders(t SecurityType) (map[string]string, error) {
headers := DefaultContentType
headers := map[string]string{
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json",
}

// SecurityType each endpoint has a security type that determines how you will interact with it
// docs: https://binance-docs.github.io/apidocs/futures/en/#endpoint-security-type
Expand Down
5 changes: 0 additions & 5 deletions binance/usdmfutures/utils/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ var (
MARKET_DATA SecurityType = "MARKET_DATA"
)

var DefaultContentType = map[string]string{
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json",
}

type ContractType = string

var (
Expand Down
6 changes: 3 additions & 3 deletions htx/rest/spot/client.go → htx/spot/rest/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package spot
package rest

import (
"context"
Expand All @@ -24,8 +24,8 @@ import (
"net/http"

"github.com/go-playground/validator"
"github.com/linstohu/nexapi/htx/rest/spot/types"
"github.com/linstohu/nexapi/htx/rest/utils"
"github.com/linstohu/nexapi/htx/spot/rest/types"
"github.com/linstohu/nexapi/htx/utils"
)

type SpotClient struct {
Expand Down
4 changes: 2 additions & 2 deletions htx/rest/spot/client_test.go → htx/spot/rest/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
* limitations under the License.
*/

package spot
package rest

import (
"context"
"os"
"testing"

"github.com/linstohu/nexapi/htx/rest/utils"
"github.com/linstohu/nexapi/htx/utils"
"github.com/stretchr/testify/assert"
)

Expand Down
File renamed without changes.
18 changes: 18 additions & 0 deletions htx/usdm/rest/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2023, LinstoHu
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package rest
18 changes: 18 additions & 0 deletions htx/usdm/websocket/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2023, LinstoHu
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package websocket
1 change: 0 additions & 1 deletion htx/rest/utils/client.go → htx/utils/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ func (htx *HTXClient) SendHTTPRequest(ctx context.Context, req HTTPRequest) (*HT
if err != nil {
return nil, err
}
defer resp.Body.Close()

if htx.GetDebug() {
dump, err := httputil.DumpResponse(resp, true)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions kucoin/rest/utils/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import (
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
"encoding/json"
"fmt"
"io"
"log/slog"
"net/http"
"net/http/httputil"
"net/url"
"strings"
"time"

"github.com/go-playground/validator"
Expand Down Expand Up @@ -149,11 +149,11 @@ func (s *KucoinClient) SendHTTPRequest(ctx context.Context, req HTTPRequest) (*H

var body io.Reader
if req.Body != nil {
formData, err := query.Values(req.Body)
jsonBody, err := json.Marshal(req.Body)
if err != nil {
return nil, err
}
body = strings.NewReader(formData.Encode())
body = bytes.NewReader(jsonBody)
}

url, err := url.Parse(req.BaseURL + req.Path)
Expand Down Expand Up @@ -191,7 +191,6 @@ func (s *KucoinClient) SendHTTPRequest(ctx context.Context, req HTTPRequest) (*H
if err != nil {
return nil, err
}
defer resp.Body.Close()

if s.GetDebug() {
dump, err := httputil.DumpResponse(resp, true)
Expand Down
4 changes: 3 additions & 1 deletion woox/rest/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ func (w *WooXRestClient) GenV3APIAuthHeaders(req types.HTTPRequest) (map[string]
return nil, fmt.Errorf("key and secret needed when init client")
}

headers := V3DefaultContentType
headers := map[string]string{
"Content-Type": "application/json",
}

strBody := ""
if req.Body != nil {
Expand Down
4 changes: 0 additions & 4 deletions woox/rest/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ var (
V1DefaultContentType = map[string]string{
"Content-Type": "application/x-www-form-urlencoded",
}

V3DefaultContentType = map[string]string{
"Content-Type": "application/json",
}
)

const (
Expand Down

0 comments on commit 88cb5d3

Please sign in to comment.