package tel


import(
	"github.com/usual2970/util/request"

)

type Params struct {
	DeveloperCDR string `json:"developerCDR"`
	DisplayNbr   string `json:"displayNbr"`
	CallerNbr    string `json:"callerNbr"`
	CalleeNbr    string `json:"calleeNbr"`
	LanguageType string `json:"languageType"`
	StatusURL    string `json:"statusURL"`
}

type Tel struct {
	SessionId string
	Params    *Params
}

func NewTel(from, to string) *Tel {
	params := &Params{
		DeveloperCDR: "yidianlingTel",
		DisplayNbr:   DispayNumber,
		CallerNbr:    "+86" + from,
		CalleeNbr:    "+86" + to,
		LanguageType: "0",
		StatusURL:    CallbackUrl,
	}

	return &Tel{
		Params: params,
	}
}

func (t *Tel) Dial() (v interface{},err error) {
	tlsClient,err:=request.NewTLSHttpClientSingle(CerPath)
	if err!=nil{
		return 
	}

	client:=request.NewClient(AppKey,AppSecret,tlsClient)
	
	client.Post(DialUrl,t.Params)
	return
}

func (t *Tel) Cancel() interface{} {
	return ""
}


