# frozen_string_literal: true module DjiMqttConnect # Factories for building example messages # Do not include this in your production code module Factories def build_device_online_update_topo_message message_data = { type: 98, sub_type: 0, device_secret: "secret", nonce: "nonce", version: 1, sub_devices: [ { sn: "drone001", type: 116, sub_type: 0, index: "A", device_secret: "secret", nonce: "nonce", version: 1 } ] } Sys::Product::UpdateTopoStatusMessage.new( _method: "update_topo", tid: "12345678-1234-1234-1234-A00000000001", bid: "12345678-1234-1234-1234-B00000000001", timestamp: 1234567890123, data: message_data, _data: message_data.deep_stringify_keys ) end def build_update_topo_status_reply_message Sys::Product::UpdateTopoStatusReplyMessage.new( _method: "update_topo", tid: "3093aad5-bb98-5026-685a-cea540eb9267", bid: "479533e0-cb01-933c-3758-22f2a82abeb8", timestamp: 1679380233000, data: { result: 0 } ) end def build_thing_product_config_requests_message message_data = { config_type: "json", config_scope: "product" } Thing::Product::ConfigRequestsMessage.new( _method: "config", tid: "3093aad5-bb98-5026-685a-cea540eb9267", bid: "479533e0-cb01-933c-3758-22f2a82abeb8", timestamp: 1679380233000, gateway: "gatewaysn", data: message_data, _data: message_data.deep_stringify_keys ) end def build_thing_product_config_requests_reply_message request_message = build_thing_product_config_requests_message reply_data = { ntp_server_host: "http://time.google.com/", app_id: "123456", app_key: "app_key", app_license: "app_license" } Thing::Product::ConfigRequestsReplyMessage.build_for(request_message, data: reply_data) end def build_thing_product_airport_bind_status_requests_message message_data = { devices: [ { sn: "drone-sn" }, { sn: "dock-sn" } ] } Thing::Product::AirportBindStatusRequestsMessage.new( _method: "airport_bind_status", _data: message_data, tid: "3093aad5-bb98-5026-685a-cea540eb9267", bid: "479533e0-cb01-933c-3758-22f2a82abeb8", timestamp: 1679380233000, data: message_data ) end def build_thing_product_airport_bind_status_requests_reply_message airport_bind_status_request = build_thing_product_airport_bind_status_requests_message Thing::Product::AirportBindStatusRequestsReplyMessage.build_for( airport_bind_status_request, result: 0, bind_status: airport_bind_status_request.data.devices.map.with_index do |device, index| { sn: device.sn, is_device_bind_organization: (index % 2).zero?, organization_id: "12345678", organization_name: "12345", device_callsign: "Device organization callsign" } end ) end def build_thing_product_airport_organization_bind_requests_message message_data = { bind_devices: [ { device_binding_code: "", organization_id: "curo", device_callsign: "", sn: "DOCK01", device_secret: "DEVICE_SECRET", device_nonce: "DEVICE_NONCE", device_model_key: "3-1-0" }, { device_binding_code: "", organization_id: "curo", device_callsign: "", sn: "M30DRONE01", device_secret: "DEVICE_SECRET", device_nonce: "DEVICE_NONCE", device_model_key: "0-67-0" } ] } Thing::Product::AirportOrganizationBindRequestsMessage.new( _method: "airport_organization_bind", _data: message_data, tid: "3093aad5-bb98-5026-685a-cea540eb9267", bid: "479533e0-cb01-933c-3758-22f2a82abeb8", timestamp: 1679380233000, data: message_data, gateway: "DOCK01" ) end def build_thing_product_airport_organization_bind_requests_reply_message airport_organization_bind_request = build_thing_product_airport_organization_bind_requests_message Thing::Product::AirportOrganizationBindRequestsReplyMessage.build_for( airport_organization_bind_request, result: 0 ) end def build_thing_product_airport_organization_get_requests_message message_data = { device_binding_code: "device_binding_code", organization_id: "organization_id" } Thing::Product::AirportOrganizationGetRequestsMessage.new( _method: "airport_organization_get", _data: message_data, tid: "3093aad5-bb98-5026-685a-cea540eb9267", bid: "479533e0-cb01-933c-3758-22f2a82abeb8", timestamp: 1679380233000, data: message_data ) end def build_thing_product_airport_organization_get_requests_reply_message airport_organization_get_request = build_thing_product_airport_organization_get_requests_message Thing::Product::AirportOrganizationGetRequestsReplyMessage.build_for( airport_organization_get_request, result: 0, output: { organization_name: "12345" } ) end def build_thing_product_storage_config_get_requests_message message_data = { module: 0 } Thing::Product::StorageConfigGetRequestsMessage.new( _method: "storage_config_get", _data: message_data, tid: "3093aad5-bb98-5026-685a-cea540eb9267", bid: "479533e0-cb01-933c-3758-22f2a82abeb8", timestamp: 1679380233000, data: message_data ) end def build_thing_product_storage_config_get_requests_reply_message storage_config_get_request = build_thing_product_storage_config_get_requests_message Thing::Product::StorageConfigGetRequestsReplyMessage.build_for( storage_config_get_request, result: 0, output: { bucket: "bucket_name", credentials: { access_key_id: "access_key_id", access_key_secret: "access_key_secret", expire: 3600, security_token: "security_token" }, endpoint: "https://oss-cn-hangzhou.aliyuncs.com", object_key_prefix: "b4cfaae6-bd9d-4cd0-8472-63b608c3c581", provider: "ali", region: "hz" } ) end end end