Пример #1
0
func RepoUberFindPD(c1 Coordinate, c2 Coordinate) PriceDist {
	k := 0
	lat1 := c1.Lat
	lng1 := c1.Lng
	lat2 := c2.Lat
	lng2 := c2.Lng
	data := make([]Price, 100)

	client := uber.NewClient("As8XPWG3ReL46A388bynORIEB7cbmQSKVFiZfx1U")
	prices, err := client.GetPrices(lat1, lng1, lat2, lng2)
	if err != nil {
		fmt.Println(err)
		fmt.Println(c1)
		fmt.Println(c2)

		fmt.Println("above this")

	} else {
		for _, price := range prices {
			var temp Price
			var temp2 = *price
			temp.Estimate = temp2.Estimate
			temp.LowEstimate = temp2.LowEstimate
			temp.HighEstimate = temp2.HighEstimate
			temp.Duration = temp2.Duration
			temp.Distance = temp2.Distance
			//fmt.Println(temp)
			data[k] = temp
			//fmt.Println("k","%d",k)
			k++
			//fmt.Println(*price)
		}
	}
	var pd PriceDist
	pd.Price = data[0].LowEstimate
	pd.Distance = data[0].Distance
	pd.Duration = data[0].Duration
	return pd
}
Пример #2
0
// In order to use the Uber API you must register an application at
// https://developer.uber.com/. In turn you will receive a `client_id`, `secret`, and
// `server_token`.
func ExampleClient() {
	client = uber.NewClient("your server_token")
}
Пример #3
0
	"gopkg.in/mgo.v2/bson"
	"io/ioutil"
	"log"
	"net/http"
	"os"
	"strings"
	//"strconv"
	//"github.com/gorilla/mux"
	//"encoding/binary"
	//  "bytes"

	uber "github.com/r-medina/go-uber"
	"math/rand"
)

var clientReq *uber.Client = uber.NewClient("As8XPWG3ReL46A388bynORIEB7cbmQSKVFiZfx1U")

type msg struct {
	Pid        bson.ObjectId `bson:"_id"`
	Id         int           `bson:"id"`
	Name       string        `bson:"name"`
	Address    string        `bson:"address"`
	City       string        `bson:"city"`
	State      string        `bson:"state"`
	Zip        string        `bson:"zip"`
	Coordinate Coordinate    `bson:"coordinate"`
}
type tripmsg struct {
	Pid                          bson.ObjectId `bson:"_id"`
	Id                           int           `bson:"id"`
	Status                       string        `bson:"status"`