### Setup Organization and Partner Source: https://github.com/abhishek-ram/pyas2-lib/blob/master/README.md Initialize an Organization and Partner object with their respective AS2 IDs, keys, certificates, and encryption/signing preferences. Ensure keys and certificates are in PEM/DER format. The MDN mode and digest algorithm can also be configured. ```python from pyas2lib.as2 import Organization, Partner my_org = Organization( as2_name='my_unique_id', # Unique AS2 Id for this organization sign_key=b'signature_key_bytes', # PEM/DER encoded private key for signature sign_key_pass='password', # Password private key for signature decrypt_key=b'decrypt_key_bytes', # PEM/DER encoded private key for decryption decrypt_key_pass='password' # Password private key for decryption ) a_partner = Partner( as2_name='partner_unique_id', # Unique AS2 Id of your partner sign=True, # Set to true for signing the message verify_cert=b'verify_cert_bytes', # PEM/DER encoded certificate for verifying partner signatures encrypt=True, # Set to true for encrypting the message encrypt_cert=b'encrypt_cert_bytes', # PEM/DER encoded certificate for encrypting messages mdn_mode='SYNC', # Expect to receive synchronous MDNs from this partner mdn_digest_alg='sha256' # Expect signed MDNs to be returned by this partner ) ``` -------------------------------- ### Commit changes Source: https://github.com/abhishek-ram/pyas2-lib/blob/master/README.md Stage and commit your changes with a descriptive message. ```bash git commit -am 'Add some feature' ``` -------------------------------- ### Create a new feature branch Source: https://github.com/abhishek-ram/pyas2-lib/blob/master/README.md Use this command to create a new branch for your feature development. ```bash git checkout -b my-new-feature ``` -------------------------------- ### Parse Incoming Async MDN Source: https://github.com/abhishek-ram/pyas2-lib/blob/master/README.md When an HTTP request is received, initialize an Mdn object and use its parse method to check if it's an asynchronous MDN. This requires the request body and a function `find_message_fumc` to find the associated message. It returns the status and detailed status of the original message. ```python from pyas2lib.as2 import Mdn msg_mdn = Mdn() # Initialize an Mdn object # Call the parse method with the HTTP request headers + content and a function the returns the related `pyas2lib.as2.Messsage` object. status, detailed_status = msg_mdn.parse(request_body, find_message_fumc) ``` -------------------------------- ### Build AS2 Message Source: https://github.com/abhishek-ram/pyas2-lib/blob/master/README.md Create an AS2 Message object using the sender and receiver configurations. The build method processes the payload and populates `msg.content` and `msg.header` for transmission. ```python from pyas2lib.as2 import Message msg = Message(sender=my_org, receiver=a_partner) msg.build(b'data_to_transmit') ``` -------------------------------- ### Push changes to a new branch Source: https://github.com/abhishek-ram/pyas2-lib/blob/master/README.md Push your committed changes to the remote repository on your new branch. ```bash git push origin my-new-feature ``` -------------------------------- ### Parse Synchronous MDN Response Source: https://github.com/abhishek-ram/pyas2-lib/blob/master/README.md Initialize an Mdn object and use its parse method to process the HTTP response data. This requires a function `find_message_func` that can locate the corresponding `pyas2lib.as2.Message` object. It returns the status and detailed status of the message transmission. ```python from pyas2lib.as2 import Mdn msg_mdn = Mdn() # Initialize an Mdn object # Call the parse method with the HTTP response headers + content and a function that returns the related `pyas2lib.as2.Messsage` object. status, detailed_status = msg_mdn.parse(b'response_data_with_headers', find_message_func) ``` -------------------------------- ### Parse Incoming AS2 Message Source: https://github.com/abhishek-ram/pyas2-lib/blob/master/README.md If an incoming request is not an MDN, catch the `MDNNotFound` exception and parse it as an AS2 message. This involves providing the request body and functions to find the organization, partner, and check for duplicate messages. The function returns parsing status, any exceptions, and an Mdn object. ```python from pyas2lib.as2 import Message msg = Message() # Call the parse method with the HTTP request headers + content, a function to return the the related `pyas2lib.as2.Organization` object, a function to return the `pyas2lib.as2.Partner` object and a function to check for duplicates. status, exception, mdn = msg.parse( request_body, find_organization, find_partner, check_duplicate_msg) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.