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 := 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, Price: uint64(tarrif.Price), } } 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), } }