Last active
July 29, 2019 06:33
-
-
Save BedrosovaYulia/695576928ea89d5f4115a97049bafe94 to your computer and use it in GitHub Desktop.
AWS Lambda Function for the Russian Post tracking via SOAP client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from zeep import Client | |
def lambda_handler(event, context): | |
url = 'https://tracking.russianpost.ru/rtm34?wsdl' | |
barcode = event['barcode'] | |
my_login = '****************' | |
my_password = '**************' | |
client = Client(url) | |
OperationHistoryRequest= { | |
"Barcode":barcode, | |
"MessageType":0, | |
"Language":"RUS" | |
} | |
AuthorizationHeader= { | |
"login":my_login, | |
"password":my_password | |
} | |
with client.settings(strict=False): | |
result = client.service.getOperationHistory(OperationHistoryRequest,AuthorizationHeader) | |
info='' | |
for item in result: | |
try: | |
info=info+str(item['OperationParameters']['OperDate'])+' '+str(item['AddressParameters']['DestinationAddress']['Index'])+' '+str(item['OperationParameters']['OperAttr']['Name']) | |
info=info+'\n ' | |
except: | |
pass | |
#print(info) | |
return { | |
'statusCode': 200, | |
'body': json.dumps(info) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment