You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: sensor.rb
    path of file: ./repos/ekylibre/app/models
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

# = Informations
#
# == License
#
# Ekylibre - Simple agricultural ERP
# Copyright (C) 2008-2009 Brice Texier, Thibaud Merigon
# Copyright (C) 2010-2012 Brice Texier
# Copyright (C) 2012-2014 Brice Texier, David Joulin
# Copyright (C) 2015-2023 Ekylibre SAS
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distribute
    
  def retrieve(options = {})
    return if listening?
    raise "Unknown equipment: vendor=#{vendor_euid}, model=#{model_euid}" unless equipment

    connection = equipment.connect(access_parameters)

    results = connection.retrieve(options)
    attributes = {
      retrieval_status: results[:status]
    }
    attributes[:nature] = results[:nature] || :sensor_analysis
    if results[:status].to_s == 'ok'
      # Indicators
      values = []
      results[:values].each do |k, v|
        values << { indicator_name: k, value: v } if v.present?
      end
      attributes.update(
        sampled_at: options[:started_at],
        analysed_at: options[:stopped_at],
        stopped_at: options[:stopped_at],
        geolocation: results[:geolocation],
        sampling_temporal_mode: results[:sampling_temporal_mode],
        items_attributes: values
      )
    else
      attributes[:retrieval_message] = results[:message]
    end