magellan.js 4.24 KB
module.exports.getAccountDestination = async (req, res) => {
  console.log('===== GET getAccountDestination =====')
  console.log('url', req.originalUrl);
  console.log('headers', req.headers);
  console.log('query', req.query);
  console.log('params', req.params);
  console.log('body', req.body);

  let response = {
    "DestinationInfo": [
      {
        "DestinationId": "61236752144b7900018138c4",
        "AccountId": "60e6e33ae5f6facdc31b5a6d",
        "DestinationName": "destination",
        "DestinationUrl": "http://routeapi.quasar.svc.cluster.local/services/destination",
        "DestinationStatus": "Enabled",
        "Mode": "Raw",
        "PickOutSensor": [],
        "EventType": [
          "Report",
          "Desire",
          "Connection"
        ],
        "CustomHeaders": {
          "x-ais-AccountKey": "60e6e33ae5f6facdc31b5a6d"
        },
        "Things": [
          "60e80fdd252ddf0001b25180",
          "611b93e7af8b3f0001e0acc7"
        ],
        "QueueStorageStatus": "Disabled",
        "LastQueueStorageStatusTimestamp": "0001-01-01T06:43:00+06:43",
        "ErrorCount": 0,
        "CustomProperties": {
          "ForwardDetail": {
            "ThingId": true,
            "ThingName": true,
            "ThingToken": true,
            "ThingIdentifier": true,
            "IMEI": true,
            "ThingCustomDetails": true
          }
        },
        "Authentications": {
          "AuthenType": "NONE"
        },
        "CreatedDatetime": "2021-07-09T15:55:17+07:00",
        "LastUpdatedTimestamp": "2021-08-20T21:25:19+07:00"
      },
      {
        "DestinationId": "61166341144b7900017e5630",
        "AccountId": "60e6e33ae5f6facdc31b5a6d",
        "DestinationName": "cdddddddddddddddddddddddddddddddd",
        "DestinationUrl": "https://mg-iot.siamimo.com/provisioningmessagesharingapis/index.html",
        "DestinationStatus": "Enabled",
        "Mode": "Raw",
        "PickOutSensor": [],
        "EventType": [
          "NONE"
        ],
        "CustomHeaders": {},
        "Things": [
          "611a21caaf8b3f0001dd63f4"
        ],
        "QueueStorageStatus": "Disabled",
        "LastQueueStorageStatusTimestamp": "0001-01-01T06:43:00+06:43",
        "ErrorCount": 0,
        "CustomProperties": {
          "ForwardDetail": {
            "ThingId": true,
            "ThingName": true,
            "ThingToken": true,
            "ThingIdentifier": true,
            "IMEI": true,
            "ThingCustomDetails": true
          }
        },
        "Authentications": {
          "AuthenType": "NONE"
        },
        "CreatedDatetime": "2021-08-13T19:19:13+07:00",
        "LastUpdatedTimestamp": "2021-08-13T23:22:13+07:00"
      }
    ],
    "@Metadata": {
      "CurrentPage": 1,
      "TotalPages": 18,
      "Top": 10,
      "TotalCount": 172,
      "HasPrevious": false,
      "HasNext": true
    },
    "OperationStatus": {
      "Code": "20000",
      "DeveloperMessage": "The requested operation was successfully."
    }
  }

  let response1 = {
    "DestinationInfo": [],
    "@Metadata": {
      "CurrentPage": 1,
      "TotalPages": 18,
      "Top": 10,
      "TotalCount": 172,
      "HasPrevious": false,
      "HasNext": true
    },
    "OperationStatus": {
      "Code": "20000",
      "DeveloperMessage": "The requested operation was successfully."
    }
  }

  res.status(200).send(response1)
}

module.exports.getAccountThings = async (req, res) => {
  console.log('===== GET getAccountThings =====')
  console.log('url', req.originalUrl);
  console.log('headers', req.headers);
  console.log('query', req.query);
  console.log('params', req.params);
  console.log('body', req.body);

  let response = {
    "ThingInfo": [
      {
        "ThingId": "60e80fdd252ddf0001b25180",
        "ThingName": "xNubula."
      },
      {
        "ThingId": "611b93e7af8b3f0001e0acc7",
        "ThingName": "xNubula.2"
      },
      {
        "ThingId": "611a21caaf8b3f0001dd63f4",
        "ThingName": "xName 01"
      }
    ],
    "@Metadata": {
      "CurrentPage": 1,
      "TotalPages": 1,
      "Top": 10,
      "TotalCount": 3,
      "HasPrevious": false,
      "HasNext": false
    },
    "OperationStatus": {
      "Code": "20000",
      "DeveloperMessage": "The requested operation was successfully."
    }
  }

  res.status(200).send(response)
}