Пример #1
0
    def make_vehicles(cls, pod_id, pod_data):
        '''
            "coordinates": {
                "lat": 42.3673905200087,
                "lng": -71.0897461574591
            },

        '''
        ret_val = []

        vehicles = object_utils.dval_list(pod_data, 'vehicles')
        for vehicle_data in vehicles:
            vid = object_utils.dval(vehicle_data, 'vehicle_id')
            zc = ZipcarVehicle(vid, pod_id)
            zc.set_attributes(pod_data, vehicle_data)
            ret_val.append(zc)
        return ret_val
Пример #2
0
    def make_vehicles(cls, pod_id, pod_data):
        '''
            "coordinates": {
                "lat": 42.3673905200087,
                "lng": -71.0897461574591
            },

        '''
        ret_val = []

        vehicles = object_utils.dval_list(pod_data, 'vehicles')
        for vehicle_data in vehicles:
            vid = object_utils.dval(vehicle_data, 'vehicle_id')
            zc = ZipcarVehicle(vid, pod_id)
            zc.set_attributes(pod_data, vehicle_data)
            ret_val.append(zc)
        return ret_val
Пример #3
0
    def set_attributes(self, pod_data, vehicle_data):
        ''' copy known values from the dict into this object, then update the timestamp
        {
          "vehicle_id": 1179454588,
          "vehicle_name": "Gadsen",
          "make_model": "Volkswagen Golf",
          "style": "5-door",
          "year": 2014,
          "hourly_rate": 10.5,
          "daily_rate": 78,
          "currency_code": "USD",
          "product_types": [
            {
              "type": "standard",
              "label": "Zipcars"
            }
          ],
          "images": {
            "thumb": "http://media.zipcar.com/images/model-image?model_id=980237689&mode=thumb",
            "mobile": "http://media.zipcar.com/images/model-image?model_id=980237689&mode=med",
            "desktop": "http://media.zipcar.com/images/model-image?model_id=980237689"
          },
          "actions": [
            {
              "type": "learn_more",
              "label": "Learn More",
              "url": "http://www.zipcar.com/?mobile_p=0&utm_source=partner&utm_medium=api&utm_campaign=partner_app&utm_content=version0"
            },
            {
              "type": "reserve",
              "label": "Reserve",
              "url": "https://members.zipcar.com/reservations?utm_source=partner&utm_medium=api&utm_campaign=partner_app&utm_content=version0"
            }
          ]
        }
        '''
        self.name   = object_utils.dval(vehicle_data, 'vehicle_name')
        self.model  = object_utils.dval(vehicle_data, 'make_model')
        self.style  = object_utils.dval(vehicle_data, 'style')
        self.year   = object_utils.dval(vehicle_data, 'year')
        self.hourly = object_utils.dval(vehicle_data, 'hourly_rate')
        self.daily  = object_utils.dval(vehicle_data, 'daily_rate')

        images = object_utils.dval(vehicle_data, 'images')
        self.img_thumb = object_utils.dval(images, 'thumb')
        self.img_small = object_utils.dval(images, 'mobile')
        self.img_large = object_utils.dval(images, 'desktop')

        urls = object_utils.dval_list(vehicle_data, 'actions')
        for u in urls:
            type = object_utils.dval(u, 'type')
            if type == 'reserve':
                self.url_reserve = object_utils.dval(u, 'url')
            if type == 'learn_more':
                self.url_info = object_utils.dval(u, 'url')

        coord = object_utils.dval(pod_data, 'coordinates')
        address = object_utils.dval(pod_data, 'address')
        self.lat, self.lon  = geo_utils.get_coord_from_dict(coord)
        self.street, self.city, self.state, self.zip = geo_utils.get_address_from_dict(address)
        self.updated = datetime.datetime.now()
Пример #4
0
    def set_attributes(self, pod_data, vehicle_data):
        ''' copy known values from the dict into this object, then update the timestamp
        {
          "vehicle_id": 1179454588,
          "vehicle_name": "Gadsen",
          "make_model": "Volkswagen Golf",
          "style": "5-door",
          "year": 2014,
          "hourly_rate": 10.5,
          "daily_rate": 78,
          "currency_code": "USD",
          "product_types": [
            {
              "type": "standard",
              "label": "Zipcars"
            }
          ],
          "images": {
            "thumb": "http://media.zipcar.com/images/model-image?model_id=980237689&mode=thumb",
            "mobile": "http://media.zipcar.com/images/model-image?model_id=980237689&mode=med",
            "desktop": "http://media.zipcar.com/images/model-image?model_id=980237689"
          },
          "actions": [
            {
              "type": "learn_more",
              "label": "Learn More",
              "url": "http://www.zipcar.com/?mobile_p=0&utm_source=partner&utm_medium=api&utm_campaign=partner_app&utm_content=version0"
            },
            {
              "type": "reserve",
              "label": "Reserve",
              "url": "https://members.zipcar.com/reservations?utm_source=partner&utm_medium=api&utm_campaign=partner_app&utm_content=version0"
            }
          ]
        }
        '''
        self.name = object_utils.dval(vehicle_data, 'vehicle_name')
        self.model = object_utils.dval(vehicle_data, 'make_model')
        self.style = object_utils.dval(vehicle_data, 'style')
        self.year = object_utils.dval(vehicle_data, 'year')
        self.hourly = object_utils.dval(vehicle_data, 'hourly_rate')
        self.daily = object_utils.dval(vehicle_data, 'daily_rate')

        images = object_utils.dval(vehicle_data, 'images')
        self.img_thumb = object_utils.dval(images, 'thumb')
        self.img_small = object_utils.dval(images, 'mobile')
        self.img_large = object_utils.dval(images, 'desktop')

        urls = object_utils.dval_list(vehicle_data, 'actions')
        for u in urls:
            type = object_utils.dval(u, 'type')
            if type == 'reserve':
                self.url_reserve = object_utils.dval(u, 'url')
            if type == 'learn_more':
                self.url_info = object_utils.dval(u, 'url')

        coord = object_utils.dval(pod_data, 'coordinates')
        address = object_utils.dval(pod_data, 'address')
        self.lat, self.lon = geo_utils.get_coord_from_dict(coord)
        self.street, self.city, self.state, self.zip = geo_utils.get_address_from_dict(
            address)
        self.updated = datetime.datetime.now()