Send and receive SMS messages using your Android phone programmatically via a simple HTTP API
Update subscription expired event handler
Acho Arnold0006397c2370
diff --git a/api/go.mod b/api/go.modindex 428f2364..17a6f95c 100644--- a/api/go.mod+++ b/api/go.mod@@ -8,7 +8,7 @@ require (github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.36.0github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.12.0github.com/NdoleStudio/go-otelroundtripper v0.0.7- github.com/NdoleStudio/lemonsqueezy-go v0.0.8+ github.com/NdoleStudio/lemonsqueezy-go v0.0.12github.com/carlmjohnson/requests v0.23.2github.com/cheggaaa/pb/v3 v3.0.8github.com/cloudevents/sdk-go/v2 v2.13.0@@ -31,7 +31,7 @@ require (github.com/redis/go-redis/v9 v9.0.2github.com/rs/zerolog v1.29.0github.com/sendgrid/sendgrid-go v3.12.0+incompatible- github.com/stretchr/testify v1.8.2+ github.com/stretchr/testify v1.8.4github.com/swaggo/swag v1.8.10github.com/thedevsaddam/govalidator v1.9.10github.com/uptrace/uptrace-go v1.13.0diff --git a/api/go.sum b/api/go.sumindex 1981b35f..a010b45c 100644--- a/api/go.sum+++ b/api/go.sum@@ -76,8 +76,8 @@ github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCgithub.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=github.com/NdoleStudio/go-otelroundtripper v0.0.7 h1:4dNXdVDxHdzRIe0TMpxfx/t+p0EJCvayugtbd/yCoOc=github.com/NdoleStudio/go-otelroundtripper v0.0.7/go.mod h1:keaIZbY7yfCTgm5kffvO/QAw86rUEEY3a8sKBTYxb3U=-github.com/NdoleStudio/lemonsqueezy-go v0.0.8 h1:dHUVRZLWgTJo6u0bsF3k1H5BksbiMW6KhBc0zSlxjbw=-github.com/NdoleStudio/lemonsqueezy-go v0.0.8/go.mod h1:bWUDOXUQywIYY4Ak79Fp5PPKHY8ju0PDOzFWlWM2co0=+github.com/NdoleStudio/lemonsqueezy-go v0.0.12 h1:uG4a6xnqw65csluoCWUH7iiFYOOsu45KGUfArUAOytg=+github.com/NdoleStudio/lemonsqueezy-go v0.0.12/go.mod h1:yRYTtU1RyapMDPTFKypIEKLEjPAbWq9a5PGqqvIn6/Y=github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=github.com/PuerkitoBio/goquery v1.5.0/go.mod h1:qD2PgZ9lccMbQlc7eEOjaeRlFQON7xY8kdmcsrnKqMg=github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=@@ -402,8 +402,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=-github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=-github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=+github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=+github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=github.com/swaggo/files v0.0.0-20220728132757-551d4a08d97a/go.mod h1:lKJPbtWzJ9JhsTN1k1gZgleJWY/cqq0psdoMmaThG3w=github.com/swaggo/files v1.0.0 h1:1gGXVIeUFCS/dta17rnP0iOpr6CXFwKD7EO5ID233e4=github.com/swaggo/files v1.0.0/go.mod h1:N59U6URJLyU1PQgFqPM7wXLMhJx7QAolnvfQkqO13kc=diff --git a/api/pkg/handlers/lemonsqueezy_handler.go b/api/pkg/handlers/lemonsqueezy_handler.goindex 98db9784..d47af5a1 100644--- a/api/pkg/handlers/lemonsqueezy_handler.go+++ b/api/pkg/handlers/lemonsqueezy_handler.go@@ -80,19 +80,26 @@ func (h *LemonsqueezyHandler) handleRequest(ctx context.Context, c *fiber.Ctx) eeventName := c.Get("X-Event-Name")switch eventName {case "subscription_created":- var request lemonsqueezy.WebHookRequestSubscription+ var request lemonsqueezy.WebhookRequestSubscriptionerr := json.Unmarshal(c.Body(), &request)if err != nil {return stacktrace.Propagate(err, fmt.Sprintf("cannot marshall [%s] to [%T]", c.Body(), request))}return h.service.HandleSubscriptionCreatedEvent(ctx, c.OriginalURL(), &request)case "subscription_cancelled":- var request lemonsqueezy.WebHookRequestSubscription+ var request lemonsqueezy.WebhookRequestSubscriptionerr := json.Unmarshal(c.Body(), &request)if err != nil {return stacktrace.Propagate(err, fmt.Sprintf("cannot marshall [%s] to [%T]", c.Body(), request))}return h.service.HandleSubscriptionCanceledEvent(ctx, c.OriginalURL(), &request)+ case "subscription_expired":+ var request lemonsqueezy.WebhookRequestSubscription+ err := json.Unmarshal(c.Body(), &request)+ if err != nil {+ return stacktrace.Propagate(err, fmt.Sprintf("cannot marshall [%s] to [%T]", c.Body(), request))+ }+ return h.service.HandleSubscriptionExpiredEvent(ctx, c.OriginalURL(), &request)default:return stacktrace.NewError(fmt.Sprintf("invalid event [%s] received with request [%s]", eventName, c.Body()))}