feat: notifications (#172)
The Notifications API allows plugins to register Notification Providers which have `sendNotification` and `resendNotification`. Each plugin can listen to any events transmittet over the event bus and the result of the notification send will be persisted in the database to allow for clear communications timeline + ability to resend notifications.
This commit is contained in:
1 parent
4229e241d0
commit
7308946e56
46 files changed
+1538
-254
No files matched your search
@@ -422,8 +422,41 @@ class WebshipperFulfillmentService extends FulfillmentService {
|
||||
/**
|
||||
* This plugin doesn't support shipment documents.
|
||||
*/
|
||||
async getShipmentDocuments() {
|
||||
return []
|
||||
async retrieveDocuments(fulfillmentData, documentType) {
|
||||
switch (documentType) {
|
||||
case "label":
|
||||
const labelRelation = fulfillmentData?.relationships?.labels
|
||||
if (labelRelation) {
|
||||
const docs = await this.retrieveRelationship(labelRelation)
|
||||
.then(({ data }) => data)
|
||||
.catch((_) => [])
|
||||
|
||||
return docs.map((d) => ({
|
||||
name: d.attributes.document_type,
|
||||
base_64: d.attributes.base64,
|
||||
type: "application/pdf",
|
||||
}))
|
||||
}
|
||||
return []
|
||||
|
||||
case "invoice":
|
||||
const docRelation = fulfillmentData?.relationships?.documents
|
||||
if (docRelation) {
|
||||
const docs = await this.retrieveRelationship(docRelation)
|
||||
.then(({ data }) => data)
|
||||
.catch((_) => [])
|
||||
|
||||
return docs.map((d) => ({
|
||||
name: d.attributes.document_type,
|
||||
base_64: d.attributes.base64,
|
||||
type: "application/pdf",
|
||||
}))
|
||||
}
|
||||
return []
|
||||
|
||||
default:
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user