Add singular account_list method, account_remove
This commit is contained in:
parent
76b73ef0c7
commit
7ba00dffcc
3 changed files with 53 additions and 0 deletions
|
@ -144,6 +144,11 @@ func (d *Client) AccountList() (*AccountListResponse, error) {
|
||||||
return response, d.call(response, "account_list", map[string]interface{}{})
|
return response, d.call(response, "account_list", map[string]interface{}{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Client) SingleAccountList(accountID string) (*SingleAccountListResponse, error) {
|
||||||
|
response := new(SingleAccountListResponse)
|
||||||
|
return response, d.call(response, "account_list", map[string]interface{}{"account_id": accountID})
|
||||||
|
}
|
||||||
|
|
||||||
type AccountSettings struct {
|
type AccountSettings struct {
|
||||||
Default bool `json:"default"`
|
Default bool `json:"default"`
|
||||||
NewName string `json:"new_name"`
|
NewName string `json:"new_name"`
|
||||||
|
@ -184,6 +189,13 @@ func (d *Client) AccountCreate(accountName string, singleKey bool) (*AccountCrea
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Client) AccountRemove(accountID string) (*AccountRemoveResponse, error) {
|
||||||
|
response := new(AccountRemoveResponse)
|
||||||
|
return response, d.call(response, "account_remove", map[string]interface{}{
|
||||||
|
"account_id": accountID,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (d *Client) AddressUnused(account *string) (*AddressUnusedResponse, error) {
|
func (d *Client) AddressUnused(account *string) (*AddressUnusedResponse, error) {
|
||||||
response := new(AddressUnusedResponse)
|
response := new(AddressUnusedResponse)
|
||||||
return response, d.call(response, "address_unused", map[string]interface{}{
|
return response, d.call(response, "address_unused", map[string]interface{}{
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -48,6 +49,19 @@ func TestClient_AccountList(t *testing.T) {
|
||||||
prettyPrint(*got)
|
prettyPrint(*got)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestClient_SingleAccountList(t *testing.T) {
|
||||||
|
d := NewClient("")
|
||||||
|
createdAccount, err := d.AccountCreate("test"+fmt.Sprintf("%d", time.Now().Unix())+"@lbry.com", false)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
account, err := d.SingleAccountList(createdAccount.ID)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
prettyPrint(*account)
|
||||||
|
}
|
||||||
|
|
||||||
func TestClient_AccountBalance(t *testing.T) {
|
func TestClient_AccountBalance(t *testing.T) {
|
||||||
d := NewClient("")
|
d := NewClient("")
|
||||||
got, err := d.AccountBalance(nil)
|
got, err := d.AccountBalance(nil)
|
||||||
|
@ -317,3 +331,21 @@ func TestClient_AccountCreate(t *testing.T) {
|
||||||
}
|
}
|
||||||
prettyPrint(*account)
|
prettyPrint(*account)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestClient_AccountRemove(t *testing.T) {
|
||||||
|
d := NewClient("")
|
||||||
|
createdAccount, err := d.AccountCreate("test"+fmt.Sprintf("%d", time.Now().Unix())+"@lbry.com", false)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
removedAccount, err := d.AccountRemove(createdAccount.ID)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = d.SingleAccountList(createdAccount.ID)
|
||||||
|
if !strings.HasPrefix("Couldn't find account", err.Error()) {
|
||||||
|
t.Error("account was not removed")
|
||||||
|
}
|
||||||
|
prettyPrint(*removedAccount)
|
||||||
|
}
|
||||||
|
|
|
@ -209,6 +209,11 @@ type AccountListResponse struct {
|
||||||
LBCTestnet []Account `json:"lbc_testnet"`
|
LBCTestnet []Account `json:"lbc_testnet"`
|
||||||
LBCRegtest []Account `json:"lbc_regtest"`
|
LBCRegtest []Account `json:"lbc_regtest"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SingleAccountListResponse struct {
|
||||||
|
Account
|
||||||
|
}
|
||||||
|
|
||||||
type AccountBalanceResponse string
|
type AccountBalanceResponse string
|
||||||
|
|
||||||
type AccountCreateResponse struct {
|
type AccountCreateResponse struct {
|
||||||
|
@ -220,6 +225,10 @@ type AccountCreateResponse struct {
|
||||||
ModifiedOn float64 `json:"modified_on"`
|
ModifiedOn float64 `json:"modified_on"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AccountRemoveResponse struct {
|
||||||
|
AccountCreateResponse
|
||||||
|
}
|
||||||
|
|
||||||
type Transaction struct {
|
type Transaction struct {
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
Amount string `json:"amount"`
|
Amount string `json:"amount"`
|
||||||
|
|
Loading…
Add table
Reference in a new issue