//get the total price (in CREDITS! NOT MONEYS!) for sending out a given message to a list of receivers.
//for credit prices see bulksms.com
get the total price (in CREDITS. NOT MONEYS!) for sending out a given message to a list of receivers.
for credit prices see bulksms.com
// get the total price ( in CREDITS! NOT MONEYS! ) for sending out a given message to a list of receivers . // for credit prices see bulksms . com
func (sms *BulkSMSSMSSender) GetQuote(receivers []string, message string) (err error, quote float64) {
	if sms.RoutingGroup < 1 || sms.RoutingGroup > 3 {
		err = errors.New("Routing Group must be 1, 2 or 3!")
		return
	}
	rtgrp := strconv.Itoa(sms.RoutingGroup)
	endpoint_url := "http://bulksms.vsms.net:5567/eapi/submission/quote_sms/2/2.0"
	rcvrs := strings.Join(receivers, ",")
	data := url.Values{
		"username":      []string{sms.Username},
		"password":      []string{sms.Password},
		"message":       []string{message},
		"msisdn":        []string{rcvrs},
		"routing_group": []string{rtgrp},
	}
	if len(sms.SenderId) > 0 {
		data.Set("sender", sms.SenderId)
	}
	c := &http.Client{}
	resp, err := c.PostForm(endpoint_url, data)
	if err != nil {
		return err, 0.0
	}
	respbytes, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return err, 0.0
	}
	resp.Body.Close()
	respstr := strings.Trim(string(respbytes[0:]), "\r\n")
	respitems := strings.Split(respstr, "|")
	respcode, err := strconv.ParseInt(respitems[0], 10, 64)
	if err != nil {
		return err, 0.0
	}
	if respcode != 0 {
		return errors.New(fmt.Sprintf("err code %d: %s", respcode, respitems[1])), 0.0
	}
	quote, err = strconv.ParseFloat(respitems[2], 64)
	return
}
func ( sms * BulkSMSSMSSender ) GetQuote ( receivers [ ] string , message string ) ( err error , quote float64 ) { if sms . RoutingGroup < 1 || sms . RoutingGroup > 3 { err = errors . New ( " " ) return } rtgrp := strconv . Itoa ( sms . RoutingGroup ) endpoint_url := " " rcvrs := strings . Join ( receivers , " " ) data := url . Values { " " : [ ] string { sms . Username } , " " : [ ] string { sms . Password } , " " : [ ] string { message } , " " : [ ] string { rcvrs } , " " : [ ] string { rtgrp } , } if len ( sms . SenderId ) > 0 { data . Set ( " " , sms . SenderId ) } c := & http . Client { } resp , err := c . PostForm ( endpoint_url , data ) if err != nil { return err , 0.0 } respbytes , err := ioutil . ReadAll ( resp . Body ) if err != nil { return err , 0.0 } resp . Body . Close ( ) respstr := strings . Trim ( string ( respbytes [ 0 : ] ) , " \r \n " ) respitems := strings . Split ( respstr , " " ) respcode , err := strconv . ParseInt ( respitems [ 0 ] , 10 , 64 ) if err != nil { return err , 0.0 } if respcode != 0 { return errors . New ( fmt . Sprintf ( " " , respcode , respitems [ 1 ] ) ) , 0.0 } quote , err = strconv . ParseFloat ( respitems [ 2 ] , 64 ) return }
get the total price (in CREDITS.
get the total price ( in CREDITS .