Add metadata and privateMetadata to webhook payloads (#730)

* Add metadata and privateMetadata to webhook payloads

* Add changeset
This commit is contained in:
Krzysztof Wolski 2023-07-07 13:01:36 +02:00 committed by GitHub
parent e1980aae90
commit d4089ab519
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 67 additions and 1 deletions

View file

@ -0,0 +1,6 @@
---
"saleor-app-emails-and-messages": patch
---
Added `metadata` and `privateMetadata` to email payloads.

View file

@ -5,6 +5,14 @@ fragment OrderDetails on Order {
channel { channel {
slug slug
} }
metadata {
key
value
}
privateMetadata {
key
value
}
user { user {
email email
firstName firstName

View file

@ -15,6 +15,18 @@ const exampleOrderPayload: OrderDetailsFragment = {
id: "T3JkZXI6NTdiNTBhNDAtYzRmYi00YjQzLWIxODgtM2JhZmRlMTc3MGQ5", id: "T3JkZXI6NTdiNTBhNDAtYzRmYi00YjQzLWIxODgtM2JhZmRlMTc3MGQ5",
number: "198", number: "198",
userEmail: "adrian.king@example.com", userEmail: "adrian.king@example.com",
metadata: [
{
key: "metadata-example",
value: "Example value",
},
],
privateMetadata: [
{
key: "private-metadata-example",
value: "Example value for private metadata",
},
],
channel: { channel: {
slug: "default-channel", slug: "default-channel",
}, },
@ -128,6 +140,18 @@ const orderFullyPaidPayload: OrderFullyPaidWebhookPayloadFragment = {
const invoiceSentPayload: InvoiceSentWebhookPayloadFragment = { const invoiceSentPayload: InvoiceSentWebhookPayloadFragment = {
invoice: { invoice: {
id: "SW52b2ljZToxMDE=", id: "SW52b2ljZToxMDE=",
metadata: [
{
key: "metadata-example",
value: "Example value",
},
],
privateMetadata: [
{
key: "private-metadata-example",
value: "Example value for private metadata",
},
],
message: null, message: null,
externalUrl: null, externalUrl: null,
url: "https://example.com/media/invoices/invoice-1032023-order-57b50a40-c4fb-4b43-b188-3bafde1770d9-fa968541-02fa-4317-b121-7205.pdf", url: "https://example.com/media/invoices/invoice-1032023-order-57b50a40-c4fb-4b43-b188-3bafde1770d9-fa968541-02fa-4317-b121-7205.pdf",
@ -254,6 +278,18 @@ const giftCardSentPayload: GiftCardSentWebhookPayloadFragment = {
sentToEmail: "user@example.com", sentToEmail: "user@example.com",
giftCard: { giftCard: {
code: "XXXX", code: "XXXX",
metadata: [
{
key: "metadata-example",
value: "Example value",
},
],
privateMetadata: [
{
key: "private-metadata-example",
value: "Example value for private metadata",
},
],
tags: [], tags: [],
created: "2021-03-16T13:12:00+00:00", created: "2021-03-16T13:12:00+00:00",
currentBalance: { currentBalance: {

View file

@ -121,7 +121,7 @@ describe("WebhookManagementService", function () {
name: invoiceSentWebhook.name, name: invoiceSentWebhook.name,
targetUrl: "https://example.com/api/webhooks/invoice-sent", targetUrl: "https://example.com/api/webhooks/invoice-sent",
query: query:
"subscription InvoiceSent { event { ...InvoiceSentWebhookPayload }}fragment InvoiceSentWebhookPayload on InvoiceSent { invoice { id message externalUrl url order { id } } order { ...OrderDetails }}fragment OrderDetails on Order { id number userEmail channel { slug } user { email firstName lastName } billingAddress { streetAddress1 city postalCode country { country } } shippingAddress { streetAddress1 city postalCode country { country } } lines { id productName variantName quantity thumbnail { url alt } unitPrice { gross { currency amount } } totalPrice { gross { currency amount } } } subtotal { gross { amount currency } } shippingPrice { gross { amount currency } } total { gross { amount currency } }}", "subscription InvoiceSent { event { ...InvoiceSentWebhookPayload }}fragment InvoiceSentWebhookPayload on InvoiceSent { invoice { id metadata { key value } privateMetadata { key value } message externalUrl url order { id } } order { ...OrderDetails }}fragment OrderDetails on Order { id number userEmail channel { slug } metadata { key value } privateMetadata { key value } user { email firstName lastName } billingAddress { streetAddress1 city postalCode country { country } } shippingAddress { streetAddress1 city postalCode country { country } } lines { id productName variantName quantity thumbnail { url alt } unitPrice { gross { currency amount } } totalPrice { gross { currency amount } } } subtotal { gross { amount currency } } shippingPrice { gross { amount currency } } total { gross { amount currency } }}",
}, },
}); });
}); });

View file

@ -15,6 +15,14 @@ const GiftCardSentWebhookPayload = gql`
created created
usedByEmail usedByEmail
isActive isActive
metadata {
key
value
}
privateMetadata {
key
value
}
initialBalance { initialBalance {
currency currency
amount amount

View file

@ -13,6 +13,14 @@ const InvoiceSentWebhookPayload = gql`
fragment InvoiceSentWebhookPayload on InvoiceSent { fragment InvoiceSentWebhookPayload on InvoiceSent {
invoice { invoice {
id id
metadata {
key
value
}
privateMetadata {
key
value
}
message message
externalUrl externalUrl
url url