Sha256: 30790453586a8ecb0b4ad871016a641ed0fbd6ec14bc76c6a7f349b63547ebec

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module DjiMqttConnect
  module Sys::Product
    # {"tid":"3093aad5-bb98-5026-685a-cea540eb9267","bid":"479533e0-cb01-933c-3758-22f2a82abeb8","timestamp":1679380232398,"method":"update_topo","data":{"domain":2,"type":144,"sub_type":0,"device_secret":"0d180c84ddbe76ee32ad2e48eab3c994","nonce":"83ad8038363b4d5387cbf106d1517718","version":1,"sub_devices":[]}}
    class StatusMessage < DjiMqttConnect::Message
      attribute :tid, Types::UUID
      attribute :bid, Types::UUID
      attribute :timestamp, Types::Timestamp

      attribute :_data, Types::Hash
      attribute :_method, Types::String

      attribute :data, Types::Hash.default({}.freeze)

      def humanized_summary
        Translations.sys_product_status_summary(_method, **humanized_summary_interpolation)
      end

      def humanized_summary_interpolation
        data.to_h.merge(method: _method)
      end

      def to_s
        # Include data method for Generic messages
        instance_of?(StatusMessage) ? "#{super}[#{_method}]" : super
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dji_mqtt_connect-0.1.25.1 lib/dji_mqtt_connect/messages/sys/product/status_message.rb
dji_mqtt_connect-0.1.25 lib/dji_mqtt_connect/messages/sys/product/status_message.rb