autocomplete coming soon

This commit is contained in:
Asim Aslam
2022-02-15 15:12:14 +00:00
parent 871025dabf
commit bbb435a7d9
6 changed files with 213 additions and 64 deletions

View File

@@ -42,6 +42,7 @@ func NewPlaceEndpoints() []*api.Endpoint {
// Client API for Place service
type PlaceService interface {
Autocomplete(ctx context.Context, in *AutocompleteRequest, opts ...client.CallOption) (*AutocompleteResponse, error)
Nearby(ctx context.Context, in *NearbyRequest, opts ...client.CallOption) (*NearbyResponse, error)
Search(ctx context.Context, in *SearchRequest, opts ...client.CallOption) (*SearchResponse, error)
}
@@ -58,6 +59,16 @@ func NewPlaceService(name string, c client.Client) PlaceService {
}
}
func (c *placeService) Autocomplete(ctx context.Context, in *AutocompleteRequest, opts ...client.CallOption) (*AutocompleteResponse, error) {
req := c.c.NewRequest(c.name, "Place.Autocomplete", in)
out := new(AutocompleteResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *placeService) Nearby(ctx context.Context, in *NearbyRequest, opts ...client.CallOption) (*NearbyResponse, error) {
req := c.c.NewRequest(c.name, "Place.Nearby", in)
out := new(NearbyResponse)
@@ -81,12 +92,14 @@ func (c *placeService) Search(ctx context.Context, in *SearchRequest, opts ...cl
// Server API for Place service
type PlaceHandler interface {
Autocomplete(context.Context, *AutocompleteRequest, *AutocompleteResponse) error
Nearby(context.Context, *NearbyRequest, *NearbyResponse) error
Search(context.Context, *SearchRequest, *SearchResponse) error
}
func RegisterPlaceHandler(s server.Server, hdlr PlaceHandler, opts ...server.HandlerOption) error {
type place interface {
Autocomplete(ctx context.Context, in *AutocompleteRequest, out *AutocompleteResponse) error
Nearby(ctx context.Context, in *NearbyRequest, out *NearbyResponse) error
Search(ctx context.Context, in *SearchRequest, out *SearchResponse) error
}
@@ -101,6 +114,10 @@ type placeHandler struct {
PlaceHandler
}
func (h *placeHandler) Autocomplete(ctx context.Context, in *AutocompleteRequest, out *AutocompleteResponse) error {
return h.PlaceHandler.Autocomplete(ctx, in, out)
}
func (h *placeHandler) Nearby(ctx context.Context, in *NearbyRequest, out *NearbyResponse) error {
return h.PlaceHandler.Nearby(ctx, in, out)
}