Add metadata and privateMetadata to webhook payloads (#730)
* Add metadata and privateMetadata to webhook payloads * Add changeset
This commit is contained in:
parent
e1980aae90
commit
d4089ab519
6 changed files with 67 additions and 1 deletions
6
.changeset/healthy-bobcats-confess.md
Normal file
6
.changeset/healthy-bobcats-confess.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
"saleor-app-emails-and-messages": patch
|
||||
---
|
||||
|
||||
Added `metadata` and `privateMetadata` to email payloads.
|
||||
|
|
@ -5,6 +5,14 @@ fragment OrderDetails on Order {
|
|||
channel {
|
||||
slug
|
||||
}
|
||||
metadata {
|
||||
key
|
||||
value
|
||||
}
|
||||
privateMetadata {
|
||||
key
|
||||
value
|
||||
}
|
||||
user {
|
||||
email
|
||||
firstName
|
||||
|
|
|
@ -15,6 +15,18 @@ const exampleOrderPayload: OrderDetailsFragment = {
|
|||
id: "T3JkZXI6NTdiNTBhNDAtYzRmYi00YjQzLWIxODgtM2JhZmRlMTc3MGQ5",
|
||||
number: "198",
|
||||
userEmail: "adrian.king@example.com",
|
||||
metadata: [
|
||||
{
|
||||
key: "metadata-example",
|
||||
value: "Example value",
|
||||
},
|
||||
],
|
||||
privateMetadata: [
|
||||
{
|
||||
key: "private-metadata-example",
|
||||
value: "Example value for private metadata",
|
||||
},
|
||||
],
|
||||
channel: {
|
||||
slug: "default-channel",
|
||||
},
|
||||
|
@ -128,6 +140,18 @@ const orderFullyPaidPayload: OrderFullyPaidWebhookPayloadFragment = {
|
|||
const invoiceSentPayload: InvoiceSentWebhookPayloadFragment = {
|
||||
invoice: {
|
||||
id: "SW52b2ljZToxMDE=",
|
||||
metadata: [
|
||||
{
|
||||
key: "metadata-example",
|
||||
value: "Example value",
|
||||
},
|
||||
],
|
||||
privateMetadata: [
|
||||
{
|
||||
key: "private-metadata-example",
|
||||
value: "Example value for private metadata",
|
||||
},
|
||||
],
|
||||
message: null,
|
||||
externalUrl: null,
|
||||
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",
|
||||
giftCard: {
|
||||
code: "XXXX",
|
||||
metadata: [
|
||||
{
|
||||
key: "metadata-example",
|
||||
value: "Example value",
|
||||
},
|
||||
],
|
||||
privateMetadata: [
|
||||
{
|
||||
key: "private-metadata-example",
|
||||
value: "Example value for private metadata",
|
||||
},
|
||||
],
|
||||
tags: [],
|
||||
created: "2021-03-16T13:12:00+00:00",
|
||||
currentBalance: {
|
||||
|
|
|
@ -121,7 +121,7 @@ describe("WebhookManagementService", function () {
|
|||
name: invoiceSentWebhook.name,
|
||||
targetUrl: "https://example.com/api/webhooks/invoice-sent",
|
||||
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 } }}",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
|
@ -15,6 +15,14 @@ const GiftCardSentWebhookPayload = gql`
|
|||
created
|
||||
usedByEmail
|
||||
isActive
|
||||
metadata {
|
||||
key
|
||||
value
|
||||
}
|
||||
privateMetadata {
|
||||
key
|
||||
value
|
||||
}
|
||||
initialBalance {
|
||||
currency
|
||||
amount
|
||||
|
|
|
@ -13,6 +13,14 @@ const InvoiceSentWebhookPayload = gql`
|
|||
fragment InvoiceSentWebhookPayload on InvoiceSent {
|
||||
invoice {
|
||||
id
|
||||
metadata {
|
||||
key
|
||||
value
|
||||
}
|
||||
privateMetadata {
|
||||
key
|
||||
value
|
||||
}
|
||||
message
|
||||
externalUrl
|
||||
url
|
||||
|
|
Loading…
Reference in a new issue