keysms

package module
v0.0.0-...-b9087ca Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2018 License: LGPL-3.0 Imports: 7 Imported by: 0

README

Import

import "github.com/andern/keysms"

Send SMS

Sending an SMS to one or multiple recipients is very simple:

keysms.Auth("username", "apiKey")
keysms.SendSMS("text message here", "98765432", "12345678")

To change sender or to send an SMS in the future you should use SMSParam:

msg := keysms.SMSParams{
    Message:   "text message here",
    Receivers: []string{"98765432", "12345678"},
    Sender:    "99999999",
    Time:      time.Now().Add(2 * time.Hour),
}
keysms.Send(msg)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Auth

func Auth(user, key string)

Types

type Message

type Message struct {
	ID        string     `json:"_id"`
	Sent      bool       `json:"sent"`
	Updated   string     `json:"updated"`
	Receivers []Receiver `json:"receivers"`
	Parts     Parts      `json:"parts"`
	Created   string     `json:"created"`
	Message   string     `json:"message"`
	Sender    string     `json:"sender"`
	Tags      bool       `json:"tags"`
	Groups    []string   `json:"groups"`
	Future    bool       `json:"future"`
	Status    Status     `json:"status"`
}

type Parts

type Parts struct {
	Total int32    `json:"total"`
	Parts []string `json:"parts"`
}

type Receiver

type Receiver struct {
	Number         string `json:"number"`
	Prefix         string `json:"prefix"`
	Country        string `json:"country"`
	DeliveryStatus int32  `json:"deliverystatus"`
	NextGWSyncTime string `json:"nextgwsynctime"`
}

type SMSParams

type SMSParams struct {
	// Text content of the SMS to send
	Message string

	// The recipients of the SMS
	Recipients []string

	// The number the SMS appears to be sent from
	Sender string

	// Time when the SMS should be sent
	Time time.Time
}

type SMSResponse

type SMSResponse struct {
	OK       bool    `json:"ok"`
	Message  Message `json:"message"`
	Quantity int32   `json:"quantity"`
	Cost     float64 `json:"cost"`
	SMSPrice float64 `json:"smsPrice"`
}

func Send

func Send(params SMSParams) (SMSResponse, error)

func SendSMS

func SendSMS(message string, recipients ...string) (SMSResponse, error)

type Status

type Status struct {
	Value     string   `json:"value"`
	Text      string   `json:"text"`
	Aggregate []string `json:"aggregate"`
	Timed     int32    `json:"timed"`
}

Jump to

Keyboard shortcuts

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