Files

49 lines
1.4 KiB
Go

package handlers
import (
"net/http"
"otaupdate/controllers"
"otaupdate/services"
"github.com/fiskerinc/cloud-services/pkg/common"
"github.com/gorilla/schema"
)
// @deprecated
// HandleSubscriptionPackageGet godoc
// @Summary Get update manifest
// @Description Get update manifest by id
// @Accept json
// @Produce json
// @Param Authorization header string false "Bearer <ID token>"
// @Param Api-Key header string false "<API token>"
// @Param id query string false "Subscription package id"
// @Success 200 {object} common.SubscriptionPackage
// @Failure 400 {object} common.JSONError "Bad request"
// @Failure 401 {object} common.JSONError "Unauthorized"
// @Failure 503 {object} common.JSONError "Service unavailable"
// @Router /subscriptionpackage [get]
func HandleSubscriptionPackageGet(w http.ResponseWriter, r *http.Request) {
subscriptionPackageGet.Handle(w, r)
}
var subscriptionPackageGet = controllers.NewGetModel(&subscriptionPackageGetModelHelper{})
type subscriptionPackageGetModelHelper struct {
SubscriptionPackagesHelper
}
func (h *subscriptionPackageGetModelHelper) ParseGetModelParams(r *http.Request) interface{} {
decoder := schema.NewDecoder()
model := common.SubscriptionPackage{}
decoder.SetAliasTag("json")
decoder.Decode(&model, r.URL.Query())
return &model
}
func (h *subscriptionPackageGetModelHelper) QueryLoad(model interface{}) error {
return services.GetDB().GetSubPackages().Load(model.(*common.SubscriptionPackage))
}