Commit 12484795 authored by Ikram Haq's avatar Ikram Haq
Browse files

Implement user_subscriptions endpoints and methods.

parent aa214d7e
Loading
Loading
Loading
Loading
+562 −0

File changed.

Preview size limit exceeded, changes collapsed.

+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ require (
	github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-swagger-api-mgr v0.0.0
	github.com/gorilla/handlers v1.4.0
	github.com/gorilla/mux v1.8.0
	github.com/mitchellh/mapstructure v1.5.0 // indirect
	github.com/prometheus/client_golang v1.9.0
)

+2 −0
Original line number Diff line number Diff line
@@ -181,6 +181,8 @@ github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS4
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+18 −0
Original line number Diff line number Diff line
@@ -111,6 +111,24 @@ func UserTrackingSubGET(w http.ResponseWriter, r *http.Request) {
	userTrackingSubGet(w, r)
}

func UserSubListGET(w http.ResponseWriter, r *http.Request) {
	userSubListGET(w, r)
}
func UserSubPOST(w http.ResponseWriter, r *http.Request) {
	userSubPOST(w, r)
}

func UserSubGET(w http.ResponseWriter, r *http.Request) {
	userSubGET(w, r)
}

func UserSubPUT(w http.ResponseWriter, r *http.Request) {
	userSubPUT(w, r)
}
func UserSubDELETE(w http.ResponseWriter, r *http.Request) {
	userSubDELETE(w, r)
}

func UserTrackingSubListGET(w http.ResponseWriter, r *http.Request) {
	userTrackingSubListGet(w, r)
}
+37 −0
Original line number Diff line number Diff line
@@ -152,6 +152,17 @@ func convertJsonToZonalSubscription(jsonInfo string) *ZonalTrafficSubscription {
	return &zonal
}

func convertUserSubscriptionToJson1(userSubs *UserLocationEventSubscription) string {

	jsonInfo, err := json.Marshal(*userSubs)
	if err != nil {
		log.Error(err.Error())
		return ""
	}

	return string(jsonInfo)
}

func convertUserSubscriptionToJson(userSubs *UserTrackingSubscription) string {

	jsonInfo, err := json.Marshal(*userSubs)
@@ -163,6 +174,21 @@ func convertUserSubscriptionToJson(userSubs *UserTrackingSubscription) string {
	return string(jsonInfo)
}

func convertJsonToUserSubscription1(jsonInfo string) *UserLocationEventSubscription {

	if jsonInfo == "" {
		return nil
	}

	var user UserLocationEventSubscription
	err := json.Unmarshal([]byte(jsonInfo), &user)
	if err != nil {
		log.Error(err.Error())
		return nil
	}
	return &user
}

func convertJsonToUserSubscription(jsonInfo string) *UserTrackingSubscription {

	if jsonInfo == "" {
@@ -178,6 +204,17 @@ func convertJsonToUserSubscription(jsonInfo string) *UserTrackingSubscription {
	return &user
}

func convertPeriodicSubscriptionToJson1(periodicSubs *UserLocationPeriodicSubscription) string {

	jsonInfo, err := json.Marshal(*periodicSubs)
	if err != nil {
		log.Error(err.Error())
		return ""
	}

	return string(jsonInfo)
}

func convertPeriodicSubscriptionToJson(periodicSubs *PeriodicNotificationSubscription) string {

	jsonInfo, err := json.Marshal(*periodicSubs)
Loading