def readThermostat(thermostat_id=False): requestparams={'thermostat_id' :thermostat_id} contextparams={} if thermostat_id is False: raise Exception("thermostat_id cannot be empty") result = invoke( 'GET', 'thermostat', requestparams,contextparams) return result
def updateThermostat(thermostat_id=None,guid=None): requestparams={'thermostat_id':thermostat_id} requestparams.update(request.json) contextparams={'guid' : requestparams.pop('guid', 0)} if request.json is None: return Error(10004).render() # result = validate_update_thermostat(requestparams) # if result is not None: # return result result =invoke( 'PUT', 'thermostat',requestparams,contextparams) return result
def POST(request_params,context_params): logger.info("Start of user onboarding") location_params = {} location_params['locations']= request_params.pop('locations') user_params = request_params try: user_response = invoke('POST','user',user_params,context_params) location_params['user_id'] = user_response['user_id'] location_response = invoke('PUT','location',location_params,context_params) except ServiceException as ex: logger.error("Onboarding failed for user %s %s" %(user_params,location_params)) return Error(ex.errorCode) response={} response.update(location_response) response.update(user_response) logger.info("User onboarding succesful") return response
def POST(request_params, context_params): logger.info("Start of user onboarding") location_params = {} location_params['locations'] = request_params.pop('locations') user_params = request_params try: user_response = invoke('POST', 'user', user_params, context_params) location_params['user_id'] = user_response['user_id'] location_response = invoke('PUT', 'location', location_params, context_params) except ServiceException as ex: logger.error("Onboarding failed for user %s %s" % (user_params, location_params)) return Error(ex.errorCode) response = {} response.update(location_response) response.update(user_response) logger.info("User onboarding succesful") return response
def create_user_location(): request_params,context_params=get_param() context_params['partner_id']=8 logger.info("Inside create_user_location") result = invoke("POST", "onboarding", request_params,context_params) return result
def create_user_location(): request_params, context_params = get_param() context_params['partner_id'] = 8 logger.info("Inside create_user_location") result = invoke("POST", "onboarding", request_params, context_params) return result