88 "github.com/tidepool-org/platform/mailer"
99 "github.com/tidepool-org/platform/oura/customerio"
1010 "github.com/tidepool-org/platform/oura/jotform"
11+ "github.com/tidepool-org/platform/oura/shopify"
1112
1213 userClient "github.com/tidepool-org/platform/user/client"
1314
@@ -40,6 +41,8 @@ import (
4041 "github.com/tidepool-org/platform/errors"
4142 "github.com/tidepool-org/platform/events"
4243 jotformAPI "github.com/tidepool-org/platform/oura/jotform/api"
44+ shopifyAPI "github.com/tidepool-org/platform/oura/shopify/api"
45+ shopifyClient "github.com/tidepool-org/platform/oura/shopify/client"
4346
4447 "github.com/tidepool-org/platform/log"
4548 oauthProvider "github.com/tidepool-org/platform/oauth/provider"
@@ -305,7 +308,17 @@ func (s *Service) initializeRouter() error {
305308 return errors .Wrap (err , "unable to create user client" )
306309 }
307310
308- webhookProcessor , err := jotform .NewWebhookProcessor (jotformConfig , s .Logger (), s .consentService , customerIOClient , usrClient )
311+ shopifyConfig := shopify.ClientConfig {}
312+ if err := envconfig .Process ("" , & shopifyConfig ); err != nil {
313+ return errors .Wrap (err , "unable to load shopify config" )
314+ }
315+
316+ shopifyClnt , err := shopifyClient .New (context .Background (), shopifyConfig )
317+ if err != nil {
318+ return errors .Wrap (err , "unable to create shopify client" )
319+ }
320+
321+ webhookProcessor , err := jotform .NewWebhookProcessor (jotformConfig , s .Logger (), s .consentService , customerIOClient , usrClient , shopifyClnt )
309322 if err != nil {
310323 return errors .Wrap (err , "unable to create jotform webhook processor" )
311324 }
@@ -315,9 +328,19 @@ func (s *Service) initializeRouter() error {
315328 return errors .Wrap (err , "unable to create jotform router" )
316329 }
317330
331+ fulfillmentEventCreatedProcessor , err := shopify .NewFulfillmentCreatedEventProcessor (s .Logger (), customerIOClient , shopifyClnt )
332+ if err != nil {
333+ return errors .Wrap (err , "unable to create fulfillment created event processor" )
334+ }
335+
336+ shopifyRouter , err := shopifyAPI .NewRouter (fulfillmentEventCreatedProcessor )
337+ if err != nil {
338+ return errors .Wrap (err , "unable to create shopify router" )
339+ }
340+
318341 s .Logger ().Debug ("Initializing routers" )
319342
320- if err = s .API ().InitializeRouters (apiRouter , v1Router , consentV1Router , jotformRouter ); err != nil {
343+ if err = s .API ().InitializeRouters (apiRouter , v1Router , consentV1Router , jotformRouter , shopifyRouter ); err != nil {
321344 return errors .Wrap (err , "unable to initialize routers" )
322345 }
323346
0 commit comments