36 lines
1.5 KiB
Python
36 lines
1.5 KiB
Python
import yaml
|
|
import requests
|
|
|
|
SETTINGS = yaml.safe_load(open('settings.yaml'))
|
|
|
|
def sendDiscordNotification(*args, settings=SETTINGS):
|
|
newLine = '\n'
|
|
shipmentNotification = requests.post(
|
|
SETTINGS['DISCORD_WEBHOOK'],
|
|
json = {
|
|
"embeds": [
|
|
{
|
|
"title": ":package: New Inbound Shipment Detected :package:",
|
|
"url": f"https://sellercentral.amazon.co.uk/fba/sendtoamazon?wf={args[0]}",
|
|
"color": 4886754,
|
|
"fields": [
|
|
{
|
|
"name": "Shipment Information",
|
|
"value": f'''
|
|
> Inbound Shipment Plan ID: {args[0]}
|
|
> Creation Date: {args[1]['creationDate']}
|
|
> Destination Fulfilment Centres: {', '.join(destination for destination in args[1]['destinations'])}
|
|
> Shipments: {', '.join(f'[{shipmentID}](https://sellercentral.amazon.co.uk/fba/inbound-shipment/summary/{shipmentID}/contents)' for shipmentID in args[1]['shipmentIDs'])}
|
|
'''
|
|
},
|
|
{
|
|
"name": "Shipment Contents",
|
|
"value": f'''
|
|
{newLine.join(f"> {MSKU}: {Count}" for MSKU, Count in args[1]['contents'].items())}
|
|
'''
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
) |