Skip to content

Commit

Permalink
v1.2.9 finished web hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
fareskato committed Mar 4, 2024
1 parent c7335dc commit 181f67a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,25 @@ func (s Shopify) verifyWebHook(data []byte, hmacHeader string) bool {
}
return hmac.Equal(expectedHMAC, decodedHMAC)
}
func WebHookCreateEntity[T any](s Shopify, t T, hmacHeader string, reqBody []byte) (*T, error) {

// WebHookHandleActionEntity uses to habdle web hooks for sources like product, order ....etc
// this function handle create,update and delete web hooks
// in case of create or update the sended data from shopify conatins resource filels like
// for example:
// {
// "title": "Example T-Shirt",
// "updated_at": "2021-12-31T19:00:00-05:00",
// "vendor": "Acme",
// .... other fileds
// }
// in case of delete the sended data contains only the deleted item id like:
//
// {
// "id": 788032119674292900
// }
//
// for more unfo refer to: https://shopify.dev/docs/api/admin-rest/2024-01/resources/webhook#event-topics
func WebHookHandleActionEntity[T any](s Shopify, t T, hmacHeader string, reqBody []byte) (*T, error) {
if s.storeWebHookKey == "" {
return nil, fkutils.ErrWebHookMissed
}
Expand Down

0 comments on commit 181f67a

Please sign in to comment.