cleaned up webhooks package
This commit is contained in:
@@ -20,7 +20,7 @@ type (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func Webhooks(
|
func Routes(
|
||||||
r *gin.RouterGroup,
|
r *gin.RouterGroup,
|
||||||
logger *logging.Logger,
|
logger *logging.Logger,
|
||||||
db *raw_events.Store,
|
db *raw_events.Store,
|
||||||
@@ -38,7 +38,7 @@ func Webhooks(
|
|||||||
|
|
||||||
r.GET(h.cfg.OAuthRedirectURIWithAcctIDParam, response.Handler(h.redirectURI))
|
r.GET(h.cfg.OAuthRedirectURIWithAcctIDParam, response.Handler(h.redirectURI))
|
||||||
|
|
||||||
r.GET("/{acctID}/new-account-link", response.Handler(h.newAccountLink))
|
r.GET("/:acctID/new-account-link", response.Handler(h.newAccountLink))
|
||||||
}
|
}
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@@ -134,7 +134,7 @@ func (h webhooks) redirectURI(c *gin.Context) (response.Response, error) {
|
|||||||
return response.SeeOther(fmt.Sprintf("/accounts/%d", acctID)), nil
|
return response.SeeOther(fmt.Sprintf("/accounts/%d", acctID)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET /{acctID}/new-account-link
|
// GET /:acctID/new-account-link
|
||||||
func (h webhooks) newAccountLink(c *gin.Context) (response.Response, error) {
|
func (h webhooks) newAccountLink(c *gin.Context) (response.Response, error) {
|
||||||
r := c.Request
|
r := c.Request
|
||||||
acctIDStr := c.Param("acctID")
|
acctIDStr := c.Param("acctID")
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Webhooks(
|
func Routes(
|
||||||
r *gin.RouterGroup,
|
r *gin.RouterGroup,
|
||||||
logger *logging.Logger,
|
logger *logging.Logger,
|
||||||
db *raw_events.Store,
|
db *raw_events.Store,
|
||||||
|
|||||||
@@ -15,26 +15,26 @@ type Config struct {
|
|||||||
Etsy etsy.Config
|
Etsy etsy.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
func Webhooks(
|
func Routes(
|
||||||
r *gin.RouterGroup,
|
r *gin.RouterGroup,
|
||||||
logger *logging.Logger,
|
logger *logging.Logger,
|
||||||
eventsDB *raw_events.Store,
|
eventsDB *raw_events.Store,
|
||||||
etsyPlatform *etsy_platform.Platform,
|
etsyPlatform *etsy_platform.Platform,
|
||||||
cfg Config,
|
cfg Config,
|
||||||
) {
|
) {
|
||||||
etsy.Webhooks(
|
etsy.Routes(
|
||||||
r.Group("/etsy"),
|
r.Group("/etsy"),
|
||||||
logger.WithGroup("etsy"),
|
logger.WithGroup("etsy"),
|
||||||
eventsDB,
|
eventsDB,
|
||||||
etsyPlatform,
|
etsyPlatform,
|
||||||
cfg.Etsy,
|
cfg.Etsy,
|
||||||
)
|
)
|
||||||
tiktok.Webhooks(
|
tiktok.Routes(
|
||||||
r.Group("/tiktok"),
|
r.Group("/tiktok"),
|
||||||
logger.WithGroup("tiktok"),
|
logger.WithGroup("tiktok"),
|
||||||
eventsDB,
|
eventsDB,
|
||||||
)
|
)
|
||||||
wix.Webhooks(
|
wix.Routes(
|
||||||
r.Group("/wix"),
|
r.Group("/wix"),
|
||||||
logger.WithGroup("wix"),
|
logger.WithGroup("wix"),
|
||||||
eventsDB,
|
eventsDB,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Webhooks(
|
func Routes(
|
||||||
r *gin.RouterGroup,
|
r *gin.RouterGroup,
|
||||||
logger *logging.Logger,
|
logger *logging.Logger,
|
||||||
db *raw_events.Store,
|
db *raw_events.Store,
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ func NewRouter(
|
|||||||
sq,
|
sq,
|
||||||
).Trim("/api")
|
).Trim("/api")
|
||||||
|
|
||||||
|
// TODO: group these into a single unifieds 'apis' object/package?
|
||||||
auth_api.Routes(
|
auth_api.Routes(
|
||||||
api.Group("/auth"),
|
api.Group("/auth"),
|
||||||
apiLogger.WithGroup("/auth"),
|
apiLogger.WithGroup("/auth"),
|
||||||
@@ -110,17 +111,14 @@ func NewRouter(
|
|||||||
accts,
|
accts,
|
||||||
unp.Group("/accounts"),
|
unp.Group("/accounts"),
|
||||||
)
|
)
|
||||||
|
webhooks.Routes(
|
||||||
// api webhooks (TODO: make a router for these)
|
|
||||||
|
|
||||||
webhooks.Webhooks(
|
|
||||||
api.Group("/webhooks"),
|
api.Group("/webhooks"),
|
||||||
logger.WithGroup("webhooks"),
|
apiLogger.WithGroup("/webhooks"),
|
||||||
rawEvents,
|
rawEvents,
|
||||||
etsy,
|
etsy,
|
||||||
webhooks.Config{
|
webhooks.Config{
|
||||||
Etsy: etsy_webhooks.Config{
|
Etsy: etsy_webhooks.Config{
|
||||||
OAuthRedirectURIWithAcctIDParam: "/oauth/account/{acctID}/auth_code",
|
OAuthRedirectURIWithAcctIDParam: "/oauth/accounts/:acctID/auth_code",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user