Skip to content

clients.sms #

SMS Client

Usage

  1. Create a twilio account and get your credentials. here
  2. Export your credentials in the shell
export TWILIO_ACCOUNT_SID=xxxxxxxxx
export TWILIO_AUTH_TOKEN=xxxxxxxxx
export TWILIO_NUMBER=xxxxxxxxx
  1. Edit and run the example to use the sms client.

fn new_sms_client #

fn new_sms_client(cred Credentials, mut logger log.Log) !Client

enum StatusTypes #

enum StatusTypes {
	error
	success
}

struct Client #

struct Client {
pub:
	api_url string = 'https://api.twilio.com/2010-04-01/Accounts'
	token   string
	sid     string
	source  string
pub mut:
	logger log.Log
}

fn (Client) get_auth_headers #

fn (mut c Client) get_auth_headers() !http.Header

fn (Client) get_data_form #

fn (mut c Client) get_data_form(msg Message) !map[string]string

fn (Client) send #

fn (mut c Client) send(msg Message) !Result

struct Credentials #

@[params]
struct Credentials {
pub:
	sid    string
	token  string
	source string
}

struct Message #

@[params]
struct Message {
pub:
	content     string
	destination string
}

struct Result #

struct Result {
pub:
	level     StatusTypes
	content   string
	more_info string
}