45 lines
1.4 KiB
Go
45 lines
1.4 KiB
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
"otaupdate/controllers"
|
|
"otaupdate/services"
|
|
|
|
"github.com/fiskerinc/cloud-services/pkg/common"
|
|
"github.com/go-pg/pg/v10/orm"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// @deprecated
|
|
// HandleSubscriptionPackageUpdate godoc
|
|
// @Summary Update subscription package
|
|
// @Description Update subscription package
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param Authorization header string false "Bearer <ID token>"
|
|
// @Param Api-Key header string false "<API token>"
|
|
// @Param package body SubPackagesUpdateRequest true "Subscription package data"
|
|
// @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 [put]
|
|
func HandleSubscriptionPackageUpdate(w http.ResponseWriter, r *http.Request) {
|
|
subscriptionPackageUpdate.Handle(w, r)
|
|
}
|
|
|
|
var subscriptionPackageUpdate = controllers.NewUpdate(&subscriptionPackageUpdateHelper{})
|
|
|
|
type subscriptionPackageUpdateHelper struct {
|
|
SubscriptionPackagesHelper
|
|
}
|
|
|
|
func (h *subscriptionPackageUpdateHelper) QueryUpdate(model interface{}) (orm.Result, error) {
|
|
return services.GetDB().GetSubPackages().Update(model.(*common.SubscriptionPackage))
|
|
}
|
|
|
|
type SubPackagesUpdateRequest struct {
|
|
ID uuid.UUID `json:"uuid"`
|
|
SubPackagesAddRequest
|
|
}
|