package utils

import (
	"encoding/json"
	"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models"
	"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/proto/discount"
)

func GetAppliedDiscountsIDs(appliedDiscounts []*discount.Discount) []string {
	discounts := make([]string, len(appliedDiscounts))
	for i, discount := range appliedDiscounts {
		discounts[i] = discount.ID
	}
	return discounts
}

func MarshalRawDetails(details models.RawDetails) string {
	data, err := json.Marshal(details)
	if err != nil {
		return ""
	}
	return string(data)
}

func GetTariffsIDs(tariffs []models.Tariff) []string {
	result := make([]string, len(tariffs))
	for i, tariff := range tariffs {
		result[i] = tariff.ID
	}
	return result
}
