nexmo

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2016 License: MIT Imports: 12 Imported by: 0

README

####Nexmo client written in Go.

Not tested with credentials.

License MIT Build Status Go Report Card GoDoc Coverage Status

#####Install:

go get gopkg.in/jimmy-go/nexmo.v0

#####Usage: Call nexmo.New method to get a new Nexmo client. For every Nexmo feature there is a package with that name that contains his Request and Response type.

E.g.: For method SMS you need a nexmo.sms.Request{} that returns nexmo.sms.Response{}

# declare a new client
client, err := nexmo.New("APIKEY", "APISECRET")
// check errors...

# use it
msg := nexmo.NewSMS("5215522334455", "NexmoTest", "Hello world!")
resp, err := client.SMS(msg)
// resp = nexmo.sms.Response

req := nexmo.NewCall("5215522334455", "http://someurl/answer.xml")
resp, err := client.Call(req)
// resp = nexmo.call.Response

t2s := nexmo.NewText2Speech("5215522334455", "NexmoTest", "Hello my world!", "en-us", "female")
resp, err := client.Text2Speech(t2s)
// resp = nexmo.text2speech.Response

#####Credits:

#####License:

MIT License

Copyright (c) 2016 Angel Del Castillo

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Overview

Package nexmo contains Nexmo client using oficial documentation.

see: https://docs.nexmo.com

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

View Source
const (
	// EndpointSMS Nexmo API endpoint.
	EndpointSMS = "https://rest.nexmo.com/sms/json?"

	// EndpointCall Nexmo API endpoint.
	EndpointCall = "https://rest.nexmo.com/call/json?"

	// EndpointText2Speech Nexmo API endpoint.
	EndpointText2Speech = "https://api.nexmo.com/tts/json?"
)

Variables

View Source
var (
	// ErrInvalidKey returned when API KEY is empty.
	ErrInvalidKey = errors.New("nexmo: invalid key length")

	// ErrInvalidSecret returned when API SECRET is empty.
	ErrInvalidSecret = errors.New("nexmo: invalid key length")

	// ErrEmptyResponse returned if response has no messages.
	ErrEmptyResponse = errors.New("nexmo: response is empty")

	// ErrBadRequest is return when http response status
	// is not 200.
	ErrBadRequest = errors.New("nexmo: bad request")

	// ErrSupportNotFound returned when this package has no
	// implementation for some feature. See supportmap map.
	ErrSupportNotFound = errors.New("nexmo: feature not supported")
)

Functions

func NewCall added in v0.0.2

func NewCall(to, answerURL string) *call.Request

NewCall returns a new call request with only required fields. see: https://docs.nexmo.com/voice/call/request

func NewSMS added in v0.0.2

func NewSMS(to, from, text string) *sms.Request

NewSMS returns a new SMS request only with required fields. see: https://docs.nexmo.com/messaging/sms-api/api-reference#request

func NewText2Speech added in v0.0.2

func NewText2Speech(to, from, text, lang, voice string) *text2speech.Request

NewText2Speech returns a new text2speech request with only required fields.

see: https://docs.nexmo.com/voice/text-to-speech/request

Types

type Nexmo

type Nexmo struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Nexmo client

func Must

func Must(key, secret string, timeout time.Duration) *Nexmo

Must calls New func or panic.

func New

func New(key, secret string, timeout time.Duration) (*Nexmo, error)

New returns a new Nexmo client with timeout.

func (*Nexmo) Call

func (x *Nexmo) Call(r *call.Request) (*call.Response, error)

Call You use Call API to make outbound calls from Nexmo virtual numbers to other phone numbers.

func (*Nexmo) SMS

func (x *Nexmo) SMS(r *sms.Request) (*sms.Response, error)

SMS use SMS API to send and receive a high volume of SMS anywhere in the world.

see: https://docs.nexmo.com/messaging/sms-api

func (*Nexmo) Text2Speech added in v0.0.2

func (x *Nexmo) Text2Speech(r *text2speech.Request) (*text2speech.Response, error)

Text2Speech You use Text-To-Speech API to send synthesized speech or recorded sound files to a phone number

type Support added in v0.0.2

type Support struct {
	DocURL string
	Method string
	URL    string
}

Support struct

Directories

Path Synopsis
examples
call
Package main contains Nexmo CALL example usage.
Package main contains Nexmo CALL example usage.
sms
Package main contains Nexmo SMS example usage.
Package main contains Nexmo SMS example usage.
text2speech
Package main contains Nexmo Text2Speech example usage.
Package main contains Nexmo Text2Speech example usage.
Package call contains Nexmo Call Request and Response.
Package call contains Nexmo Call Request and Response.
Package sms contains Nexmo SMS Request and Response as in see: https://docs.nexmo.com/messaging/sms-api/api-reference MIT License Copyright (c) 2016 Angel Del Castillo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
Package sms contains Nexmo SMS Request and Response as in see: https://docs.nexmo.com/messaging/sms-api/api-reference MIT License Copyright (c) 2016 Angel Del Castillo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
Package text2speech contains Nexmo Text-To-Speech Request and Response.
Package text2speech contains Nexmo Text-To-Speech Request and Response.

Jump to

Keyboard shortcuts

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