From 4261c6771cf3e9e5db07d6191f48d9940bd61acf Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Mon, 26 Jul 2021 13:54:24 -0400 Subject: [PATCH] add receipt and device deletion --- internal/api/api.go | 4 ++++ internal/api/devices.go | 4 ++++ internal/api/receipt.go | 12 ++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 internal/api/receipt.go diff --git a/internal/api/api.go b/internal/api/api.go index 03c7c5d..234bd5c 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -67,6 +67,10 @@ func (a *api) Routes() *httprouter.Router { router.POST("/v1/device", a.upsertDeviceHandler) router.POST("/v1/device/:apns/test", a.testDeviceHandler) router.POST("/v1/device/:apns/account", a.upsertAccountHandler) + router.DELETE("/v1/device/:apns", a.deleteDeviceHandler) + + router.POST("/v1/receipt", a.checkReceiptHandler) + router.POST("/v1/receipt/:apns", a.checkReceiptHandler) return router } diff --git a/internal/api/devices.go b/internal/api/devices.go index 851296e..f20428b 100644 --- a/internal/api/devices.go +++ b/internal/api/devices.go @@ -91,3 +91,7 @@ func (a *api) testDeviceHandler(w http.ResponseWriter, r *http.Request, ps httpr } w.WriteHeader(http.StatusOK) } + +func (a *api) deleteDeviceHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { + w.WriteHeader(http.StatusOK) +} diff --git a/internal/api/receipt.go b/internal/api/receipt.go new file mode 100644 index 0000000..b623b57 --- /dev/null +++ b/internal/api/receipt.go @@ -0,0 +1,12 @@ +package api + +import ( + "net/http" + + "github.com/julienschmidt/httprouter" +) + +func (a *api) checkReceiptHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { + w.Write([]byte(`{"status_code": 11, "status_message": "Receipt is valid, lifetime subscription", "subscription_type": "lifetime"}`)) + w.WriteHeader(http.StatusOK) +}