No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.travis.yml
LICENSE
README.md
client_test.go
message.go
operator_lookup_response.go
send_sms_response.go
zensend.go
zensend_error.go

README.md

Build Status

ZenSend API for Go

Installation

go get github.com/zensend/zensend
go install github.com/zensend/zensend

Examples

First, make sure you import the zensend package

import zensend

Then, create an instance of zensend.Client

client := zensend.New("YOUR API KEY")

Sending SMS

message := &zensend.Message{
    Body: "The SMS Body",
    Originator: "FROM YOU",
    Numbers: []string{"447777777777", "448888888888"},
}

response, error := client.SendSMS(message)

if error == nil {
  log.Println("GUID:", response.TxGuid, "NUMBERS:", response.Numbers, "SMS Parts:", response.SmsParts, "Encoding:", response.Encoding)
} else {
  switch error := error.(type) {
  case zensend.ZenSendError:
    log.Println("Status Code:", error.StatusCode, "Failcode:", error.FailCode, "Parameter:", error.Parameter)
  default:
    log.Println(error)
  }
}

Checking your balance

balance, error = client.CheckBalance()

if error == nil {
  log.Println("Balance:", balance)
} else {
  switch error := error.(type) {
  case zensend.ZenSendError:
    log.Println("Status Code:", error.StatusCode, "Failcode:", error.FailCode, "Parameter:", error.Parameter)
  default:
    log.Println(error)
  }
}

Retrieving pricing information

prices, error = client.GetPrices()

if error == nil {
  for country := range prices {
    fmt.Printf("Country: %s. Price: %v\n", country, prices[country])
  }
} else {
  switch error := error.(type) {
  case zensend.ZenSendError:
    log.Println("Status Code:", error.StatusCode, "Failcode:", error.FailCode, "Parameter:", error.Parameter)
  default:
    log.Println(error)
  }
}

Operator Lookup

response, error := client.LookupOperator("441234567890")
if error == nil {
  fmt.Printf("MCC: %s MNC: %s Operator: %s CostInPence: %f NewBalanceInPence: %f", response.MCC, response.MNC, response.Operator, response.CostInPence, response.NewBalanceInPence)
} 
  
### Testing using the REPL

    gore
    :import zensend