package sresponse

import (
	paymenttypes "github.com/tech/sendico/pkg/payments/types"
	moneyv1 "github.com/tech/sendico/pkg/proto/common/money/v1"
)

func toMoney(m *moneyv1.Money) *paymenttypes.Money {
	if m == nil {
		return nil
	}
	return &paymenttypes.Money{
		Amount:   m.GetAmount(),
		Currency: m.GetCurrency(),
	}
}

func toMoneyList(list []*moneyv1.Money) []*paymenttypes.Money {
	if len(list) == 0 {
		return nil
	}
	result := make([]*paymenttypes.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
}
