golang lib api Telphin billing
~ $ go get -u gopkg.in/OrlovEvgeny/telphin-sdk.v1
Example Trusted auth
func main() {
//OAuth type
trusted := &telphin.Trusted {
GrantType: "client_credentials",
ClientID: <your client_id>,
ClientSecret: <your client_secret>,
}
//New api
api, err := telphin.NewAPI(trusted)
if err != nil {
fmt.Println(err)
}
fmt.Println("You telphin access token: ", api.AccessToken)
fmt.Println("You telphin token expires in: ", api.ExpiresIn)
fmt.Println("You telphin Login: ", api.User.Login)
fmt.Println("You telphin Clinet ID: ", api.User.ClientId)
fmt.Println("You telphin is Admin: ", api.User.IsAdmin)
}
Example get Extension list
exten, err := api.ExtensionList(api.User.ClientId, true)
if err != nil {
fmt.Println(err)
}
for _, e := range exten {
fmt.Printf("Extension id: %d, Extension name: %s \n", e.ID, e.Name)
}
Example download records
exten, err := api.ExtensionList(api.User.ClientId, true)
if err != nil {
fmt.Println(err)
}
t := time.Now()
rounded := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
recordList, err := api.GetRecordList(exten[0].ID, rounded, time.Now(), "asc")
if err != nil {
fmt.Println(err)
}
for _, v := range recordList {
api.DownloadRecord(v.RecordUUID, "./downloads/")
}
All methods: