This repository has been archived by the owner on Mar 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
QueueFax
Michael Fridman edited this page Mar 19, 2018
·
6 revisions
See the official Queue_fax docs for more info.
The QueueFax
method takes 2 mandatory arguments, a []File
and QueueCfg
. You can pass nil
as an argument to []File
, but it must be accompanied by QueueOptions
with a valid CoverPage
, see example further down for cover page only example.
// all QueueCfg fields are mandatory
cfg := srfax.QueueCfg{
CallerID: 6476892276, // sender's fax number, must be 10 digits
SenderEmail: "mf192@icloud.com", // sender's email address
FaxType: "SINGLE", // SINGLE|BROADCAST
ToFaxNumber: []string{"16476892276"}, // receiver's fax number(s), must be 11 digits
}
filename := "sample.pdf" // must contain an extension
by, err := ioutil.ReadFile(filename)
if err != nil {
log.Fatalln(err)
}
// encode the contents of the file as base64
encoded := base64.StdEncoding.EncodeToString(by)
// here we are sending a single file, but it is still wrapped inside a slice of File
files := []srfax.File{
{Name: filename, Content: encoded},
}
resp, err := client.QueueFax(files, cfg)
if err != nil {
log.Fatalln(err)
}
srfax.PP(resp) // pretty print response to terminal
Output:
{
"Status": "Success",
"Result": "389091764"
}
// all QueueCfg fields are mandatory
cfg := srfax.QueueCfg{
CallerID: 6476892276, // sender's fax number, must be 10 digits
SenderEmail: "mf192@icloud.com", // sender's email address
FaxType: "SINGLE", // SINGLE|BROADCAST
ToFaxNumber: []string{"16476892276"}, // receiver's fax number, must be 11 digits
}
opts := srfax.QueueOptions{
CoverPage: "Standard",
}
resp, err := client.QueueFax(nil, cfg, opts)
if err != nil {
log.Fatalln(err)
}
srfax.PP(resp) // pretty print response to terminal
Output:
The Result field, if successful, will contain a FaxDetailsID
, i.e., a unique fax job ID.
{
"Status": "Success",
"Result": "383721600"
}