v2/accounting: Implement uni BalanceResponse

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-08-17 13:39:46 +03:00 committed by Stanislav Bogatyrev
parent 9df86935f5
commit e84c8aee2c
2 changed files with 128 additions and 0 deletions

View file

@ -17,6 +17,18 @@ type BalanceRequest struct {
verifyHeader *service.RequestVerificationHeader
}
type BalanceResponseBody struct {
bal *Decimal
}
type BalanceResponse struct {
body *BalanceResponseBody
metaHeader *service.ResponseMetaHeader
verifyHeader *service.ResponseVerificationHeader
}
type Decimal struct {
val int64
@ -122,3 +134,59 @@ func (d *Decimal) SetPrecision(v uint32) {
d.prec = v
}
}
func (br *BalanceResponseBody) GetBalance() *Decimal {
if br != nil {
return br.bal
}
return nil
}
func (br *BalanceResponseBody) SetBalance(v *Decimal) {
if br != nil {
br.SetBalance(v)
}
}
func (br *BalanceResponse) GetBody() *BalanceResponseBody {
if br != nil {
return br.body
}
return nil
}
func (br *BalanceResponse) SetBody(v *BalanceResponseBody) {
if br != nil {
br.body = v
}
}
func (br *BalanceResponse) GetResponseMetaHeader() *service.ResponseMetaHeader {
if br != nil {
return br.metaHeader
}
return nil
}
func (br *BalanceResponse) SetResponseMetaHeader(v *service.ResponseMetaHeader) {
if br != nil {
br.metaHeader = v
}
}
func (br *BalanceResponse) GetResponseVerificationHeader() *service.ResponseVerificationHeader {
if br != nil {
return br.verifyHeader
}
return nil
}
func (br *BalanceResponse) SetResponseVerificationHeader(v *service.ResponseVerificationHeader) {
if br != nil {
br.verifyHeader = v
}
}

View file

@ -91,3 +91,63 @@ func DecimalFromGRPCMessage(m *accounting.Decimal) *Decimal {
return d
}
func BalanceResponseBodyToGRPCMessage(br *BalanceResponseBody) *accounting.BalanceResponse_Body {
if br == nil {
return nil
}
m := new(accounting.BalanceResponse_Body)
m.SetBalance(
DecimalToGRPCMessage(br.GetBalance()),
)
return m
}
func BalanceResponseBodyFromGRPCMessage(m *accounting.BalanceResponse_Body) *BalanceResponseBody {
if m == nil {
return nil
}
br := new(BalanceResponseBody)
br.SetBalance(
DecimalFromGRPCMessage(m.GetBalance()),
)
return br
}
func BalanceResponseToGRPCMessage(br *BalanceResponse) *accounting.BalanceResponse {
if br == nil {
return nil
}
m := new(accounting.BalanceResponse)
m.SetBody(
BalanceResponseBodyToGRPCMessage(br.GetBody()),
)
service.ResponseHeadersToGRPC(br, m)
return m
}
func BalanceResponseFromGRPCMessage(m *accounting.BalanceResponse) *BalanceResponse {
if m == nil {
return nil
}
br := new(BalanceResponse)
br.SetBody(
BalanceResponseBodyFromGRPCMessage(m.GetBody()),
)
service.ResponseHeadersFromGRPC(m, br)
return br
}