github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/v1/deposit.go (about)

     1  package bitfinex
     2  
     3  import "errors"
     4  
     5  type DepositService struct {
     6  	client *Client
     7  }
     8  
     9  type DepositResponse struct {
    10  	Result   string
    11  	Method   string
    12  	Currency string
    13  	Address  string
    14  }
    15  
    16  func (d *DepositResponse) Success() (bool, error) {
    17  	if d.Result == "success" {
    18  		return true, nil
    19  	} else {
    20  		err := errors.New(d.Address)
    21  		return false, err
    22  	}
    23  }
    24  
    25  func (s *DepositService) New(method, walletName string, renew int) (DepositResponse, error) {
    26  
    27  	payload := map[string]interface{}{
    28  		"method":      method,
    29  		"wallet_name": walletName,
    30  		"renew":       renew,
    31  	}
    32  
    33  	req, err := s.client.newAuthenticatedRequest("POST", "deposit/new", payload)
    34  
    35  	if err != nil {
    36  		return DepositResponse{}, err
    37  	}
    38  
    39  	var v DepositResponse
    40  	_, err = s.client.do(req, &v)
    41  
    42  	if err != nil {
    43  		return DepositResponse{}, err
    44  	}
    45  	return v, nil
    46  }