# frozen_string_literal: true module DjiMqttConnect module Thing::Product class EventsMessage < DjiMqttConnect::Message attribute :bid, Types::UUID attribute :tid, Types::UUID attribute :timestamp, Types::Timestamp # Can be determined from the topic, but included for convenience attribute? :gateway, Types::SerialNumber # NOTE: Included in most events messages, requires a reply on the events_reply topic if true attribute? :need_reply, Types::Integer.enum(0, 1) attribute :_data, Types::Hash attribute :_method, Types::String attribute :data, Types::Hash.default({}.freeze) def need_reply? need_reply == 1 end def humanized_summary Translations.thing_product_events_summary(_method, **humanized_summary_interpolation) end def humanized_summary_interpolation data.to_h.merge(method: _method, flight_ids: flight_ids.join(", ")) end # All the flight IDs in the message def flight_ids [] end def to_s # Include data method for Generic messages instance_of?(EventsMessage) ? "#{super}[#{_method}]" : super end end end end