phone

package
v0.0.0-...-21f0d4d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2016 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package phone abstracts away sending various message types to a phone.

Index

Constants

This section is empty.

Variables

View Source
var ErrFileDoesNotExist = errors.New("The given file path does not exist.")

ErrFileDoesNotExist is returned when the given input file cannot be found

View Source
var ErrFileIsDirectory = errors.New("The given file path is a directory")

ErrFileIsDirectory is returned when the given filepath is a directory

View Source
var ErrFiletypeNotSupported = errors.New("The given filetype is not supported")

ErrFiletypeNotSupported is returned when the given input file is a valid file, but its extension is not supported by the sender service.

Examples of invalid types include ".exe", ".docx", and ".pptx"

Functions

This section is empty.

Types

type Sender

type Sender struct {
	// contains filtered or unexported fields
}

Sender holds the necessary values for sending supported data to a phone.

Must be initalized with the NewSender func.

func NewSender

func NewSender(
	config TwilioConfig,
	acceptedNGROKTOS bool,
	port int,
	verbose bool,
) *Sender

NewSender creates a new sender object with the specified options. Utilizes the ngrokker pkg, and in turn, ngrok, for its introspective tunneling purposes, and Twilio for its MMS sending purposes. If you'd like to override the tunneling service with something else, use NewSenderTunnel.

A valid Twilio Configuration is needed to be able to properly send a message.

Users must accept the ngrok ToS before sending anything.

Port will be used to create a local webserver and introspective tunnel, if necessary. The port must not be currently in use by another process.

Verbose prints diagnostic information to stderr.

func NewSenderTunnel

func NewSenderTunnel(
	tunnel ngrokker.Tunneler,
	config TwilioConfig,
	port int,
	verbose bool,
) *Sender

NewSenderTunnel is similar to NewSender, except that it allows you to override the introspective tunneling service with your own.

func (Sender) SendFile

func (s Sender) SendFile(phoneNumber, filePath string) error

SendFile sends a file to the specified phone number.

Currently, it only supports photos, but support for additional files is planned.

type TwilioConfig

type TwilioConfig struct {
	SID       string
	AuthToken string
	SenderNum string
}

TwilioConfig represents all necessary information needed to send a message via twilio. For more information, see http://twilio.com

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL