PostalMethods extends DeliveryMethod
PostalMethods service for physically mailing letters
Table of Contents
Properties
| $api_key | |
| $available_file_types | |
| $colored | |
| $description | |
| $double_sided | |
| $file | |
| $include_reply_envelope | |
| $perforate_document | |
| $return_address | |
| $to_address | |
| $url |
Methods
| __construct() | Constructs a new PostalMethods component |
| errors() | Returns all errors set in this object |
| getFileTypes() | Retrieves a list of available file types accepted by Postal Methods |
| resetAll() | Resets all settings back to default except for the account username and password |
| send() | Sends the document to Postal Methods for mailing |
| setApiKey() | Sets the Postal Methods API Key required for making requests |
| setColored() | Sets whether to print in color |
| setDescription() | Sets a description to associate with this letter in the PostalMethods account |
| setDoubleSided() | Sets whether to print on both sides of a page |
| setFile() | Sets the file and file type of the file to be mailed |
| setPerforated() | Sets whether the bottom-third of the letter sent to PostalMethods should be perforated |
| setReplyEnvelope() | Sets a reply envelope to be included in the mail |
| setReturnAddress() | Sets the return address |
| setToAddress() | Sets the outside address |
| getSendParameters() | Gathers all the parameters necessary to send the letter |
| parseResponse() | Parses the API response from PostalMethods, sets any errors that may have been generated |
Properties
$api_key
private
string
$api_key
The account API key
$available_file_types
private
array<string|int, mixed>
$available_file_types
= ['DOC', 'DOCX', 'PDF', 'HTML']
An array of available file types accepted by Postal Methods NOTE: These file types are acceptable when the address is inside of the document
$colored
private
string
$colored
= 'false'
'true' to print in color, 'false' for black-and-white
$description
private
string
$description
An optional description to associate with this letter
$double_sided
private
string
$double_sided
= 'false'
'true' to print on both sides of a page, 'false' otherwise
$file
private
array<string|int, mixed>
$file
= []
An array of a file's bitstream data and file type
$include_reply_envelope
private
string
$include_reply_envelope
= 'false'
'true' to include a reply envelope, 'false' otherwise
$perforate_document
private
string
$perforate_document
= 'false'
'true' if bottom-third of the letter should be perforated, 'false' otherwise
$return_address
private
array<string|int, mixed>
$return_address
A list of return address fields to send to
$to_address
private
array<string|int, mixed>
$to_address
A list of address fields to send to
$url
private
static string
$url
= 'https://api.secure.postalmethods.com/v1'
The URL to submit requests to
Methods
__construct()
Constructs a new PostalMethods component
public
__construct() : mixed
errors()
Returns all errors set in this object
public
errors() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of error info
getFileTypes()
Retrieves a list of available file types accepted by Postal Methods
public
getFileTypes() : array<string|int, mixed>
Return values
array<string|int, mixed> —A numerically-indexed array of available file types
resetAll()
Resets all settings back to default except for the account username and password
public
resetAll() : mixed
send()
Sends the document to Postal Methods for mailing
public
send() : mixed
setApiKey()
Sets the Postal Methods API Key required for making requests
public
setApiKey(string $api_key) : mixed
Parameters
- $api_key : string
-
The Postal Methods API key
setColored()
Sets whether to print in color
public
setColored(bool $colored) : mixed
Parameters
- $colored : bool
-
True to print in color, false to print in black-and-white
setDescription()
Sets a description to associate with this letter in the PostalMethods account
public
setDescription(string $description) : mixed
Parameters
- $description : string
-
A description to associate with this letter. Limit 100 characters
setDoubleSided()
Sets whether to print on both sides of a page
public
setDoubleSided(bool $double_sided) : mixed
Parameters
- $double_sided : bool
-
True to print on both sides of a page, false to print on one
setFile()
Sets the file and file type of the file to be mailed
public
setFile(array<string|int, mixed> $file) : mixed
Parameters
- $file : array<string|int, mixed>
-
A key=>value array of the file and it's extension:
- file The bitstream of the file to send in binary
- type The type of file this is (i.e. HTML, DOC, DOCX, or PDF), (optional, default PDF)
setPerforated()
Sets whether the bottom-third of the letter sent to PostalMethods should be perforated
public
setPerforated(bool $perforated) : mixed
Parameters
- $perforated : bool
-
True to have the bottom-third of the letter perforated, false to not perforate the letter
Tags
setReplyEnvelope()
Sets a reply envelope to be included in the mail
public
setReplyEnvelope(bool $include_reply_envelope) : mixed
Parameters
- $include_reply_envelope : bool
-
True to include a reply envelope in the mail, false to not include a reply envelope
Tags
setReturnAddress()
Sets the return address
public
setReturnAddress(array<string|int, mixed> $address) : mixed
Parameters
- $address : array<string|int, mixed>
-
A list of attributes attributes including:
- name The name of the recipient
- company The company name
- address1 Address1
- address2 Address2
- city The city
- state The ISO 3166-2 subdivision code
- zip The postal code
- country The ISO 3166-1 alpha3 country code
setToAddress()
Sets the outside address
public
setToAddress(array<string|int, mixed> $address) : mixed
Parameters
- $address : array<string|int, mixed>
-
A list of attributes attributes including:
- name The name of the recipient
- company The company name
- address1 Address1
- address2 Address2
- city The city
- state The ISO 3166-2 subdivision code
- zip The postal code
- country_code The ISO 3166-1 alpha3 country code
getSendParameters()
Gathers all the parameters necessary to send the letter
private
getSendParameters() : mixed
parseResponse()
Parses the API response from PostalMethods, sets any errors that may have been generated
private
parseResponse(string $response) : bool
Parameters
- $response : string
-
The API response from PostalMethods
Return values
bool —true on success, false on error