Пример #1
0
func GetTaxiAPIInstruments(params c.TaxiApiParams, for_name string) (t.TaxiInterface, t.AddressSupplier, error) {
	switch api_name := params.Name; api_name {
	case i.INFINITY:
		return i.GetInfinityAPI(params, for_name), i.GetInfinityAddressSupplier(params, for_name), nil
	case t.FAKE:
		return t.GetFakeAPI(params), i.GetInfinityAddressSupplier(params, for_name), nil
	case sedi.SEDI:
		sedi_api := sedi.NewSediAPI(params)
		return sedi_api, sedi_api, nil
	}
	return nil, nil, errors.New("Not imply name of api")
}
func main() {
	msngr.DEBUG = true
	//	my_street := "Российская"
	my_address_from := "Российская 3"
	my_street_to := "Российская 28"

	conf := configuration.ReadConfig()
	api_data := conf.Taxis["fake"].Api.GetAPIData()
	s := sedi.NewSediAPI(&api_data)

	//	order_statuses, err := s.GetOrderStatuses()
	//	if err != nil {
	//		log.Printf("order statuses err : %v", err)
	//		return
	//	}
	//	for _, order_status := range order_statuses {
	//		log.Printf("order status : %+v \n", order_status)
	//	}

	log.Println(s)

	address_from := s.AddressesAutocomplete(my_address_from)
	adress_to := s.AddressesAutocomplete(my_street_to)
	log.Printf("\nFrom %+v\nTo %+v\n", address_from, adress_to)

	//	order := taxi.NewOrderInfo{
	//		Delivery:taxi.Delivery{Street:my_street, House:"3"},
	//		Destinations:[]taxi.Destination{taxi.Destination{Street:my_street, House:"28"}},
	//		Phone:"+79811064022",
	//	}
	//	res, mes := s.CalcOrderCost(order)
	//	log.Printf("calc res: %v, mes: %s", res, mes)
	//
	//	ans := s.NewOrder(order)
	//	log.Printf("ans of new order response: %+v", ans)
	//
	//	for {
	//		orders := s.Orders()
	//		for i, order := range orders {
	//			log.Printf("%v\t%v\n", i, order)
	//		}
	//		time.Sleep(10 * time.Second)
	//	}
	//
	//	if ans.IsSuccess {
	//		fmt.Println(s.CancelOrder(ans.Content.Id))
	//	}
}