Skip to main content

Postal Methods API SDK for Python

Project description

This is the python package for Postal Methods API

It consists of six functions The class name is PMAPI. the functions are listed below.

SendLetter(myDescription="", perforation=False, replyOnEnvelope=False, returnAddress=None, File=None, fileUrl='', isDoubleSided=False, isColored=False, urlFileExtension='', refId='', returnAddressPosition=1, isReturnAddressAppended=False )

SendLetterWithAddress(myDescription="", perforation=False, replyOnEnvelope=False, returnAddress=None, sendToAddress=None, File=None, fileUrl='', templateId=0, isDoubleSided=False, isColored=False, urlFileExtension='', refId='', returnAddressPosition=1, isReturnAddressAppended=False )

Takes the Letter Id:

GetPDF(self, RequestId)

Takes a List of Letter Ids:

GetLetterStatus(self, RequestIds)

Takes the Letter Id:

GetLetterDetails(self, RequestId)

Takes the Letter Id:

CancelDelivery(self, RequestId)

Response: The response object contains three properties

  1. status
  2. errorMessage
  3. result

The status gives you the status code of the request.

The errorMessage will give the error message if the status is not 200

the result will contain the response result.

You can find the result type of each API by looking at the example response result field in the documentation here:

https://documenter.getpostman.com/view/10877655/TVKD3dba

Implementation: Initialize the PMAPI Class with your API key. Call functions with their respective params.

Example is given below:

Imports:

from pmpackage import PMAPI

from pmpackage import Address

Initialization:

testReq = PMAPI('api-key')

Status:

Ids = [1,2,3]

response = testReq.GetLetterStatus(Ids)

Detail:

Id = 1

response = testReq.GetLetterDetails(Id)

Cancel:

Id = 1

response = testReq.CancelDelivery(Id)

PDF:

Ids = 1

response = testReq.GetPDF(Id)

SendLetter:

filePath = 'ValidDoc.pdf'
with open(filePath, "rb") as uploadedFile:

    # First We Initialize the Address Object
    returnAddress = Address('Company', 'AddressLine1', 'AddressLine2',
                             'City', 'State', 'Zip', 'Country')

    response = testReq.SendLetter('Hello', 
    True, 
    True, 
    returnAddress, 
    uploadedFile, 
    '', True, 
    True, '', 
    'hello123', 
    2, 
    True)

Send Letter With Address:

filePath = 'ValidDoc.pdf'
with open(filePath, "rb") as uploadedFile:

    # First We Initialize the Address Object
     returnAddress = Address('Company', 'AddressLine1', 'AddressLine2',
                            'City', 'State', 'Zip', 'Country')
    SendAddress = Address('', '1300 Montgomery Highway', '',
                            'Vestavia Hills', 'AL', '35612', None)
    hello = checkReq.SendLetterWithAddress('Hello',
                                           True,
                                           True,
                                       returnAddress,
                                       SendAddress,
                                       uploadedFile,
                                       '',
                                       0,
                                       True,
                                       True,
                                       '',
                                       'hello123',
                                       2,
                                       False
                                       )

Project details


Release history Release notifications | RSS feed

This version

2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Postal Methods 2.0 API-2.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Postal_Methods_2.0_API-2.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file Postal Methods 2.0 API-2.0.tar.gz.

File metadata

  • Download URL: Postal Methods 2.0 API-2.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for Postal Methods 2.0 API-2.0.tar.gz
Algorithm Hash digest
SHA256 694e18cae421a9449b7a9f676eb7bbe6f45bc9b90bfdb7fb9ddf4574efde9d1a
MD5 293594df7154725395cd9d49166d5678
BLAKE2b-256 13d159e6a557e287ed8f6a92afd5e429ee425f46ae558e203d75b3c73222670d

See more details on using hashes here.

File details

Details for the file Postal_Methods_2.0_API-2.0-py3-none-any.whl.

File metadata

  • Download URL: Postal_Methods_2.0_API-2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for Postal_Methods_2.0_API-2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d7785eb8d1005f1bc3c5753defdab086ff6297430dfd3ae9aecb9ef0f1f4d173
MD5 6737581210db8f62b53dc70d6902e36d
BLAKE2b-256 96944464c906fce7071b38838eebc49f965592f2212e6a2d844e236b6c68bf59

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page