refactor: split channelToResponse into pricingToResponse + intervalToResponse
This commit is contained in:
parent
3cd398b098
commit
b453c32743
@ -142,6 +142,12 @@ func channelToResponse(ch *service.Channel) *channelResponse {
|
|||||||
|
|
||||||
resp.ModelPricing = make([]channelModelPricingResponse, 0, len(ch.ModelPricing))
|
resp.ModelPricing = make([]channelModelPricingResponse, 0, len(ch.ModelPricing))
|
||||||
for _, p := range ch.ModelPricing {
|
for _, p := range ch.ModelPricing {
|
||||||
|
resp.ModelPricing = append(resp.ModelPricing, pricingToResponse(&p))
|
||||||
|
}
|
||||||
|
return resp
|
||||||
|
}
|
||||||
|
|
||||||
|
func pricingToResponse(p *service.ChannelModelPricing) channelModelPricingResponse {
|
||||||
models := p.Models
|
models := p.Models
|
||||||
if models == nil {
|
if models == nil {
|
||||||
models = []string{}
|
models = []string{}
|
||||||
@ -156,20 +162,9 @@ func channelToResponse(ch *service.Channel) *channelResponse {
|
|||||||
}
|
}
|
||||||
intervals := make([]pricingIntervalResponse, 0, len(p.Intervals))
|
intervals := make([]pricingIntervalResponse, 0, len(p.Intervals))
|
||||||
for _, iv := range p.Intervals {
|
for _, iv := range p.Intervals {
|
||||||
intervals = append(intervals, pricingIntervalResponse{
|
intervals = append(intervals, intervalToResponse(iv))
|
||||||
ID: iv.ID,
|
|
||||||
MinTokens: iv.MinTokens,
|
|
||||||
MaxTokens: iv.MaxTokens,
|
|
||||||
TierLabel: iv.TierLabel,
|
|
||||||
InputPrice: iv.InputPrice,
|
|
||||||
OutputPrice: iv.OutputPrice,
|
|
||||||
CacheWritePrice: iv.CacheWritePrice,
|
|
||||||
CacheReadPrice: iv.CacheReadPrice,
|
|
||||||
PerRequestPrice: iv.PerRequestPrice,
|
|
||||||
SortOrder: iv.SortOrder,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
resp.ModelPricing = append(resp.ModelPricing, channelModelPricingResponse{
|
return channelModelPricingResponse{
|
||||||
ID: p.ID,
|
ID: p.ID,
|
||||||
Platform: platform,
|
Platform: platform,
|
||||||
Models: models,
|
Models: models,
|
||||||
@ -181,9 +176,22 @@ func channelToResponse(ch *service.Channel) *channelResponse {
|
|||||||
ImageOutputPrice: p.ImageOutputPrice,
|
ImageOutputPrice: p.ImageOutputPrice,
|
||||||
PerRequestPrice: p.PerRequestPrice,
|
PerRequestPrice: p.PerRequestPrice,
|
||||||
Intervals: intervals,
|
Intervals: intervals,
|
||||||
})
|
|
||||||
}
|
}
|
||||||
return resp
|
}
|
||||||
|
|
||||||
|
func intervalToResponse(iv service.PricingInterval) pricingIntervalResponse {
|
||||||
|
return pricingIntervalResponse{
|
||||||
|
ID: iv.ID,
|
||||||
|
MinTokens: iv.MinTokens,
|
||||||
|
MaxTokens: iv.MaxTokens,
|
||||||
|
TierLabel: iv.TierLabel,
|
||||||
|
InputPrice: iv.InputPrice,
|
||||||
|
OutputPrice: iv.OutputPrice,
|
||||||
|
CacheWritePrice: iv.CacheWritePrice,
|
||||||
|
CacheReadPrice: iv.CacheReadPrice,
|
||||||
|
PerRequestPrice: iv.PerRequestPrice,
|
||||||
|
SortOrder: iv.SortOrder,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func pricingRequestToService(reqs []channelModelPricingRequest) []service.ChannelModelPricing {
|
func pricingRequestToService(reqs []channelModelPricingRequest) []service.ChannelModelPricing {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user