Skip to content

Instantly share code, notes, and snippets.

@BedrosovaYulia
Last active July 29, 2019 06:33
Show Gist options
  • Save BedrosovaYulia/695576928ea89d5f4115a97049bafe94 to your computer and use it in GitHub Desktop.
Save BedrosovaYulia/695576928ea89d5f4115a97049bafe94 to your computer and use it in GitHub Desktop.
AWS Lambda Function for the Russian Post tracking via SOAP client
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