Sha256: d2918e173c104b84f428c238bdb12842d6851c22b91dc78feb527a6c40d326fb

Contents?: true

Size: 1.57 KB

Versions: 2

Compression:

Stored size: 1.57 KB

Contents

# frozen_string_literal: true

module DjiMqttConnect
  module Thing::Product
    # https://developer.dji.com/doc/cloud-api-tutorial/en/api-reference/dock-to-cloud/mqtt/dock/custom_fly_area.html#get-custom-flight-area-file
    class FlightAreasGetRequestsReplyMessage < RequestsReplyMessage
      def self.build_for(flight_areas_get, files:, result: 0)
        new(
          _method: flight_areas_get._method,
          data: {
            result: result,
            output: {
              files: files
            }
          },
          tid: flight_areas_get.tid,
          bid: flight_areas_get.bid,
          timestamp: current_timestamp
        )
      end

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

      attribute :data do
        include Mixins::ResultMessage

        attribute :result, Types::ResultCode

        attribute :output do
          attribute :files, Types::Array do
            attribute :name, Types::String
            attribute :url, Types::String
            attribute :checksum, Types::String
            attribute :size, Types::Integer

            def humanized_summary
              name
            end
          end
        end
      end

      def humanized_summary
        return super if data.output.files.none?

        Translations.thing_product_requests_reply_summary(
          "#{_method}_with_files",
          **humanized_summary_interpolation
        )
      end

      def humanized_summary_interpolation
        super.merge(
          files: data.output.files.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/flight_areas_get.rb
dji_mqtt_connect-0.1.25 lib/dji_mqtt_connect/messages/thing/product/requests_reply/flight_areas_get.rb