示例#1
0
    def start_driving_no_map(self, request_params, alternate_events=None):
        '''Start driving with a text confirmation instead of a map'''
        latitude = load_parameter(request_params, "dest latitude")
        longitude = load_parameter(request_params, "dest longitude")

        # we can't reliably split the variable name into entity and variable type because
        # variable names can include v2_0_rating and v1_place_id
        destination_name_variable = request_params[0]['variable_name'].replace(
            'latitude', 'name')
        destination_address_variable = request_params[0][
            'variable_name'].replace('latitude', 'address')
        destination_name = self.manager.lookup_variable_by_name(
            destination_name_variable)
        destination_address = self.manager.lookup_variable_by_name(
            destination_address_variable)

        request_params.append({
            'name':
            'confirmationString',
            'variable_name':
            'confirmationString',
            'value':
            'The agent selected your destination as {} at {} ({}, {}). Is this correct?'
            .format(destination_name, destination_address, latitude, longitude)
        })
        return self.api_call(self.map_provider.start_driving_no_map,
                             request_params,
                             latitude,
                             longitude,
                             alternate_events=alternate_events)
示例#2
0
 def places_nearby(self, request_params, alternate_events=None):
     query = load_parameter(request_params, "query")
     latitude = load_parameter(request_params, "src latitude")
     longitude = load_parameter(request_params, "src longitude")
     return self.api_call(self.map_provider.places_nearby,
                          request_params,
                          query,
                          latitude,
                          longitude,
                          alternate_events=alternate_events)
示例#3
0
 def start_driving(self, request_params, alternate_events=None):
     latitude = load_parameter(request_params, "dest latitude")
     longitude = load_parameter(request_params, "dest longitude")
     place_id = load_parameter(request_params, "dest id")
     return self.api_call(self.map_provider.start_driving,
                          request_params,
                          latitude,
                          longitude,
                          place_id,
                          alternate_events=alternate_events)
示例#4
0
 def find_place(self, request_params, alternate_events=None):
     query = load_parameter(request_params, "query")
     latitude = load_parameter(request_params, "src latitude")
     longitude = load_parameter(request_params, "src longitude")
     response = self.api_call(self.map_provider.find_place,
                              request_params,
                              query,
                              latitude,
                              longitude,
                              alternate_events=alternate_events)
     return response
示例#5
0
 def distance_matrix(self, request_params, alternate_events=None):
     source_latitude = load_parameter(request_params, "src latitude")
     source_longitude = load_parameter(request_params, "src longitude")
     dest_latitude = load_parameter(request_params, "dest latitude")
     dest_longitude = load_parameter(request_params, "dest longitude")
     return self.api_call(self.map_provider.distance_matrix,
                          request_params,
                          source_latitude,
                          source_longitude,
                          dest_latitude,
                          dest_longitude,
                          alternate_events=alternate_events)
示例#6
0
    def find_latlon(self, request_params, alternate_events=None):
        '''find_place, but only returns lat/long'''
        query = load_parameter(request_params, "query")
        latlon = load_parameter(request_params, "src lat/long")

        # find_latlon is currently only supported with google maps
        response = self.api_call(self.map_provider.find_latlon,
                                 request_params,
                                 query,
                                 latlon,
                                 alternate_events=alternate_events)

        return response
示例#7
0
    def at_time(self, request_params):
        '''Return the current weather at the specified time'''

        lat_long = load_parameter(request_params, "lat/long")
        lat, lon = lat_long.split(',')
        time_query = load_parameter(request_params, "time query")
        response = self.api_call(
            self.provider.weather_at_time,
            request_params,
            lat,
            lon,
            time_query)
        return response
示例#8
0
 def current(self, request_params):
     '''Return the current weather'''
     lat_long = load_parameter(request_params, "lat/long")
     lat, lon = lat_long.split(',')
     response = self.api_call(
         self.provider.current_weather,
         request_params,
         lat,
         lon)
     return response
示例#9
0
 def generate_place(self, request_params):
     latitude = load_parameter(request_params, "src latitude")
     longitude = load_parameter(request_params, "src longitude")
     return self.map_provider.generate_place(latitude, longitude)
示例#10
0
 def compare(self, request_params):
     number1 = load_parameter(request_params, "number1")
     number2 = load_parameter(request_params, "number2")
     return self.api_call(self.provider.compare, request_params, number1,
                          number2)