[go: up one dir, main page]

Skip to content

Commit

Permalink
add main/sub transfer; support candlesticks time range
Browse files Browse the repository at this point in the history
  • Loading branch information
revilwang committed Apr 15, 2020
1 parent 46fc6b9 commit acf3131
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 7 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ but will not receive any future API upgrade support
## Overview
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client.

- API version: 4.11.2
- Package version: 4.11.2
- API version: 4.12.0
- Package version: 4.12.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen
For more information, please visit [https://www.gate.io/page/contacts](https://www.gate.io/page/contacts)

Expand Down Expand Up @@ -135,6 +135,7 @@ Class | Method | HTTP request | Description
*SpotApi* | [**ListTickers**](docs/SpotApi.md#listtickers) | **Get** /spot/tickers | Retrieve ticker information
*SpotApi* | [**ListTrades**](docs/SpotApi.md#listtrades) | **Get** /spot/trades | Retrieve market trades
*WalletApi* | [**Transfer**](docs/WalletApi.md#transfer) | **Post** /wallet/transfers | Transfer between accounts
*WalletApi* | [**TransferWithSubAccount**](docs/WalletApi.md#transferwithsubaccount) | **Post** /wallet/sub_account_transfers | Transfer between main and sub accounts


## Documentation For Models
Expand Down Expand Up @@ -175,6 +176,7 @@ Class | Method | HTTP request | Description
- [RepayRequest](docs/RepayRequest.md)
- [Repayment](docs/Repayment.md)
- [SpotAccount](docs/SpotAccount.md)
- [SubAccountTransfer](docs/SubAccountTransfer.md)
- [Ticker](docs/Ticker.md)
- [Trade](docs/Trade.md)
- [Transfer](docs/Transfer.md)
Expand Down
14 changes: 12 additions & 2 deletions api_spot.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,17 +668,21 @@ func (a *SpotApiService) GetOrder(ctx context.Context, orderId string, currencyP

/*
SpotApiService Market candlesticks
Candlestick data will start from (current time - limit * interval), end at current time
Maximum of 1000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval`
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param currencyPair Currency pair
* @param optional nil or *ListCandlesticksOpts - Optional Parameters:
* @param "Limit" (optional.Int32) - Maximum number of record returned in one list
* @param "Limit" (optional.Int32) - Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected.
* @param "From" (optional.Int64) - Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified
* @param "To" (optional.Int64) - End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time
* @param "Interval" (optional.String) - Interval time between data points
@return [][]string
*/

type ListCandlesticksOpts struct {
Limit optional.Int32
From optional.Int64
To optional.Int64
Interval optional.String
}

Expand All @@ -703,6 +707,12 @@ func (a *SpotApiService) ListCandlesticks(ctx context.Context, currencyPair stri
if localVarOptionals != nil && localVarOptionals.Limit.IsSet() {
localVarQueryParams.Add("limit", parameterToString(localVarOptionals.Limit.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.From.IsSet() {
localVarQueryParams.Add("from", parameterToString(localVarOptionals.From.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.To.IsSet() {
localVarQueryParams.Add("to", parameterToString(localVarOptionals.To.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.Interval.IsSet() {
localVarQueryParams.Add("interval", parameterToString(localVarOptionals.Interval.Value(), ""))
}
Expand Down
68 changes: 68 additions & 0 deletions api_wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,71 @@ func (a *WalletApiService) Transfer(ctx context.Context, transfer Transfer) (*ht

return localVarHttpResponse, nil
}

/*
WalletApiService Transfer between main and sub accounts
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param subAccountTransfer
*/
func (a *WalletApiService) TransferWithSubAccount(ctx context.Context, subAccountTransfer SubAccountTransfer) (*http.Response, error) {
var (
localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
)

// create path and map variables
localVarPath := a.client.cfg.BasePath + "/wallet/sub_account_transfers"

localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}

// to determine the Content-Type header
localVarHttpContentTypes := []string{"application/json"}

// set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHttpContentType
}

// to determine the Accept header
localVarHttpHeaderAccepts := []string{}

// set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
}
// body params
localVarPostBody = &subAccountTransfer
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams,
localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes, true)
if err != nil {
return nil, err
}

localVarHttpResponse, err := a.client.callAPI(r)
if err != nil || localVarHttpResponse == nil {
return localVarHttpResponse, err
}

localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
localVarHttpResponse.Body.Close()
if err != nil {
return localVarHttpResponse, err
}

if localVarHttpResponse.StatusCode >= 300 {
newErr := GenericOpenAPIError{
body: localVarBody,
error: localVarHttpResponse.Status,
}
return localVarHttpResponse, newErr
}

return localVarHttpResponse, nil
}
2 changes: 1 addition & 1 deletion configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func NewConfiguration() *Configuration {
cfg := &Configuration{
BasePath: "https://api.gateio.ws/api/v4",
DefaultHeader: make(map[string]string),
UserAgent: "OpenAPI-Generator/4.11.2/go",
UserAgent: "OpenAPI-Generator/4.12.0/go",
Key: "",
Secret: "",
}
Expand Down
6 changes: 4 additions & 2 deletions docs/SpotApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ Authentication with API key and secret is required
> [][]string ListCandlesticks(ctx, currencyPair, optional)
Market candlesticks

Candlestick data will start from (current time - limit * interval), end at current time
Maximum of 1000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval`

### Required Parameters

Expand All @@ -366,7 +366,9 @@ Optional parameters are passed through a pointer to a ListCandlesticksOpts struc
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------

**limit** | **optional.Int32**| Maximum number of record returned in one list | [default to 100]
**limit** | **optional.Int32**| Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. | [default to 100]
**from** | **optional.Int64**| Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified |
**to** | **optional.Int64**| End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time |
**interval** | **optional.String**| Interval time between data points | [default to 30m]

### Example
Expand Down
13 changes: 13 additions & 0 deletions docs/SubAccountTransfer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SubAccountTransfer

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Currency** | **string** | Transfer currency name |
**SubAccount** | **string** | Sub account user ID |
**Direction** | **string** | Transfer direction. to - transfer into sub account; from - transfer out from sub account |
**Amount** | **string** | Transfer amount |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


45 changes: 45 additions & 0 deletions docs/WalletApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All URIs are relative to *https://api.gateio.ws/api/v4*
Method | HTTP request | Description
------------- | ------------- | -------------
[**Transfer**](WalletApi.md#Transfer) | **Post** /wallet/transfers | Transfer between accounts
[**TransferWithSubAccount**](WalletApi.md#TransferWithSubAccount) | **Post** /wallet/sub_account_transfers | Transfer between main and sub accounts


# **Transfer**
Expand Down Expand Up @@ -53,3 +54,47 @@ Authentication with API key and secret is required

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **TransferWithSubAccount**
> TransferWithSubAccount(ctx, subAccountTransfer)
Transfer between main and sub accounts

### Required Parameters

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.
**subAccountTransfer** | [**SubAccountTransfer**](SubAccountTransfer.md)| |

### Example

```golang
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against other hosts
// client.ChangeBasePath("https://some-other-host")
client.SetKeySecret("YOUR API KEY", "YOUR API SECRET")
api := client.WalletApi
subAccountTransfer := new (gateapi.SubAccountTransfer); // SubAccountTransfer -

result, _, err := api.TransferWithSubAccount(nil, subAccountTransfer)
if err != nil {
fmt.Println(err.Error())
} else {
fmt.Println(result)
}
```

### Return type

(empty response body)

### Authorization

Authentication with API key and secret is required

### HTTP request headers

- **Content-Type**: application/json
- **Accept**: Not defined

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

21 changes: 21 additions & 0 deletions model_sub_account_transfer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Gate API v4
*
* APIv4 provides spot, margin and futures trading operations. There are public APIs to retrieve the real-time market statistics, and private APIs which needs authentication to trade on user's behalf.
*
* Contact: support@mail.gate.io
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/

package gateapi

type SubAccountTransfer struct {
// Transfer currency name
Currency string `json:"currency"`
// Sub account user ID
SubAccount string `json:"sub_account"`
// Transfer direction. to - transfer into sub account; from - transfer out from sub account
Direction string `json:"direction"`
// Transfer amount
Amount string `json:"amount"`
}

0 comments on commit acf3131

Please sign in to comment.