+ contact requests
Some checks failed
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
ci/woodpecker/push/bump_version Pipeline failed
Some checks failed
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
ci/woodpecker/push/bump_version Pipeline failed
This commit is contained in:
29
api/server/internal/server/siteimp/contact.go
Normal file
29
api/server/internal/server/siteimp/contact.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package siteimp
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/tech/sendico/pkg/api/http/response"
|
||||
snotifications "github.com/tech/sendico/pkg/messaging/notifications/site"
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func (a *SiteAPI) contactRequest(r *http.Request) http.HandlerFunc {
|
||||
var request model.ContactRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&request); err != nil {
|
||||
a.logger.Warn("Failed to decode contact request payload", zap.Error(err))
|
||||
return response.BadRequest(a.logger, a.Name(), "invalid_payload", "Failed to decode contact request payload")
|
||||
}
|
||||
request.Normalize()
|
||||
if err := request.Validate(); err != nil {
|
||||
a.logger.Warn("Contact request validation failed", zap.Error(err))
|
||||
return response.BadPayload(a.logger, a.Name(), err)
|
||||
}
|
||||
if err := a.producer.SendMessage(snotifications.ContactRequest(a.Name(), &request)); err != nil {
|
||||
a.logger.Warn("Failed to enqueue contact request notification", zap.Error(err))
|
||||
return response.Internal(a.logger, a.Name(), err)
|
||||
}
|
||||
return response.Accepted(a.logger, map[string]string{"status": "queued"})
|
||||
}
|
||||
31
api/server/internal/server/siteimp/demo.go
Normal file
31
api/server/internal/server/siteimp/demo.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package siteimp
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/tech/sendico/pkg/api/http/response"
|
||||
snotifications "github.com/tech/sendico/pkg/messaging/notifications/site"
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func (a *SiteAPI) demoRequest(r *http.Request) http.HandlerFunc {
|
||||
var request model.DemoRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&request); err != nil {
|
||||
a.logger.Warn("Failed to decode demo request payload", zap.Error(err))
|
||||
return response.BadRequest(a.logger, a.Name(), "invalid_payload", "Failed to decode demo request payload")
|
||||
}
|
||||
request.Normalize()
|
||||
if err := request.Validate(); err != nil {
|
||||
a.logger.Warn("Demo request validation failed", zap.Error(err))
|
||||
return response.BadPayload(a.logger, a.Name(), err)
|
||||
}
|
||||
|
||||
if err := a.producer.SendMessage(snotifications.DemoRequest(a.Name(), &request)); err != nil {
|
||||
a.logger.Warn("Failed to enqueue demo request notification", zap.Error(err))
|
||||
return response.Internal(a.logger, a.Name(), err)
|
||||
}
|
||||
|
||||
return response.Accepted(a.logger, map[string]string{"status": "queued"})
|
||||
}
|
||||
@@ -2,18 +2,12 @@ package siteimp
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
api "github.com/tech/sendico/pkg/api/http"
|
||||
"github.com/tech/sendico/pkg/api/http/response"
|
||||
"github.com/tech/sendico/pkg/messaging"
|
||||
snotifications "github.com/tech/sendico/pkg/messaging/notifications/site"
|
||||
"github.com/tech/sendico/pkg/mlogger"
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
"github.com/tech/sendico/pkg/mservice"
|
||||
eapi "github.com/tech/sendico/server/interface/api"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type SiteAPI struct {
|
||||
@@ -29,32 +23,13 @@ func (a *SiteAPI) Finish(_ context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *SiteAPI) demoRequest(r *http.Request) http.HandlerFunc {
|
||||
var request model.DemoRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&request); err != nil {
|
||||
a.logger.Warn("Failed to decode demo request payload", zap.Error(err))
|
||||
return response.BadRequest(a.logger, a.Name(), "invalid_payload", "Failed to decode demo request payload")
|
||||
}
|
||||
request.Normalize()
|
||||
if err := request.Validate(); err != nil {
|
||||
a.logger.Warn("Demo request validation failed", zap.Error(err))
|
||||
return response.BadPayload(a.logger, a.Name(), err)
|
||||
}
|
||||
|
||||
if err := a.producer.SendMessage(snotifications.DemoRequest(a.Name(), &request)); err != nil {
|
||||
a.logger.Warn("Failed to enqueue demo request notification", zap.Error(err))
|
||||
return response.Internal(a.logger, a.Name(), err)
|
||||
}
|
||||
|
||||
return response.Accepted(a.logger, map[string]string{"status": "queued"})
|
||||
}
|
||||
|
||||
func CreateAPI(a eapi.API) (*SiteAPI, error) {
|
||||
p := &SiteAPI{
|
||||
logger: a.Logger().Named(mservice.Site),
|
||||
producer: a.Register().Messaging().Producer(),
|
||||
}
|
||||
|
||||
a.Register().Handler(mservice.Site, "/demo/request", api.Post, p.demoRequest)
|
||||
a.Register().Handler(mservice.Site, "/request/demo", api.Post, p.demoRequest)
|
||||
a.Register().Handler(mservice.Site, "/request/contact", api.Post, p.contactRequest)
|
||||
return p, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user