Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

README.md

sdk-go

SDK in Go for the CALLR API.

Works with Go 1.11+ (this is a go module), using standard packages only.

Quick start

import callr "github.com/THECALLR/sdk-go"

func main() {
    // use Api Key Auth (recommended) - use the customer portal to generate keys
    api := callr.NewWithAPIKeyAuth("key")
    
    result, err := api.Call("method", params...)

Usage

Broadcast

Broadcast messages to a target

target := map[string]interface{}{
    "number": "+33123456789",
    "timeout": 30,
}
messages := []interface{}{
    131,
    132,
    "TTS|TTS_EN-GB_SERENA|Hello world! how are you ? I hope you enjoy this call. good bye."
}

options := map[string]interface{}{
    "cdr_field": "userData",
    "cli": "BLOCKED",
    "loop": 2,
}

result, err := api.Call("calls.broadcast_1", target, messages, options)
Without options
target := map[string]interface{}{
    "number": "+33123456789",
    "timeout": 30,
}

messages := []interface{}{
    131,
    132,
    134,
}

result, err := api.Call("calls.broadcast_1", target, messages, nil)

Method

Objects


REALTIME

Create a REALTIME app with a callback URL

options := map[string]interface{}{
    "url": "http://yourdomain.com/realtime_callback_url",
}

result, err := api.Call("apps.create", "REALTIME10", "Your app name", options)

Method

Objects

Start a REALTIME outbound call

target := map[string]interface{}{
    "number": "+33132456789",
    "timeout": 30,
}

callOptions := map[string]interface{}{
    "cdr_field": "42",
    "cli": "BLOCKED",
}

result, err := api.Call("calls.realtime", "appHash", target, callOptions)

Method

Objects

Inbound Calls - Assign a phone number to a REALTIME app

result, err := api.Call("apps.assign_did", "appHash", "DID ID")

Method

Objects


Sending SMS

Without options

result, err := api.Call("sms.send", "SMS", "+33123456789", "Hello, world", nil)

Method

Personalized sender

Your sender must have been authorized and respect the sms_sender format

result, err := api.Call("sms.send", "Your Brand", "+33123456789", "Hello world!", nil)

Method

If you want to receive replies, do not set a sender - we will automatically use a shortcode

result, err := api.Call("sms.send", "", "+33123456789", "Hello world!", nil)

Method

Force GSM encoding

optionSMS := map[string]interface{}{
    "force_encoding": "GSM",
}

result, err := api.Call("sms.send", "", "+33123456789", "Hello world!", optionSMS)

Method

Objects

Long SMS (availability depends on carrier)

var text bytes.Buffer

text.WriteString("Some super mega ultra long text to test message longer than 160 characters ")
text.WriteString("Some super mega ultra long text to test message longer than 160 characters ")
text.WriteString("Some super mega ultra long text to test message longer than 160 characters")

result, err := api.Call("sms.send", "SMS", "+33123456789", text.String(), nil)

Method

Specify your SMS nature (alerting or marketing)

optionSMS := map[string]interface{}{
    "nature": "ALERTING",
}

result, err := api.Call("sms.send", "SMS", "+33123456789", "Hello world!", optionSMS)

Method

Objects

Custom data

optionSMS := map[string]interface{}{
    "user_data": "42",
}

result, err := api.Call("sms.send", "SMS", "+33123456789", "Hello world!", optionSMS)

Method

Objects

Delivery Notification - set webhook endpoint to receive notifications

optionSMS := map[string]interface{}{
       	"webhook": map[string]interface{}{ 
			"endpoint":"http://yourdomain.com/webhook_endpoint", 
		},
    }


result, err := api.Call("sms.send", "SMS", "+33123456789", "Hello world!", optionSMS)

Method

Objects

Inbound SMS - set webhook endpoint to receive inbound messages (MO) and replies

Do not set a sender if you want to receive replies - we will automatically use a shortcode.

optionSMS := map[string]interface{}{
       	"webhook": map[string]interface{}{ 
			"endpoint":"http://yourdomain.com/webhook_endpoint", 
		},
    }

result, err := api.Call("sms.send", "", "+33123456789", "Hello world!", optionSMS)

Method

Objects

Get an SMS

result, err := api.Call("sms.get", "SMSHASH")

Method

Objects


DIDs

List available countries with DID availability

result, err := api.Call("did/areacode.countries")

Method

Objects

Get area codes available for a specific country and DID type

result, err := api.Call("did/areacode.get_list", "US", nil)

Method

Objects

Get DID types available for a specific country

result, err := api.Call("did/areacode.types", "US")

Method

Objects

Buy a DID (after a reserve)

result, err := api.Call("did/store.buy_order", "OrderToken")

Method

Objects

Cancel your order (after a reserve)

result, err := api.Call("did/store.cancel_order", "OrderToken")

Method

Cancel a DID subscription

result, err := api.Call("did/store.cancel_subscription", "DID ID")

Method

View your store quota status

result, err := api.Call("did/store.get_quota_status")

Method

Objects

Get a quote without reserving a DID

result, err := api.Call("did/store.get_quote", 0, "GOLD", 1)

Method

*Objects/

Reserve a DID

result, err := api.Call("did/store.reserve", 0, "GOLD", 1, "RANDOM")

Method

Objects

View your order

result, err := api.Call("did/store.view_order", "OrderToken")

Method

Objects


Media

List your medias

result, err := api.Call("media/library.get_list", nil)

Method

Create an empty media

result, err := api.Call("media/library.create", "name")

Method

Upload a media

mediaID := 0

result, err := api.Call("media/library.set_content_from_file", mediaID, "imported temporary file name")

Method

Use Text-to-Speech

mediaID := 0

result, err := api.Call("media/tts.set_content", mediaID, "Hello world!", "TTS-EN-GB_SERENA", nil)

Method

You can’t perform that action at this time.