Skip to content

Commit

Permalink
[#131] client: Name all methods and types the same way
Browse files Browse the repository at this point in the history
Inherit name format of object operations in all other ones.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
  • Loading branch information
Leonard Lyubich authored and cthulhu-rider committed Feb 18, 2022
1 parent 998bae3 commit 69fffac
Show file tree
Hide file tree
Showing 16 changed files with 235 additions and 235 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ c, _ := client.New(
ctx, cancel := context.WithTimeout(context.Background(), 5 * time.Second)
defer cancel()

res, err := c.GetBalance(ctx, owner)
res, err := c.BalanceGet(ctx, owner)
if err != nil {
return
}
Expand Down
22 changes: 11 additions & 11 deletions client/accounting.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,51 +10,51 @@ import (
"github.com/nspcc-dev/neofs-sdk-go/owner"
)

// GetBalancePrm groups parameters of GetBalance operation.
type GetBalancePrm struct {
// PrmBalanceGet groups parameters of BalanceGet operation.
type PrmBalanceGet struct {
ownerSet bool
ownerID owner.ID
}

// SetAccount sets identifier of the NeoFS account for which the balance is requested.
// Required parameter. Must be a valid ID according to NeoFS API protocol.
func (x *GetBalancePrm) SetAccount(id owner.ID) {
func (x *PrmBalanceGet) SetAccount(id owner.ID) {
x.ownerID = id
x.ownerSet = true
}

// GetBalanceRes groups resulting values of GetBalance operation.
type GetBalanceRes struct {
// ResBalanceGet groups resulting values of BalanceGet operation.
type ResBalanceGet struct {
statusRes

amount *accounting.Decimal
}

func (x *GetBalanceRes) setAmount(v *accounting.Decimal) {
func (x *ResBalanceGet) setAmount(v *accounting.Decimal) {
x.amount = v
}

// Amount returns current amount of funds on the NeoFS account as decimal number.
//
// Client doesn't retain value so modification is safe.
func (x GetBalanceRes) Amount() *accounting.Decimal {
func (x ResBalanceGet) Amount() *accounting.Decimal {
return x.amount
}

// GetBalance requests current balance of the NeoFS account.
// BalanceGet requests current balance of the NeoFS account.
//
// Exactly one return value is non-nil. By default, server status is returned in res structure.
// Any client's internal or transport errors are returned as `error`,
// If WithNeoFSErrorParsing option has been provided, unsuccessful
// NeoFS status codes are returned as `error`, otherwise, are included
// in the returned result structure.
//
// Immediately panics if parameters are set incorrectly (see GetBalancePrm docs).
// Immediately panics if parameters are set incorrectly (see PrmBalanceGet docs).
// Context is required and must not be nil. It is used for network communication.
//
// Return statuses:
// - global (see Client docs).
func (c *Client) GetBalance(ctx context.Context, prm GetBalancePrm) (*GetBalanceRes, error) {
func (c *Client) BalanceGet(ctx context.Context, prm PrmBalanceGet) (*ResBalanceGet, error) {
switch {
case ctx == nil:
panic(panicMsgMissingContext)
Expand All @@ -78,7 +78,7 @@ func (c *Client) GetBalance(ctx context.Context, prm GetBalancePrm) (*GetBalance

var (
cc contextCall
res GetBalanceRes
res ResBalanceGet
)

c.initCallContext(&cc)
Expand Down
Loading

0 comments on commit 69fffac

Please sign in to comment.