def _api_command(self, api_method, api_url, api_params): params = { 'apiMethod': api_method, 'apiParameters': api_params, 'apiUrl': api_url } result = self._send_message(MessageTypes.API_COMMAND, params) self._validate_api_call_response(result) return AppState(result)
def request_pickup(self, pickup_address, vehicle_type=UberVehicleType.UBERX, gps_location=None, payment_profile=None, use_credits=True): """ request an uber pickup. Args: - vehicle_type: an id or a VehicleView instance of the ride you want - pickup_address: geo-coded location or a string (if you're feeling frisky!) - current_location: gps coords - payment_profile: (optional) a payment profile id or an instance of PaymentProfile Returns: - app_state To examine ride status, check the following: """ if isinstance(vehicle_type, VehicleView): vehicle_type = vehicle_type.id if isinstance(payment_profile, PaymentProfile): payment_profile = payment_profile.id if isinstance(pickup_address, basestring): search_result = geolocation.geolocate(pickup_address) if not search_result: raise UberLocationNotFound(u"Can't find location " + unicode(pickup_address)) pickup_address = search_result[0] params = { 'pickupLocation': pickup_address, 'useCredits': use_credits, 'vehicleViewId': int(vehicle_type), } if payment_profile: params['paymentProfileId'] = int(payment_profile) response = self._send_message('Pickup', params=params, location=gps_location) return AppState(response)
def cancel_pickup(self, location=None): """ cancels current ride """ return AppState(self._send_message('PickupCanceledClient', location=location))
def ping(self, location): """ 'pings' uber and returns the state of the world. (nearby cars, pricing etc) """ return AppState(self._send_message(MessageTypes.PING_CLIENT, location=location))