package transfer import ( "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/broker" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/discount" ) func TariffsToProductInformations(tarrifs []models.Tariff) []*discount.ProductInformation { productInformations := []*discount.ProductInformation{} for _, tariff := range tarrifs { for _, privilege := range tariff.Privileges { productInformations = append(productInformations, PrivilegeToProductInformation(tariff)) } } return productInformations } func PrivilegeToProductInformation(privilege models.Privilege) *discount.ProductInformation { return &discount.ProductInformation{ ID: privilege.ID, Price: privilege.Price, Group: privilege.ServiceKey, } } 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), } }