Sha256: 94599c973b18f85385a56b4ed5db8d80ca87d17cf891ab85759658f91ccc5c0b

Contents?: true

Size: 1.6 KB

Versions: 2

Compression:

Stored size: 1.6 KB

Contents

# frozen_string_literal: true

module DjiMqttConnect
  module Thing::Product
    class AirportBindStatusRequestsReplyMessage < RequestsReplyMessage
      def self.build_for(airport_bind_status_message, bind_status:, result: 0)
        new(
          _method: airport_bind_status_message._method,
          tid: airport_bind_status_message.tid,
          bid: airport_bind_status_message.bid,
          timestamp: current_timestamp,
          data: {
            result: result,
            output: {
              bind_status: bind_status
            }
          }
        )
      end

      attribute :_method, Types::String.enum("airport_bind_status")

      attribute :data do
        include Mixins::ResultMessage

        attribute :result, Types::ResultCode

        attribute :output do
          attribute :bind_status, Types::Array do
            attribute :sn, Types::SerialNumber
            attribute :is_device_bind_organization, Types::Bool
            attribute :organization_id, Types::String
            attribute :organization_name, Types::String
            attribute :device_callsign, Types::String

            def humanized_summary
              I18n.t(
                is_device_bind_organization ? "bound" : "unbound",
                scope: "dji_mqtt_connect.thing_product_airport_bind_status_requests_reply_message.humanized_summary",
                **to_h
              )
            end
          end
        end
      end

      def humanized_summary_interpolation
        super.merge(
          bind_status: data.output.bind_status.map(&:humanized_summary).join(", ")
        )
      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/thing/product/requests_reply/airport_bind_status.rb
dji_mqtt_connect-0.1.25 lib/dji_mqtt_connect/messages/thing/product/requests_reply/airport_bind_status.rb