33 lines
588 B
Go
33 lines
588 B
Go
package sresponse
|
|
|
|
import (
|
|
"github.com/tech/sendico/pkg/model"
|
|
moneyv1 "github.com/tech/sendico/pkg/proto/common/money/v1"
|
|
)
|
|
|
|
func toMoney(m *moneyv1.Money) *model.Money {
|
|
if m == nil {
|
|
return nil
|
|
}
|
|
return &model.Money{
|
|
Amount: m.GetAmount(),
|
|
Currency: m.GetCurrency(),
|
|
}
|
|
}
|
|
|
|
func toMoneyList(list []*moneyv1.Money) []*model.Money {
|
|
if len(list) == 0 {
|
|
return nil
|
|
}
|
|
result := make([]*model.Money, 0, len(list))
|
|
for _, item := range list {
|
|
if m := toMoney(item); m != nil {
|
|
result = append(result, m)
|
|
}
|
|
}
|
|
if len(result) == 0 {
|
|
return nil
|
|
}
|
|
return result
|
|
}
|