def save_datapoints
      @logger.debug "Saving #{datapoints.size} datapoints to the #{id} datastream"
      response = XivelyConnector.connection.post("/v2/feeds/#{device.id}/datastreams/#{id}/datapoints",
                                                  :body => {:datapoints => datapoints}.to_json)
      # If the response succeeded, clear the datapoint buffer and return the response object
      if response.success?
        clear_datapoints_buffer
        response
      else
        logger.error response.response
        raise response.response
      end
    end
def save_datapoints
      @logger.debug "Saving #{datapoints.size} datapoints to the #{id} datastream"
      response = XivelyConnector.connection.post("/v2/feeds/#{device.id}/datastreams/#{id}/datapoints",
                                                  :body => {:datapoints => datapoints}.to_json)
      # If the response succeeded, clear the datapoint buffer and return the response object
      if response.success?
        clear_datapoints_buffer
        response
      else
        logger.error response.response
        raise response.response
      end
    end
Send the queued datapoints array to Xively