# frozen_string_literal: true module DjiMqttConnect module Thing::Product # https://developer.dji.com/doc/cloud-api-tutorial/en/server-api-reference/mqtt/thing-model/gateway/dock/log.html#inform-of-file-uploading-progress class FileuploadProgressEventsMessage < EventsMessage attribute :_method, Types::String.enum("fileupload_progress") attribute :data do attribute :output do attribute :ext do attribute :files, Types::Array do # {"0":"Aircraft","3":"DJI Dock"} attribute :module, Types::Coercible::Integer.enum(0, 3) def humanized_module I18n.t(self.module, scope: "dji_mqtt_connect.thing_product_fileupload_progress_events_message.humanized_module") end attribute :size, Types::Integer attribute :device_sn, Types::SerialNumber attribute :key, Types::String attribute? :fingerprint, Types::String attribute :progress do attribute :current_step, Types::Integer attribute? :total_step, Types::Integer attribute :progress, Types::Integer attribute? :finish_time, Types::Timestamp attribute :upload_rate, Types::Integer attribute? :result, Types::Integer attribute :status, Types::String def humanized_status # NOTE: status shares many values with flighttask_status, but not all I18n.t(status, scope: "dji_mqtt_connect.flighttask_status", default: status.titleize) end end def humanized_summary I18n.t( "humanized_summary", scope: "dji_mqtt_connect.thing_product_fileupload_progress_events_message", module: humanized_module, key: key.split("/").last, status: progress.humanized_status, progress: progress.progress ) end end end attribute :status, Types::String end end def humanized_summary_interpolation super.merge( progress: data.output.ext.files.map(&:humanized_summary).join(", ") ) end end end end