Adding a function to pull product names and send them in notifications, replacing SKUs
This commit is contained in:
parent
1f83971dcd
commit
b9fdb4825f
@ -75,6 +75,19 @@ def getAccessToken(settings=SETTINGS):
|
||||
|
||||
return AccessToken.json()['access_token']
|
||||
|
||||
def getProductName(SKU, settings=SETTINGS):
|
||||
product = requests.get(
|
||||
settings['SPAPI_ENDPOINT'] + '/listings/2021-08-01/items/' + settings['SELLER_ID'] + f'/{SKU}',
|
||||
headers = {
|
||||
'x-amz-access-token': getAccessToken(),
|
||||
},
|
||||
params = {
|
||||
'marketplaceIds': settings['MARKETPLACE_ID']
|
||||
},
|
||||
)
|
||||
|
||||
return product.json()['summaries'][0]['itemName']
|
||||
|
||||
def sendDiscordNotification(settings=SETTINGS, content=None):
|
||||
notification = {"content": content}
|
||||
requests.post(settings['DISCORD_WEBHOOK'], json=notification)
|
||||
@ -96,7 +109,6 @@ def parseInboundShipments(settings=SETTINGS):
|
||||
shipmentData = {}
|
||||
|
||||
for shipment in InboundShipments:
|
||||
log('Got shipment creation date: {}'.format(shipment['createdAt']), 'info')
|
||||
if isShipmentWithinSpecifiedDelta(shipment['createdAt']):
|
||||
log('Adding inbound plan to list: {}'.format(shipment['inboundPlanId']), 'info')
|
||||
inboundPlanIDs.append(shipment['inboundPlanId'])
|
||||
@ -119,7 +131,8 @@ def parseInboundShipments(settings=SETTINGS):
|
||||
itemDict = {}
|
||||
totalItemCount = 0
|
||||
for item in getShipment.json()['items']:
|
||||
itemDict.update({item.get('msku'): item.get('quantity')})
|
||||
productName = getProductName(item['msku'])
|
||||
itemDict.update({productName: item.get('quantity')})
|
||||
totalItemCount += item['quantity']
|
||||
itemDict.update({'Total item count': totalItemCount})
|
||||
shipmentData.update({ID: itemDict})
|
||||
|
@ -1,41 +0,0 @@
|
||||
[INFO] 🔄 Getting shipments...
|
||||
[INFO] Got shipment creation date: 2024-07-12T13:07:50Z
|
||||
[INFO] Current time: 2024-07-12 19:40:02.303950
|
||||
[INFO] Shipment creation time: 2024-07-12 13:07:50
|
||||
[INFO] Time delta: 6:32:12.303950
|
||||
[INFO] Got shipment creation date: 2024-07-10T09:34:31Z
|
||||
[INFO] Current time: 2024-07-12 19:40:02.306061
|
||||
[INFO] Shipment creation time: 2024-07-10 09:34:31
|
||||
[INFO] Time delta: 2 days, 10:05:31.306061
|
||||
[INFO] Got shipment creation date: 2024-07-09T15:47:43Z
|
||||
[INFO] Current time: 2024-07-12 19:40:02.306273
|
||||
[INFO] Shipment creation time: 2024-07-09 15:47:43
|
||||
[INFO] Time delta: 3 days, 3:52:19.306273
|
||||
[INFO] Got shipment creation date: 2024-07-08T12:23:20Z
|
||||
[INFO] Current time: 2024-07-12 19:40:02.306490
|
||||
[INFO] Shipment creation time: 2024-07-08 12:23:20
|
||||
[INFO] Time delta: 4 days, 7:16:42.306490
|
||||
[INFO] Got shipment creation date: 2024-07-05T12:57:09Z
|
||||
[INFO] Current time: 2024-07-12 19:40:02.306689
|
||||
[INFO] Shipment creation time: 2024-07-05 12:57:09
|
||||
[INFO] Time delta: 7 days, 6:42:53.306689
|
||||
[INFO] Got shipment creation date: 2024-07-05T11:39:06Z
|
||||
[INFO] Current time: 2024-07-12 19:40:02.306884
|
||||
[INFO] Shipment creation time: 2024-07-05 11:39:06
|
||||
[INFO] Time delta: 7 days, 8:00:56.306884
|
||||
[INFO] Got shipment creation date: 2024-07-04T13:50:17Z
|
||||
[INFO] Current time: 2024-07-12 19:40:02.307080
|
||||
[INFO] Shipment creation time: 2024-07-04 13:50:17
|
||||
[INFO] Time delta: 8 days, 5:49:45.307080
|
||||
[INFO] Got shipment creation date: 2024-07-03T13:29:03Z
|
||||
[INFO] Current time: 2024-07-12 19:40:02.307283
|
||||
[INFO] Shipment creation time: 2024-07-03 13:29:03
|
||||
[INFO] Time delta: 9 days, 6:10:59.307283
|
||||
[INFO] Got shipment creation date: 2024-07-02T14:06:09Z
|
||||
[INFO] Current time: 2024-07-12 19:40:02.307511
|
||||
[INFO] Shipment creation time: 2024-07-02 14:06:09
|
||||
[INFO] Time delta: 10 days, 5:33:53.307511
|
||||
[INFO] Got shipment creation date: 2024-07-01T14:54:48Z
|
||||
[INFO] Current time: 2024-07-12 19:40:02.307714
|
||||
[INFO] Shipment creation time: 2024-07-01 14:54:48
|
||||
[INFO] Time delta: 11 days, 4:45:14.307714
|
31
logs/log_2024-07-12_21:37:04.log
Normal file
31
logs/log_2024-07-12_21:37:04.log
Normal file
@ -0,0 +1,31 @@
|
||||
[INFO] 🔄 Getting shipments...
|
||||
[INFO] Current time: 2024-07-12 21:37:04.979052
|
||||
[INFO] Shipment creation time: 2024-07-12 13:07:50
|
||||
[INFO] Time delta: 8:29:14.979052
|
||||
[INFO] Current time: 2024-07-12 21:37:04.981162
|
||||
[INFO] Shipment creation time: 2024-07-10 09:34:31
|
||||
[INFO] Time delta: 2 days, 12:02:33.981162
|
||||
[INFO] Current time: 2024-07-12 21:37:04.981349
|
||||
[INFO] Shipment creation time: 2024-07-09 15:47:43
|
||||
[INFO] Time delta: 3 days, 5:49:21.981349
|
||||
[INFO] Current time: 2024-07-12 21:37:04.981507
|
||||
[INFO] Shipment creation time: 2024-07-08 12:23:20
|
||||
[INFO] Time delta: 4 days, 9:13:44.981507
|
||||
[INFO] Current time: 2024-07-12 21:37:04.981663
|
||||
[INFO] Shipment creation time: 2024-07-05 12:57:09
|
||||
[INFO] Time delta: 7 days, 8:39:55.981663
|
||||
[INFO] Current time: 2024-07-12 21:37:04.981816
|
||||
[INFO] Shipment creation time: 2024-07-05 11:39:06
|
||||
[INFO] Time delta: 7 days, 9:57:58.981816
|
||||
[INFO] Current time: 2024-07-12 21:37:04.981968
|
||||
[INFO] Shipment creation time: 2024-07-04 13:50:17
|
||||
[INFO] Time delta: 8 days, 7:46:47.981968
|
||||
[INFO] Current time: 2024-07-12 21:37:04.982168
|
||||
[INFO] Shipment creation time: 2024-07-03 13:29:03
|
||||
[INFO] Time delta: 9 days, 8:08:01.982168
|
||||
[INFO] Current time: 2024-07-12 21:37:04.982320
|
||||
[INFO] Shipment creation time: 2024-07-02 14:06:09
|
||||
[INFO] Time delta: 10 days, 7:30:55.982320
|
||||
[INFO] Current time: 2024-07-12 21:37:04.982470
|
||||
[INFO] Shipment creation time: 2024-07-01 14:54:48
|
||||
[INFO] Time delta: 11 days, 6:42:16.982470
|
@ -1,5 +1,7 @@
|
||||
REFRESH_TOKEN: TOKEN
|
||||
CLIENT_ID: CLIENTID
|
||||
CLIENT_SECRET: CLIENTSECRET
|
||||
DISCORD_WEBHOOK: DISCORDWEBHOOK
|
||||
SPAPI_ENDPOINT: SPAPIENDPOINT
|
||||
REFRESH_TOKEN: 'TOKEN'
|
||||
CLIENT_ID: 'CLIENTID'
|
||||
CLIENT_SECRET: 'CLIENTSECRET'
|
||||
DISCORD_WEBHOOK: 'DISCORDWEBHOOK'
|
||||
SPAPI_ENDPOINT: 'SPAPIENDPOINT'
|
||||
SELLER_ID: 'SELLERID'
|
||||
MARKETPLACE_ID: 'MARKETPLACEID'
|
Loading…
Reference in New Issue
Block a user