2023-05-30 11:33:57 +00:00
|
|
|
package transfer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models"
|
2023-07-06 18:50:46 +00:00
|
|
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/broker"
|
2023-05-30 11:33:57 +00:00
|
|
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/discount"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TariffsToProductInformations(tarrifs []models.Tariff) []*discount.ProductInformation {
|
|
|
|
productInformations := make([]*discount.ProductInformation, len(tarrifs))
|
|
|
|
|
|
|
|
for index, tariff := range tarrifs {
|
|
|
|
productInformations[index] = TariffToProductInformation(tariff)
|
|
|
|
}
|
|
|
|
|
|
|
|
return productInformations
|
|
|
|
}
|
|
|
|
|
|
|
|
func TariffToProductInformation(tarrif models.Tariff) *discount.ProductInformation {
|
|
|
|
return &discount.ProductInformation{
|
|
|
|
ID: tarrif.ID,
|
2023-09-09 22:44:46 +00:00
|
|
|
Price: tarrif.Price,
|
2023-07-06 18:50:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TariffMessageProtoToTariffModel(tariff *broker.TariffMessage) *models.Tariff {
|
|
|
|
if tariff == nil {
|
|
|
|
return &models.Tariff{}
|
|
|
|
}
|
|
|
|
|
|
|
|
return &models.Tariff{Privileges: PrivilegeArrayProtoToModel(tariff.Privileges)}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TariffModelToProtoMessage(userID string, tariffModel *models.Tariff) *broker.TariffMessage {
|
|
|
|
if tariffModel == nil {
|
|
|
|
return &broker.TariffMessage{}
|
|
|
|
}
|
|
|
|
|
|
|
|
return &broker.TariffMessage{
|
|
|
|
UserID: userID,
|
|
|
|
Privileges: PrivilegeArrayModelToProto(tariffModel.Privileges),
|
2023-05-30 11:33:57 +00:00
|
|
|
}
|
|
|
|
}
|