Skip to content
Ben Dauphinee edited this page Aug 8, 2014 · 1 revision

USPSTools\EPF

This class is for managing USPS Electronic Product Fulfillment (EPF) interactions.

  • Class name: EPF
  • Namespace: USPSTools

Constants

EPF_BASE_URL

const EPF_BASE_URL = 'https://epfws.usps.gov/ws/resources'

Properties

$debugMode

protected mixed $debugMode

Set if we are in debug mode or not.

  • Visibility: protected

$fileSaveLocation

protected mixed $fileSaveLocation = ''

The file location to save downloads to.

  • Visibility: protected

$loginUser

protected mixed $loginUser

The user ID assigned to use for login.

  • Visibility: protected

$loginPass

protected mixed $loginPass

The password assigned to use for login.

  • Visibility: protected

$logonKey

protected mixed $logonKey

Session key for this login instance.

  • Visibility: protected

$requestSuccess

protected mixed $requestSuccess = null

Tracks if the latest request was successful or not.

  • Visibility: protected

$tokenKey

protected mixed $tokenKey

Rotating security token, changed with every request. To be used along with loginKey.

  • Visibility: protected

$subscribedProducts

protected mixed $subscribedProducts

A list of product codes and IDs that we are subscribed to, to be used with queries to API.

  • Visibility: protected

Methods

\USPSTools\EPF::__construct()

mixed USPSTools\EPF::\USPSTools\EPF::__construct()(string $loginUser, string $loginPass, boolean $debugMode)

Handles the setup of this class

  • Visibility: public

Arguments

  • $loginUser string - The user to log into the service with.
  • $loginPass string - The password to log into the service with.
  • $debugMode boolean - If we want to echo out debugging information.

\USPSTools\EPF::downloadFile()

array USPSTools\EPF::\USPSTools\EPF::downloadFile()(string $fileId, string $filePath)

Download the actual file you are looking to fetch from the Akamai edge servers.

  • Visibility: public

Arguments

  • $fileId string - The file ID to download. This is returned as part of a listFiles call.
  • $filePath string - The file to download. This is returned as part of a listFiles call.

\USPSTools\EPF::downloadEpf()

array USPSTools\EPF::\USPSTools\EPF::downloadEpf()(string $fileId, string $filePath)

Download smaller files from the responding webserver.

  • Visibility: public

Arguments

  • $fileId string - The file ID to download. This is returned as part of a listFiles call.
  • $filePath string - The file to download. This is returned as part of a listFiles call.

\USPSTools\EPF::downloadNewestFile()

array USPSTools\EPF::\USPSTools\EPF::downloadNewestFile()(string $productCode, string $productId, string $status, string $fulfilled)

Download the newest file available of this product.

  • Visibility: public

Arguments

  • $productCode string - The product code to list files for.
  • $productId string - The product ID under the product code to list files for.
  • $status string - [Optional] Apply a filter on the file status.
  • $fulfilled string - [Optional] Apply a filter on the file fulfillment status.

\USPSTools\EPF::findNewestFile()

array USPSTools\EPF::\USPSTools\EPF::findNewestFile()(string $productCode, string $productId, string $status, string $fulfilled)

Find the newest file available for this product code/id combination. If set, some filtering can be applied to this list.

  • Visibility: public

Arguments

  • $productCode string - The product code to list files for.
  • $productId string - The product ID under the product code to list files for.
  • $status string - [Optional] Apply a filter on the file status.
  • $fulfilled string - [Optional] Apply a filter on the file fulfillment status.

\USPSTools\EPF::listFiles()

array USPSTools\EPF::\USPSTools\EPF::listFiles()(string $productCode, string $productId, string $status, string $fulfilled)

You can get a list of available files for a particular EPF product code/id combination. If set, some filtering can be applied to this list.

  • Visibility: public

Arguments

  • $productCode string - The product code to list files for.
  • $productId string - The product ID under the product code to list files for.
  • $status string - [Optional] Apply a filter on the file status.
  • $fulfilled string - [Optional] Apply a filter on the file fulfillment status.

\USPSTools\EPF::login()

array USPSTools\EPF::\USPSTools\EPF::login()()

Use this function to log in to the EPF system.

  • Visibility: public

\USPSTools\EPF::logout()

array USPSTools\EPF::\USPSTools\EPF::logout()()

Use this function to log out of the EPF system. This is not required, but considered good practice.

  • Visibility: public

\USPSTools\EPF::parseHeaders()

mixed USPSTools\EPF::\USPSTools\EPF::parseHeaders()(string $headerString)

Parse cURL response headers into a usable array.

  • Visibility: protected

Arguments

  • $headerString string - A string containing the headers to parse.

\USPSTools\EPF::pullResource()

array USPSTools\EPF::\USPSTools\EPF::pullResource()(string $url, string $mode, array $jsonData)

This function will execute a request to the EPF server.

  • Visibility: protected

Arguments

  • $url string - The EPF sub-url that we want to hit.
  • $mode string - The mode we want to use in our request. By default, we're going to POST.
  • $jsonData array - Extra parameters for the EPF request.

\USPSTools\EPF::setDownloadLocation()

mixed USPSTools\EPF::\USPSTools\EPF::setDownloadLocation()(string $fileSaveLocation)

Set the download location to use when storing downloads.

  • Visibility: public

Arguments

  • $fileSaveLocation string - The location to save our downloaded files to.

\USPSTools\EPF::setStatus()

array USPSTools\EPF::\USPSTools\EPF::setStatus()(string $fileId, string $status)

Set the status on a particular file. This should be set after a download is successfully completed.

  • Visibility: public

Arguments

  • $fileId string - The file ID to download. This is returned as part of a listFiles call.
  • $status string - The status to set the file to.

\USPSTools\EPF::version()

array USPSTools\EPF::\USPSTools\EPF::version()()

This function allows you to check connectivity and get the version of the web service.

  • Visibility: public