gowiraya

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

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

Go to latest
Published: Nov 7, 2019 License: MIT Imports: 7 Imported by: 0

README

GoWiraya

Go library for sending SMS with Wiraya.

Note that the ip needs to be whitelisted at Wiraya.

Usage

client, err := gowiraya.NewWirayaClient("xapikey")
if err != nil {
    fmt.Println(err)
    return
}

data := gowiraya.SendMessage{
    Recipient: "4612345678",
    Sender:    "Test",
    Message:   "This is the message",
}

resp, err := client.SendMessageFromAlpha(data)
if err != nil {
    fmt.Println(err)
    return
}

data2 := gowiraya.MessageStatus{
    MessageId: resp.Result,
}

resp2, err := client.GetMessageStatus(data2)
if err != nil {
    fmt.Println(err)
    return
}

fmt.Println("Status for message: " + resp2.Result)

Documentation

Index

Constants

View Source
const (
	ErrorSender          = "ERROR_SENDER"
	ErrorContent         = "ERROR_CONTENT"
	ErrorDateTime        = "ERROR_DATETIME"
	ErrorAuthentication  = "ERROR_AUTHENTICATION"
	ErrorProjectNotFound = "ERROR_PROJECT_NOT_FOUND"

	StatusInqueue      = "INQUEUE"
	StatusSent         = "SENT"
	StatusDelivered    = "DELIVERED"
	StatusNotDelivered = "NOT DELIVERED"
	StatusTooLate      = "TOOLATE"
	StatusFailure      = "FAILURE"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionResponseWithId

type ActionResponseWithId struct {
	Error    bool                   `json:"error,omitempty"`
	Failures map[string]interface{} `json:"failures,omitempty"`
}

type AuthRequestKey

type AuthRequestKey struct {
	Key string `json:"key,omitempty"` // Static Wiraya API key
}

type CampaignRequestModel

type CampaignRequestModel struct {
	Campaign  string `json:"campaign"`            // Campaign identifier (provided by Wiraya)
	Iteration string `json:"iteration,omitempty"` // Iteration value. Only used with recurring communication to same contacts
}

type ContactRequstModel

type ContactRequstModel struct {
	Personal map[string]string `json:"personal"` // Data points with personally identifiable information
	General  map[string]string `json:"general"`  // Data points without PII
}

type EventRequestModel

type EventRequestModel struct {
	Name string `json:"name"`         // Event name (provided by Wiraya)
	At   string `json:"at,omitempty"` // Time of event. ISO format, in UTZ (Z)
}

type IdResponse

type IdResponse struct {
	Id string `json:"id"` // Correlation id for ingested entity
}

type MessageStatus

type MessageStatus struct {
	MessageId string `json:"MessageId"`
}

type Response

type Response struct {
	Result string `json:"Result"`
}

type SendMessage

type SendMessage struct {
	Recipient string `json:"recipient"` // Number to send pin to
	Sender    string `json:"sender"`    // Sender name for SMS
	Message   string `json:"message"`   // Message
}

type SendPinCode

type SendPinCode struct {
	Recipient string `json:"recipient"` // Number to send pin to
	Sender    string `json:"sender"`    // Sender name for SMS
	Message   string `json:"message"`   // Message, add {code} to specify where the pin should be
	IPAddress string `json:"ipaddress"` // IPAddress of user to avoid spam
}

type TokenResponse

type TokenResponse struct {
	Authenticated bool   `json:"authentication"`
	Token         string `json:"token"`
	TokenExpires  string `json:"tokenExpires"`
}

type VerifyPinCode

type VerifyPinCode struct {
	Recipient string `json:"recipient"` // Number to send pin to
	IPAddress string `json:"ipaddress"` // IPAddress of user to avoid spam
	PinCode   string `json:"pincode"`   // Pin code that will be verified if active or not
}

type WirayaClient

type WirayaClient struct {
	HttpClientProxy *http.Client
	HttpClient      *http.Client
	// contains filtered or unexported fields
}

func NewWirayaClient

func NewWirayaClient(xApiKey string, proxy *string) (client *WirayaClient, err error)

func (*WirayaClient) AddContact

func (c *WirayaClient) AddContact(contactID int64, data ContactRequstModel) (response ActionResponseWithId, err error)

func (*WirayaClient) AddContactToCampaign

func (c *WirayaClient) AddContactToCampaign(contactID int64, data CampaignRequestModel) (response IdResponse, err error)

func (*WirayaClient) AddEventToContact

func (c *WirayaClient) AddEventToContact(contactID int64, data EventRequestModel) (response IdResponse, err error)

func (*WirayaClient) GetMessageStatus

func (c *WirayaClient) GetMessageStatus(data MessageStatus) (response Response, err error)

func (*WirayaClient) SendMessageFromAlpha

func (c *WirayaClient) SendMessageFromAlpha(data SendMessage) (response Response, err error)

func (*WirayaClient) SendPinCode

func (c *WirayaClient) SendPinCode(data SendPinCode) (response Response, err error)

func (*WirayaClient) VerifyCode

func (c *WirayaClient) VerifyCode(data VerifyPinCode) (response Response, err error)

Jump to

Keyboard shortcuts

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